Jump to content

A problem with collision when a sprite changes size


ylluminarious
 Share

Recommended Posts

Hi all,

 

I have a sprite in my game that changes size at certain points in the game. It changes size via the `sprite.body.setSize` method. Unfortunately, it seems that the sprite is unaffected by objects that it should collide with whilst it is in the process of changing size. This makes sense because the sprite's boundaries are in a state of flux during the process of a size change, but this is bad because my user can take advantage of this and move through walls. I'm not sure how to get the sprite to be susceptible to collision while in the process of changing size. Does anyone know a way around this?

Link to comment
Share on other sites

There may be an easier solution for that but here it is.

You can enable an overlap check when the player is resizing ,see at which side is the wall relative to the sprite and then move the sprite away from the wall until the resizing is complete. After that you can disable the overlap check.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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