0
我试图强制一个动作完成,然后才能调用另一个动作。我查看了各种时间延迟和CCSequencing的例子,这是迄今为止,但它仍然无法正常工作。我需要完整的.5出现在另一个动作之前(无论是向左,向右还是向下)。只要你在动作完成之前没有按下按钮,所有事情都会发挥作用,那就是当先前的动作被缩短时。cocos2d iphone等待动作完成/完成
-(void) moveup{
CCNode *mySprite = [self getChildByTag:kTagSprite];
//moves sprite up 30 pixels in 1/2 second
[mySprite runAction: [CCMoveTo actionWithDuration:.5 position:ccp(mySprite.position.x, mySprite.position.y+30)]];
}
//this is inside CCtouchesbegan. upsprite is a box that gets clicked to move the object up
if(CGRectContainsPoint([upsprite boundingBox], point)){
//should call CCSequence of events, method moveup, and then CCDelayTime, forcing a pause
[self runAction:[CCSequence actions:[CCCallFuncND actionWithTarget:self selector:@selector(moveup) data:nil], [CCDelayTime actionWithDuration:.5], nil]];
}
我试着用[[CCDirector sharedDirector] pause]
暂停但这冻结一切,包括我的移动精灵。在我目前的例子中,CCDelayTime似乎不起作用。
我知道这个问题有点像ccsequencing其他人的副本,所以如果它需要被标记为复制,那很好,但我真的很喜欢一些帮助,因为它真的让我失望。
这与我最终做的相似。最简单的方法是调用初始移动动作,然后在该调用下调用[lolosprite runAction:[CCSequence actionOne:[CCDelayTime actionWithDuration:.5] two:[CCCallFunc actionWithTarget:self selector:@selector(enabletouch)]]] ]。使用它你可以直接禁用触摸,直到你用方法enabletouch再次打开它。我正在用CCAction方法(isdone)尝试bool方法,但isdone总是返回false,所以bool从未被设置回解锁状态。我仍不确定为什么isdone没有工作。 – 2011-06-10 14:37:12
我有同样的问题,不知道我是否理解你的解决方案 – RollRoll 2014-08-12 15:34:45