当我在 Cocos2d 2.0 中沿屏幕滚动图像时,我无法无限期地重复图像......我正在使用 ccTexParams 方法,如下所示:
_movingHills = [CCSprite spriteWithFile:@"MenuBackHills.png"];
_movingHills.position = backGround.position;
[self addChild:_movingHills z:1];
//make sure hills repeat!
ccTexParams repeatHills = {GL_LINEAR, GL_LINEAR, GL_REPEAT, GL_CLAMP_TO_EDGE};
[_movingHills.texture setTexParameters:&repeatHills];
然后更新:
float PIXELS_PER_SECOND = 1;
static float offset = 0;
offset += PIXELS_PER_SECOND * dt;
CGSize textureSize = _movingHills.textureRect.size;
[_movingHills setTextureRect:CGRectMake(offset, 0, textureSize.width, textureSize.height)];
然而,所有这一切都导致我的场景中添加了一个漆黑的屏幕:/