Jump to content

Sprite body rotation


hellspawn_bg
 Share

Recommended Posts

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:

 

space_Ship.png

 

Thanks :)

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Guest
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.

Loading...
 Share

  • Recently Browsing   0 members

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