I've implemented simple collision detection for squares (for now), but it seems to be lagging on my device and I don't know why.
I have a subclass of SPSprite called "Shape" which defines the shape of an object in the game (in this case a square) and it's location. It also has a function "inCollisionWith:(Shape *)shape2" which returns true if it collides with shape 2 (determined by 4 simple comparisons of the x and y coordinates).
I have a subclass of SPSprite called "GameBoard", to which all the shapes are added as children. It has a function "checkCollisionFor:(Shape *)shape" which calls [shape inCollisionWith: child_i] for each child.
Shape objects can be dragged. They have SPTouchPhaseMoved listeners which call [self.parent checkCollisionFor:self] (parent is the GameBoard class) before updating the location.
I noticed that the lagging increased as the game was running, so I checked the Allocations in Instruments. There seem to be many SPPoints,SPMatrix and SPRectangles that get created and not released (71769 living SPPoints, 56541 living SPMatrix, 14000 living SPRectangle). I don't use SPMatrix, and the only place that SPPoints are used is in the touchListener, where SPPoint *currentPos = [touch locationInSpace:self.parent] is called (and also for previousPos). But these are not instances that I need to release right?
Does anyone have an idea what is going on?