2

我正在使用 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 处于保持状态时替换为时间间隔的浮点数。并在触摸结束时重置它。

任何帮助深表感谢。

4

1 回答 1

0

如果我记得很清楚,您应该能够为您的操作设置标签(setTag)。

您可以在 ccTouchBegan 中设置标记,并使用 ccTouchEnded 中的此标记从其节点检索此特定操作,这将允许您根据需要暂停、终止或替换操作。

于 2012-01-09T19:56:36.567 回答