我正在使用CCSequence动作,我希望我的精灵在触摸并按住时保持特定动作,并在触摸结束后继续执行序列。
-(BOOL) ccTouchBegan:(UITouch *)touch withEvent:(UIEvent *)event{
id downward = [CCRotateTo actionWithDuration:0.1 angle:45];
id straight = [CCRotateTo actionWithDuration:0.1 angle:0];
id stable = [CCSequence actionWithDuration:1.0];
id upward = [CCRotateTo actionWithDuration:0.1 angle:-45];
id Seq = [CCSequence actions:downward, straight, stable, upward, nil];
[mySprite runAction:Seq];
}
-(void) ccTouchEnded:(UITouch *)touch withEvent:(UIEvent *)event{
}
我希望这个“id stable = [CCSequence actionWithDuration:1.0];”当Touch处于保持状态时,替换为浮动的时间间隔。并在触摸结束时重置它。
非常感谢任何帮助。
答案 0 :(得分:0)
如果我记得很清楚你应该能够为你的行动设置标签(setTag)。
您可以在ccTouchBegan中设置标记,并使用ccTouchEnded中的此标记从其节点检索此特定操作,这样您就可以根据需要暂停,终止或替换操作。