下面的代码有能力从向上到向下的方向或其他方式进行无休止的背景旋转。
我只想与这个旋转相反。我试过但可以解决这个问题。
有人建议我,如何做到这一点?
private void animateBackground() {
_oddBackground = CCSprite.sprite("sky.png");
_evenBackground = CCSprite.sprite("sky.png");
/*from Upward to Downward direction background rotation */
_oddBackground.setPosition(winSize.width / 2, winSize.height / 2);
_evenBackground.setPosition(winSize.width / 2, winSize.height + (winSize.height / 2));
schedule("scroll");
addChild(_oddBackground).addChild(_evenBackground);
}
public void scroll(float dt) {
// move them 100*dt pixels down
_oddBackground.setPosition(_oddBackground.getPosition().x, _oddBackground.getPosition().y - 100 * dt);
_evenBackground.setPosition(_evenBackground.getPosition().x, _evenBackground.getPosition().y - 100 * dt);
// reset position when they are off from view.
if (_oddBackground.getPosition().y < - winSize.height / 2) {
_oddBackground.setPosition(winSize.width / 2, winSize.height / 2);
_evenBackground.setPosition(winSize.width / 2, winSize.height+ (winSize.height / 2));
}
}