Selective collisions – shooting

Screen Shot 2014-10-21 at 1.05.53 PM
Let’s examine a series of common problems occurring when an object spawns another, e.g. shooting.

Download the example: example11b – bullets

If you don’t want certain objects to collide with some other objects give them the same groupIndex:


The isBullet property makes for more precise collisions with fast moving objects


To shoot at an angle we use the trigonometry we’ve seen before:

float bulletVX = bulletSpeed * cos(angle);
float bulletVY = bulletSpeed * sin(angle);
Posted in

Post a comment