When the scene moves, it moves (sometimes not always) in an absurd and jerky way that leads to irritation. The following code has been used to move the scene:
//NAVIGATION TOWARDS X AND Y WhenEver and how ever you want
if (abs(diffX) > abs(diffY)) //Scroll in x
{
//CCLOG(@"yScrlFlag=%d",yScrlFlag);
if(diffX > 0)
{
xScrlFlag=1;
[self.parent runAction:[CCMoveTo actionWithDuration:round(-(-3112-self.parent.position.x)/950)
position:ccp((-3112-self.position.x),self.parent.position.y)]];
[resetPosition setIsEnabled:YES];
[resetPosition runAction:[CCMoveTo actionWithDuration:round(-(-3112-self.parent.position.x)/950)
position:ccp((3112+self.position.x+70),resetPosition.position.y)]];
//[self.parent.menuButton setIsEnabled:NO];
}
else
{
xScrlFlag=0;
[self.parent runAction:[CCMoveTo actionWithDuration:(-self.parent.position.x/950)
position:ccp(0,self.parent.position.y)]];
//[resetPosition setIsEnabled:YES];
[resetPosition runAction:[CCMoveTo actionWithDuration:(-self.parent.position.x/950)
position:ccp(141,resetPosition.position.y)]];
}
}
else //Scroll in y
{
if(diffY < 0)
{
[resetPosition setIsEnabled:YES];
//CCLOG(@"MOVING PARENT BY=%f",(-self.position.y));
//CCLOG(@"self.parent.position BEFORE MOVE=(%f, %f)",self.parent.position.x,self.parent.position.y);
//CCLOG(@"resetPosition.position BEFORE MOVE=(%f, %f)",resetPosition.position.x,resetPosition.position.y);
[self.parent runAction:[CCMoveTo actionWithDuration:(-(-300-self.parent.position.y)/650)
position:ccp(self.parent.position.x,(-self.position.y))]];
//Working
[resetPosition runAction:[CCMoveTo actionWithDuration:(-(-300-self.parent.position.y)/650)
position:ccp(resetPosition.position.x, 280-(-self.position.y))]];
//CCLOG(@"self.parent.position AFTER MOVE=(%f, %f)",self.parent.position.x,self.parent.position.y);
//CCLOG(@"resetPosition.position BEFORE MOVE=(%f, %f)",resetPosition.position.x,resetPosition.position.y);
}
else
{
//CCLOG(@"yScrlFlag");
yScrlFlag=0;
[self.parent runAction:[CCMoveTo actionWithDuration:(-(-300-self.parent.position.y)/950)
position:ccp(self.parent.position.x,0)]];
[resetPosition runAction:[CCMoveTo actionWithDuration:round(-(-300-self.parent.position.y)/949)
position:ccp(resetPosition.position.x,280)]];
}
}
What I want is all time smoothness in the movement of scene. As the code shows, it moves the scene in both horizontal and vertical direction. And the basic problem occurs when one (any) sprite in the scene is mobilized, and the scene starts scrolling. It behaves in a jerky way in that case too (possibly more so than in the normal case). Any suggestions?
Try CCFollow instead of doing everything manually:
CCFollow