hellspawn_bg Posted November 13, 2014 Share Posted November 13, 2014 Hey guys, I have noticed that when I rotate my sprite by altering the angle, the physical body of the sprite doesn't get rotated. Any ideas why? Here is my code: preload: function() { this.starShip = this.add.sprite(this.world.centerX, this.world.centerY, 'starShip'); this.starShip.anchor.setTo(0.5, 0.5); // Needed for the collision detection this.game.physics.arcade.enable(this.starShip); }, update: function() { // Player turns left if (this.cursors.left.isDown) { this.starShip.angle -= 3; } // Player turns right else if (this.cursors.right.isDown) { this.starShip.angle += 3; } }, render: function() { this.game.debug.body(this.starShip); }And here is the result: Thanks Link to comment Share on other sites More sharing options...
spencerTL Posted November 13, 2014 Share Posted November 13, 2014 Could be wrong on this but I think Arcade physics can only make use of bodies that are rectangular and unrotated. I think you'd need to use P2 for what you want. So effectively there is no point in the body rotating as it can't be used for the physics anyway. Link to comment Share on other sites More sharing options...
hellspawn_bg Posted November 13, 2014 Author Share Posted November 13, 2014 Strangely though, the physics arcade body has allowRotation property which returns true in my case. Link to comment Share on other sites More sharing options...
spencerTL Posted November 13, 2014 Share Posted November 13, 2014 True, and a rotation property according to the docs. My reasoning was based on Arcade physics being aabb so axis aligned bounding box. I could well be wrong though. I've learnt a lot trying to answer questions on this forum but my answers are definitely less trustworthy than those of Lewster etc!Actually i've just found an answer to this from lewster in this thread which explains the rotation property of body.http://www.html5gamedevs.com/topic/6514-spriteangle-and-bodyrotation-questions/3rd post in. lewster32 1 Link to comment Share on other sites More sharing options...
Recommended Posts