使对象在 CCActionSequence 之后消失
Making an Object disappear after a CCActionSequence
我正在制作一个 iOS 游戏,其中的一部分包括一个随机生成的弹珠,它沿着一条路径移动,并在完成该路径后消失。这是我用来生成和移动大理石的方法:
-(void) createMarbleObstacle :(CCTime) randomTimeInterval{
marbleObj = (Marble *)[CCBReader load: @"Marble"];
marbleObj.position= _cLnode.position;
[_contentNode addChild: marbleObj];
[marbleObj moveMarble:(randomTimeInterval*5) :_bLnode: _aLnode];
}
-(void) moveMarble: (CCTime)interval :(CCNode*)a :(CCNode*)b{
moveM1 = [CCActionMoveTo actionWithDuration:(interval) position: a.position];
moveM2 = [CCActionMoveTo actionWithDuration:(interval) position: b.position];
moveM4 = [CCActionSequence actions:moveM1, moveM2, nil];
[self runAction: moveM4];
}
但是,我不知道如何在 CCActionSequence
完成后让大理石消失。感谢您的帮助。
在 moveMarble
:
中为您的序列添加另一个动作
id clean = [CCActionCallBlock actionWithBlock:^{
[_contentNode removeChild:marbleObj cleanup:YES];
}];
moveM4 = [CCActionSequence actions:moveM1, moveM2, clean, nil];
或类似的东西:)
我正在制作一个 iOS 游戏,其中的一部分包括一个随机生成的弹珠,它沿着一条路径移动,并在完成该路径后消失。这是我用来生成和移动大理石的方法:
-(void) createMarbleObstacle :(CCTime) randomTimeInterval{
marbleObj = (Marble *)[CCBReader load: @"Marble"];
marbleObj.position= _cLnode.position;
[_contentNode addChild: marbleObj];
[marbleObj moveMarble:(randomTimeInterval*5) :_bLnode: _aLnode];
}
-(void) moveMarble: (CCTime)interval :(CCNode*)a :(CCNode*)b{
moveM1 = [CCActionMoveTo actionWithDuration:(interval) position: a.position];
moveM2 = [CCActionMoveTo actionWithDuration:(interval) position: b.position];
moveM4 = [CCActionSequence actions:moveM1, moveM2, nil];
[self runAction: moveM4];
}
但是,我不知道如何在 CCActionSequence
完成后让大理石消失。感谢您的帮助。
在 moveMarble
:
id clean = [CCActionCallBlock actionWithBlock:^{
[_contentNode removeChild:marbleObj cleanup:YES];
}];
moveM4 = [CCActionSequence actions:moveM1, moveM2, clean, nil];
或类似的东西:)