Deesr Posted February 6, 2014 Share Posted February 6, 2014 Hello!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 More sharing options...
rich Posted February 6, 2014 Share Posted February 6, 2014 Do you need to use any physics at all on the weapon? If not try setting weapon.body = null and see what happens. Link to comment Share on other sites More sharing options...
Deesr Posted February 6, 2014 Author Share Posted February 6, 2014 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 More sharing options...
rich Posted February 6, 2014 Share Posted February 6, 2014 The body is the collision area of the Sprite. It doesn't have to be the same size as the sprite, or located in the same place even, hence having its own x.y properties. Link to comment Share on other sites More sharing options...
Recommended Posts