Welcome to the iMore Forums Create Your Account or Ask a Question Answers in 5 minutes - no registration required!
Results 1 to 2 of 2
  1. Thread AuthorThread Author   #1  
    bapper1's Avatar
    iPhone Nanite

    1 Posts

    Default Sprite displaying problems


    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:-

    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?


  2. #2  
    ZeroDivision's Avatar
    iPhone Newbie

    20 Posts
    Global Posts
    21 Global Posts



    did you try
    CGRect imageRect = CGRectMake(curX, curY, 320.0-curX, 480.0-curY);

Posting Permissions