Quartz game design?

Posts: 5
Joined: 2008.08
Post: #1
Hi all!

I'm using Core Graphics for a puzzle/action game I'm working on, but with this being the first game I've written I'm not sure if my "game engine" will work well on an iPhone.

- I have each sprite in a (small) separate CGLayer.
- I draw that layer to a (full size) sprite layer with a transparent background.
- I draw the background image to another, opaque layer.
- I overlay the sprite layer on the backgroundlayer to an offscreen layer
- I draw the offscreen layer to the screen.

Is that a good/bad/silly way of doing it?
Should I just quit, and use OpenGL instead?
I might find a tidier approach if I knew how to blit just a rectangle from one context to another; without having to copy/draw the entire context. If I did this, I could also have every frame of one sprite in just one CGLayer, and copy the relevant rectangle as needed.

The game performance on the device seems to be getting slower already, even before I add sound effects & ambient sounds. (As an aside, does playing a long sound file significantly tax the CPU, even it's a low bit-rate?)

I know I'm asking a lot, many thanks for any advice!
Quote this message in a reply
Posts: 5
Joined: 2008.08
Post: #2
Sorry to bump my own thread, but I waffled on a bit in my previous message, when I really have just two questions:

- Is there a way of copy an area (rect) from one Core Graphics context to another?

- Is it faster/slower to use an offscreen buffer in an iPhone Core Graphics game? (It takes >10 minutes to install the game on my device, so it's difficult to profile!)

Many thanks for any help!
Quote this message in a reply
Posts: 5,143
Joined: 2002.04
Post: #3
Nobody can answer the iPhone-specific parts of the question due to the http://fuckingnda.com/ , but on Mac OS X, using Quartz for a game is a pretty poor idea. Either OpenGL or CoreAnimation will get you hardware acceleration for your graphics.
Quote this message in a reply
Posts: 3,591
Joined: 2003.06
Post: #4
Well, I think I can say, without much risk of NDA violation, that at least the way you're doing it is indeed the hard way. Heed OSC's advice. Core Animation is probably closer to what you've already been doing. Just read the docs carefully on it and you'll be rolling. If that still isn't good enough performance-wise, then move up to OpenGL.
Quote this message in a reply
Posts: 5
Joined: 2008.08
Post: #5
Thanks to both of you for the advice!

I only went with CoreGraphics as I have experience with it before on OSX, so it was one less "unknown" - this is my first attempt at game programming, and obviously first at an iPhone app!

The game screen is mostly static, so I might get away with no h/w acceleration for this project, but will have to finally dig up some OpenGL manuals for future projects "on all Apple platforms" Wink

Thanks again!
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  How to design short game levels vangelisfx 1 3,317 Dec 23, 2009 01:27 PM
Last Post: ThemsAllTook
  frame rate for a Quartz game? aerospaceman 2 5,086 Jun 22, 2009 10:56 AM
Last Post: longjumper
  Quartz Text showing up mirrored and rotated aerospaceman 4 5,906 Jun 21, 2009 08:18 AM
Last Post: aerospaceman
  [iPhone Dev] 2D Games, OpenGL or Quartz? jAuriya 17 21,940 Jun 10, 2008 01:45 PM
Last Post: jAuriya