Jump to content

"Flip" behavior in 1.1.4


Recommended Posts

I spent the last couple of hours on updating my current project to Phaser 1.1.4, 
and I'm experiencing some weird behavior when it comes to flip a sprite.

This is the code I'm using:

//Set Anchor Pointthis.weapon.sprite.anchor.setTo(-0.1, 0.5);//Rotate Weaponvar weaponRotation = game.physics.angleToXY(this.spritePosition, this.worldX, this.worldY);this.weapon.sprite.rotation = weaponRotation;//Flip Weapon if requiredif (weaponRotation >= -1.5 && weaponRotation <= 1.5) {    this.weapon.sprite.scale.y = 1;} else {    this.weapon.sprite.scale.y = -1;}

On the image below you can see the result in 1.1.3 and in 1.1.4. The weapon gets "shifted" up for some reason.



I can't really tell why that's the case, since I wasn't able to find anything regarding this in the changelog.


Thanks in advance!

Link to comment
Share on other sites

Do you need to use any physics at all on the weapon? If not try setting weapon.body = null and see what happens.

Ah, thanks. I set the position of the body, not the sprite itself, which brings me to another question.

Whats the diffrence with Sprite.x and Sprite.body.x? Because they don't seem to be the same.

Link to comment
Share on other sites


  • Recently Browsing   0 members

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