Again, everything appears fine now. I think I was confused about how tint composition works as well. I had multiple sprites tinting in a stack, and was thinking that the result would be a combination of the colors I was tinting to, when really I was just filtering more and more color out with each sprite in the stack. :-/ Thanks.
AtlasSpriteManager color issue (on device only)
(34 posts) (9 voices)-
Posted 2 years ago #
-
Ok guys... sorry to bring this old post up again, but I'm having some problems with transparency :-P
So, I have game layer (a regular node that has a TMXTiledMap child). The png transparency on every node/atlas sprite in that is just fine, the borders look ok, the transparency is also good (in the device, in the simulator there are some known problems).
When the hero dies or the level is ended, I want to show a layer that is basically white with an alpha channel. I create this layer together with a new atlas sprite manager (which is using the same texture as several of the layers in the TMX map), and create a new atlas sprite with the rects I want. When showing the new layer, the sprite looks grey, like it's ignoring the alpha channel.
I'm using cocos v0.8.2 and my code looks like this:
In the app delegate:
// default values from the Box2D Template [[Director sharedDirector] setPixelFormat:kPixelFormatRGBA8888]; [[Director sharedDirector] setDepthBufferFormat:kDepthBuffer16]; [Texture2D setDefaultAlphaPixelFormat:kTexture2DPixelFormat_RGBA8888];somewhere in my level controller
if (endState == gffLevelFinishedDead) { GameOver *go = [GameOver menuWithLevel:self state:endState]; [self addChild:go]; }and this is the relevant code for GameOver (which is a Layer)
- (id)initWithLevel:(GameLevel *)level state:(levelEndState)endState { if ((self = [super init])) { gameLevel = level; // create sprite manager for the overlay AtlasSpriteManager *sm = [AtlasSpriteManager spriteManagerWithFile:@"SheetWorld01-1.png"]; // create game over sheet AtlasSprite *overlay = [sm createSpriteWithRect:CGRectMake(544.0f, 704.0f, 480.0f, 320.0f)]; overlay.anchorPoint = CGPointZero; [sm addChild:overlay]; // add menu and the items // add sprite manager to the menu [sm setBlendFunc: (ccBlendFunc) {GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA}]; [self addChild:sm]; } return self; }I tried with several blend functions, some set the sprite white, but none I tried is what I'm expecting: to see through that layer... I'm sure I'm missing something really basic here... Any pointers?
thanks!
Posted 2 years ago # -
Another weird thing is that right after adding the layer, the fps drop from 60 to about 6... :-S
[EDIT] I now changed the AtlasSpriteManager for a regular Sprite (created with spriteWithFile) and same thing happens: the framerate drops and the sprite does not blend correctly... :-S
[EDIT] the framerate dropping was my mistake :-P
Posted 2 years ago # -
Finally I've opened a bug on the Apple Bug Tracker regarding the
CGImageGetAlphaInfoon the simulator.
Bug ID #7489024Posted 2 years ago #
Reply
You must log in to post.