I've got a very simplistic "game" set up on the iPhone. Things move around, rotate, you can interact with them, etc. In the simulator, it runs fine, but on the device it gets around 0.25 FPS, and it's so slow that it doesn't have time to recognize touches, apparently.
This was originally just using a UIView with an array of Item
s each of which had a Tick and a Draw function. At the beginning of the app, I started a Timer that shoots off at 60 FPS, which calls Tick, and at the end of Tick, it calls [self setNeedsDisplay];
It was working so horribly slow, so I turned the Item
class into a subclass of the CALayer
class, moving the layer around instead of redrawing the items. However, I was moving the CALayer
around manually, frame-by-frame, and this, apparently, is no good. It was still way too slow. So I told it to move to its final destination and gave it a length equal to the number of ticks it would take to get there.
That worked okay, but there are cases when, if you interact with something, it should stop moving that way and do something else instead. So I moved back to moving every tick, and instead of just setting the new position, I also wrapped it in a CATransaction and gave the transaction the same length as the tick.
Works OK, but new problem arises: If I want to animate something, I still have to use [self setNeedsDisplay] every tick, which calls drawInContext:
, and this seems to be a major slow down issue.
Isn't there just a way to manually draw everything like I was doing before? I was just making CGContext* calls, and it worked fine in the simulator! It would work fine if I implemented something similar on J2ME or in embedded C++. What am I missing? Do I really need to learn OpenGL to do any sort of interesting manual animation?