Sprite displaying problems

bapper1

New member
Sep 25, 2009
1
0
0
Visit site
Hi,

I'm completely new to iPhone development and am trying to write a simple game in Quartz2D. I'm stuck at the first hurdle, displaying the sprite on the screen.

I've worked out how to load my .png image and have successfully displayed it in a UIImage, so I know it's loading OK. But when I try to draw it to the screen using CGContextDrawImage nothing shows.

Here's my Code:-

-(void)drawRect:(CGRect)rect
{
UIImage *sprite = [UIImage imageNamed:mad:"icon.png"];
CGRect imageRect = CGRectMake(curX, curY, 320.0, 480.0);

CGContextRef context = UIGraphicsGetCurrentContext();
CGContextDrawImage(context, imageRect, sprite.CGImage);

}

I've put it in the main ViewController of my app.

I've kept the code really simple so I don't see where I could be going wrong. Has anyone got any ideas?

thanks,

Bapper
 

Trending Posts

Members online

Forum statistics

Threads
260,365
Messages
1,766,580
Members
441,240
Latest member
smitty22d2