我想从左向右连续移动背景图片。我从
infinite-background picture

但是在这种情况下背景图像是从右向左移动,但我想从左向右。我试图在上面的代码中进行更改,但这对我不起作用。
谁能告诉我该怎么做?

最佳答案

您应该可以将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;

}

10-08 01:03