我想从左到右连续移动背景图片。我得到了一个参考 infinite-background picture
但是在这里,背景图像从右向左移动,但我想从左到右。我试图在上面的代码中进行更改,但这对我不起作用.. 谁能告诉我怎么做?
答案 0 :(得分:3)
你应该能够改变 - 到+为x并反转if条件......
试试这个:
-(void)scrollBackground:(ccTime)dt
{
CGSize s = [[CCDirector sharedDirector] winSize];
CGPoint pos1 = mBG1.position;
CGPoint pos2 = mBG2.position;
pos1.x += MM_BG_SPEED_DUR;
pos2.x += MM_BG_SPEED_DUR;
if(pos1.x >= (s.width*0.5f) )
{
pos1.x = pos2.x - s.width;
}
if(pos2.x >= (s.width*0.5f) )
{
pos2.x = pos1.x - s.width;
}
mBG1.position = pos1;
mBG2.position = pos2;
}