1. bapper1's Avatar
    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)drawRectCGRect)rect
    {
    UIImage *sprite = [UIImage imageNamed:@"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
    09-25-2009 04:19 PM
  2. ZeroDivision's Avatar
    hi,

    did you try
    CGRect imageRect = CGRectMake(curX, curY, 320.0-curX, 480.0-curY);
    01-20-2010 10:54 PM
LINK TO POST COPIED TO CLIPBOARD