0
votes

I am trying to make a simple skateboarding game using AndEngine and the Box2D physics addon. I am trying to make a 'grind' rail and need to test if the bottom of my player is in collision with the top of the grind rail; I know the common way to do this is to resize the collision box to 1 pixel along each edge of the sprite and test for collision, but I have no idea how I can resize the collision box of any of my sprites bodies.

I would just use Andengines collision detection but box2Ds collision detection and general physics stop some things being detected as a collision with AndEngines collision detection, so I have been trying to make a new 'ContactListener' for my physics world and play around with the 'beginContact(Contact contact)' method, but differentiating between things that are colliding is a lot less straightforward and I'm not really sure what i'm doing...

Also, I would like the ability for my player to pass beside the rail (in front of it) but at the moment my player collides with its edges and stops.

At the moment box2D is seeming like more effort than its worth and I'm very tempted to rip it out of my code and just go with AndEngines collision detection instead and have a crack at my own simple physics...

1
This page might be useful iforce2d.net/b2dtut/collision-callbacks You could probably use the b2ContactFilter::ShouldCollide function to decide when the rail should be collidable.iforce2d
@iforce2d thanks for the pointer I'll look into it nowAndroidNoob

1 Answers

1
votes

You can attach 'Userdata' (Type: Object) to the Body objects you create. I would make some kind of Userdata class and extend sth like SkateBoardUserdata and GrindRailUserdata.