hi all,
I want to make my sprite move from 'a' position to 'b' then back to 'a' when I touch the screen. This will happen only when y axis of the sprite equals to 43. So I add the restrain. The following code works well with what I said.
But the problem is the frame will decrease to 20-30 fps at both the beginning and the ending.
Am I use the code right so something wrong with my thought. Hoping your help.
Thanks advanced.
alex
- (BOOL)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
BOOL mark = NO;
CCSprite *sprite = (CCSprite*)[self getChildByTag:Tag];
int y = sprite.position.y;
if(y == 43)
{
id action1 = [CCMoveTo actionWithDuration:0.6 position:ccp(180,43+160)];
id action2 = [CCMoveTo actionWithDuration:0.6 position:ccp(180,43)];
id action3 = [CCSequence actions:action1,action2,nil];
[sprite runAction:action3];
}
return mark;
}