Jump to content

Debug in Phaser.State


Recommended Posts

Hi there,


I'm new to Phaser and new to TypeScript, I just work on the base of the tutorials and set up the multi state project. I created two sprites and want to display the sprite bodies. But this doesn't work. Here is my code:

module TestGame {     export class Level1 extends Phaser.State {				sp:Phaser.Sprite;		sp2:Phaser.Sprite;		        create() {        	this.sp = this.game.add.sprite(80,200,"preloadBar");        	this.sp.angle = 70;        	this.sp.body.immovable = true;					this.sp2 = this.game.add.sprite(100,50,"loader2");		this.sp2.body.collideWorldBounds = true;        	this.sp2.body.bounce.y = .6;		this.sp2.body.gravity.y = 100;        }                        update(){	        this.game.physics.collide(this.sp, this.sp2, this.collisionHandler, null, this);        }                render(){        	console.log(this.game.debug.renderSpriteBody);        	console.log(this.sp);        	console.log("---");	        this.game.debug.renderSpriteBody(this.sp);	        this.game.debug.renderSpriteInfo(this.sp, 100, 100, "#ffffff");        }                collisionHandler(){	        if (this.sp.body.touching.down) console.log("DOWN");        }        		    } // end of class} // end of module

The sprites are displayed and working and the render function logs the data correctly, but neither sprite collision bounds nor sprite info are displayed.


It works fine if I don't use States.


Any ideas, what I do wrong?

Link to comment
Share on other sites

  • 3 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...