Monday, April 25, 2011

How to render animation or effects using Core Graphics

I want to draw a projectile of a cannon moving and explosive effects (just simple broken bits flying around). How should I approach this using Core Graphics (on iPhone)?

I am using an NSTimer to call a render method and update the animated projectile or explosive effects and I have no problem drawing each individual pieces (such as filled rec, or line) but I found that drawRect always erases the previous content and only render the new stuff.

How would you approach this?

From stackoverflow
  • There's a really good book on this at the Pragmatic Programmers site.

    hhafez : I looked at that book at the book store it only has one chapter on iphone? Is coreanimation on iphone and macosx that simmilar?
    Boon : This is not so much an animation issue as it is a rendering issue, so that book won't be of much help (case in point, I have that book so I know).
  • Found the solution, use setNeedsDisplayInRect instead of setNeedsDisplay and limit to the small area I was drawing into (Thanks Erica).

0 comments:

Post a Comment

Note: Only a member of this blog may post a comment.