Domanda

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

È stato utile?

Soluzione

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top