Jump to content
This forum will be closing down. Please move to the respective dedicated project forums.

Changing Sprite's Scale Causes Physics Body To Become Detached


Disease
 Share

Recommended Posts

I'm using Phaser 2.4.8 and seem to be having a strange issue. 

In the player sprite constructor I set the anchor to .5, .5

this.anchor.setTo(.5, .5);

The spritesheet is drawn with the character facing right, so when the player presses LEFT this is what I do to point it left:

          if (this.game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
            if (this.scale.x == 1) {
              this.scale.x = -1;
            }
}

Unfortunately this simple act causes the Sprite's physics body to leap to the sprite/sprite texture's right side for no reason I can see. The image of the character moves around fine but the physics body jumps around every time the scale switches between 1 and -1. 

You can see this happening with all the debugging information turned on at:

http://syntonicstudios.github.io/Shapeshifter/bin/index.html

Also the entire source of the game is at:

https://github.com/SyntonicStudios/Shapeshifter

I thought I was missing something simple until I looked at an old game I did wish Phaser were I did the exact same thing but this issue did not crop up at all. 

Anyone know what is going on here? 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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