Iphone 如何在Cocos2D中将雪碧添加到另一个雪碧上?
我想有一个雪碧在另一个雪碧,并希望给动画的雪碧在顶部。有谁能给我推荐一个方法吗?我试过这个Iphone 如何在Cocos2D中将雪碧添加到另一个雪碧上?,iphone,cocos2d-iphone,xcode4.3,Iphone,Cocos2d Iphone,Xcode4.3,我想有一个雪碧在另一个雪碧,并希望给动画的雪碧在顶部。有谁能给我推荐一个方法吗?我试过这个 CCLayer *foreground = [CCLayer node]; CCSprite* background = [CCSprite spriteWithFile:@"background.png" ]; background.position = ccp( 150, -120 ); seeker1 = [CCSprite spriteWithFile: @"wa
CCLayer *foreground = [CCLayer node];
CCSprite* background = [CCSprite spriteWithFile:@"background.png" ];
background.position = ccp( 150, -120 );
seeker1 = [CCSprite spriteWithFile: @"wave.png"];
seeker1.position = ccp( 180, 420 );
[seeker1 addChild:background z:-1];
[foreground addChild:seeker1];
[self addChild:foreground z:1];
id waves = [CCWaves actionWithWaves:5 amplitude:15 horizontal:YES vertical:YES grid:ccg(15,10) duration:5];
id a1 = [CCMoveBy actionWithDuration:3 position:ccp(0,-200)];
id action2 =
[CCSequence actions: [[a1 copy] autorelease], [a1 reverse], nil];
id action = [CCSpawn actions:
action2,
waves,
nil];
[seeker1 runAction:action];
但是,当我运行程序时,它会为整个层提供动画。任何人都可以只为seeker1提供动画吗?这是因为您已将背景精灵添加为seeker1 sprite的子项 我假设您打算将背景添加为前景层的子层。大概是这样的:
[foreground addChild:background z:-1];
这是因为您已将背景精灵添加为seeker1 sprite的子级 我假设您打算将背景添加为前景层的子层。大概是这样的:
[foreground addChild:background z:-1];