I'm developing 2D Side scroll Android Game, using AndEngine and its BOX2D extension.
I have player body, with 2 sensors for 'feet' and 'head' so I might know exactly which side of the player touched different object etc. Here's image showing how does it work:
It works well for checking if player is currently touching ground with feet, so he can jump for example, etc. Now I'm trying to implement actions executed after contact with monster body.
In my contact sensor, I'm checking
if (x1.getBody().getUserData().equals("monster") && x2.getUserData().equals("foot"))
{
jump();
}
if (x1.getBody().getUserData().equals("monster") && x2.getUserData().equals("player"))
{
GameManager.playSound(lostSound);
handleDie();
}
But every time I jump on the 'head' of the monster (So basically I'm touching it with feet sensor) died action is executed. Because both contacts are noticed by contact listener, it works if I would make feet sensor higher, to protrude more from player body (player body is exact shape of player's sprite texture) so it would look like there wasn't contact between player and monster at all.
Thanks in advance for any tips how to handle it properly.