当场景移动时,它会以荒谬和生涩的方式移动(有时并不总是),从而导致刺激。以下代码用于移动场景:
//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)]];
}
}
我想要的是场景运动中的所有时间平滑。如代码所示,它在水平和垂直方向上移动场景。并且当场景中的一个(任何)sprite
被动员并且场景开始滚动时,会出现基本问题。在这种情况下它也会以一种不稳定的方式运行(可能比正常情况下更多)。有什么建议吗?