Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>If option 2 is sufficiently performant for your needs I would stick with that - it's as easy a system as you'll get on the iPhone and fine for very simple graphics. A related option that might buy you a little bit of speed is using CALayers to implement the graphics. CALayers are almost as easy to use, but are a bit more lightweight than UIViews (in some ways you can think of UIViews as just wrappers for CALayers with additional overhead for managing things like touch events, etc.)</p> <p>If you're interested I would read the Core Animation Programming Guide (I would provide a link but I think my reputation is too low, but Google should track it down for you). Core Animation is a big subject and can be pretty daunting but if you just use layers (i.e. not the animation parts of it) it's not so bad. Here's a quick example to give you a sense of what using layers looks like:</p> <pre><code>// NOTE: I haven't compiled this code so it may have typos/errors I haven't noticed UIView* canvasView; // the view that will be the "canvas" for your game ... // initialize the canvas, etc. CALayer* imageLayer = [CALayer layer]; UIImage* image = [UIImage imageNamed: @"MyImage.png"]; imageLayer.content = (id)image.CGImage; imageLayer.bounds = CGRectMake(0, 0, image.size.width, image.size.height); imageLayer.position = CGPointMake(100, 100); // NOTE: Unlike UIViews CALayers have their origin at the center [canvasView.layer addSublayer:imageLayer]; </code></pre> <p>So basically it looks a lot like working with views but with some added performance (and occasional headache). </p> <p>P.S. - One thing to keep in mind is that if you make changes to a layer's property that is animatable (e.g. position, opacity, etc.) Core Animation will implicitly animate it (e.g. if you write imageLayer.position = somePoint; the layer animates to that position rather than having it's position set immediately. There's easy ways to work around that but that's a topic for another question/answer.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload