0
votes

When checking shapes collision with andengine, I usually use:

//set new position for the shape
mySecondShape.setPosition(mySecondShape.getX() + x, mySecondShape.getY() + y);   

//check collision
if(myFirstShape.collidesWith(mySecondShape))

I want to know if 2 shapes will collide before setting the new position, like :

if(myFirstShape.collidesWith(mySecondShape, addToX, addToY))

does a such method exist ? Thank you for reading

1

1 Answers

0
votes

No, I don't think such a method exists.

You can:

  • Create a dummy shape - same size and everything, but invisible. Then, you could move this dummy and check for collision before moving the real shape.
  • If you react to the collision right after moving the shape, it shouldn't be a problem - AndEngine won't draw the shape while your code executes (If it runs on the UpdateThread).