Reputation: 1187
I'm using CCSequence Actions and I want my sprite to hold at a specific action while touch and hold and continue the sequence once the touch is ended.
-(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{
}
I want this "id stable = [CCSequence actionWithDuration:1.0];" replaced with a float of time interval while the Touch is on Hold. And reset it when the touch ends.
Any help is much appreciated.
Upvotes: 2
Views: 558
Reputation: 561
If i recall well you should be able to set a tag to your action (setTag).
You could set the tag in ccTouchBegan and retrieve this particular action from its node using this tag in ccTouchEnded, which would allow you to pause, terminate, or replace the action as needed.
Upvotes: 0