Using CGContext to Display iPhone Sprite Sheet
So, I have a spritesheet in png format and I have already worked out the coordinates for what I want to display. I am trying to create a method that will return a UIImage when passing location information on a sprite. I just don't know how to use the CGContext stuff along with the coordinates to return the UIImage.
I was looking for CGContextClipToRect because I think this is the way to do it, but I just cannot get it to work.
Something like that
CGSize size = CGSizeMake(xSize, ySize);
UIGraphicsBeginImageContext(size);
//CGContextClipToRect(spriteSheet.size, imageRect);
[spriteSheet drawAtPoint:CGPointMake(xPos, yPos)];
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return newImage;
only returns what is in the Context size. I need to be able to "move" this size box around the sprite if that makes sense.
Any help would be appreciated.
Thanks, Mike
a source to share