Question

Moved to version 2.0 of Cocos2D but I'm trying to find a workaround solution to convert UIImage to CCSprite, previous one like:

        CCTexture2D *texture = [[[CCTexture2D alloc] initWithImage:tempImage] autorelease];
        self.spriteImage = [CCSprite spriteWithTexture:texture];

Note:

tempImage is a UIImage object

Was it helpful?

Solution

Try this:

self.spriteImage = [[CCSprite alloc] initWithCGImage:tempImage.CGImage 
                                                 key:@"unique image name"];

Alternatively there's also a initWithCGImage method in CCTexture2D if you prefer to use that.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top