Weird behaviour with CCTexture2D (v simple code)
In my app I've got a CCTexture2D, which I'm creating using an image, creating a sprite from the texture, then adding to the stage, like this:
UIImage* faceUIImage = [UIImage imageNamed:@"face.jpg"];
CCTexture2D* faceTest = [[CCTexture2D alloc] initWithImage:faceUIImage];
CCSprite* testSprite = [CCSprite spriteWithTexture:faceTest];
[self addChild:testSprite];
testSprite.position = CGPointMake(200, 100);
(I know this might seem a weird way to do it, but I'm doing some stuff to the pixel data elsewhere in the program, so I cant just use a pure sprite).
In the simulator, it looks fine:
However, when I run it on my iPhone (running 4.2), I get this:
Ignoring the fact that t开发者_C百科hey are different orientations, how come the image on my device is in the background, and really dark? Can anyone help me with this?
Thanks, Rich
Did you try :
[self addChild:testSprite z:1];
Eventually I fixed this simply by changing the jpg to a png instead... Maybe cocos2d doesnt really like jpg?
精彩评论