我有一个像这样的场景:
MyScene(CClayer的子类)
的.m
+(CCScene *) sceneWithSprite:(CCSprite*)sback
{
return [[[self alloc] initWithSprite:sback] autorelease];
}
-(id) initWithSprite:(CCSprite*)sback
{
self = [super init];
if (self) {
self.spriteBack = sback;
// sback is a sprite that comes from the previous scene
// remove sback from that scene, so we can add it here
[sback removeFromParentAndCleanup:NO];
[self addChild:self.spriteBack z:-1];
CGSize windowSize = [[CCDirector sharedDirector] winSize];
CGFloat midX = windowSize.width/2.0f;
CGFloat midY = windowSize.height/2.0f;
CCMenuItemLabel *menuItem1 = [CCMenuItemFont itemFromString:@"item 1" target:self selector:@selector(multi:)];
CCMenuItemLabel *menuItem2 = [CCMenuItemFont itemFromString:@"item 2" target:self selector:@selector(multi:)];
CCMenuItemLabel *menuItem3 = [CCMenuItemFont itemFromString:@"item 3" target:self selector:@selector(multi:)];
CCMenu *menu = [CCMenu menuWithItems:menuItem1, menuItem2, menuItem3, nil];
[menu alignItemsVertically];
[self addChild:menu];
menu.position = ccp(midX, midY);
}
return self;
}
我需要做一个淡出过渡。我使用
调用前一个场景 CCScene *menu = [Menu sceneWithSprite:spriteBack];
[[CCDirector sharedDirector] replaceScene:
[CCTransitionFadeDown transitionWithDuration:0.5f scene:menu]];
问题是转换发生黑色然后突然出现新场景。
有没有办法在没有黑色的情况下从当前场景转换到新场景?
感谢
答案 0 :(得分:0)
试试CCTransitionCrossFade
。如果您在交叉淡入淡出中间有一个淡入白色的问题,请参阅此主题:http://www.cocos2d-iphone.org/forum/topic/28949