Jump to content

Setting the body.x

Dream Of Sleeping

Recommended Posts

I'm having all sorts of weird issues with collision.


Do I set the sprite.x and sprite.y when I need to position it? Because setting the sprite.body.x often doesn't seem to work. If I alter the sprite.x and the move the body.x do I take into consideration the anchor being centered in the sprite? Do I set the body.x - the sprites half width?



Link to comment
Share on other sites

There are much better people than me at this sort of thing but as a suggestion if you need to move the sprite outside the physics could you kill it and then revive it in the correct place. This sort of thing happens all the time in sprite pooling so should work. If anything is placed where two bodies interest though they'll whizz off. (They do in P2 anyway). When I had this I always calculated a point a set distance and rotation from one of the sprites so that the two bodies would not intersect when the new one was added.

I hope this is some help or that somebody with a better idea contributes.


This thread incicates that what you are doing will have weird effects:


Link to comment
Share on other sites

Thank you very much for replying. I'm actually starting to really depressed about this, so I might just not finish this time. I wish I'd used create js now.


That thread was useful thank you. If I do continue in the morning will just have to write my own functions to test collision. I can't possibly understand why the sprite. intersect method always returns true.

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.

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.


  • Recently Browsing   0 members

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