all, I am making a game in which a sprite is move from one position to another through a jerk of 19 pixel, basically I want to make a game just like stacker online. in the app store, in this game the box is move through a jerk of 19 piexel , and the object is moving is in the grid , i have following code but I not give me the jerk motion
-(void)actionLayer
{
isRunning = 0;
addPixedlValue += 19;
id actionMove = [CCMoveTo actionWithDuration:6 position:ccp( 50,109)]; //300,100
id actionMoveDone = [CCCallFuncN actionWithTarget:self selector:@selector(LayerAction:)];
animateAction = [CCSequence actions:actionMove, actionMoveDone, nil];
NSLog(@"pixel value %d",addPixedlValue);
[boxSprite runAction:animateAction];
}
-(void)LayerAction:(id)sender
{
addPixedlValue +=19;
id actionMove = [CCMoveTo actionWithDuration:6 position:ccp( 270,109)]; //300,100
id actionMoveDone = [CCCallFuncN actionWithTarget:self selector:@selector(actionLayer)];
animateAction = [CCSequence actions:actionMove, actionMoveDone, nil];
[boxSprite runAction:animateAction];
}
I think your problem can be sort out By scheduling a selector for a time interval say 0.1 and you can update the position according to your self.
And unshedule the selector whenever needed to stop the sprite.
For Scheduling a selector
For unscheduling
This help you in make jerking movement.