这是我的滚动背景代码:
for (int i = 0; i < 2; i++) {
bg1 = [SKSpriteNode spriteNodeWithImageNamed:@"nightbackground"];
bg1.anchorPoint = CGPointZero;
bg1.position = CGPointMake(0, 0);
[bg1 setScale:0.5];
[self addChild:bg1];
bg2 = [SKSpriteNode spriteNodeWithImageNamed:@"nightbackground"];
bg2.anchorPoint = CGPointZero;
bg2.position = CGPointMake(bg1.size.width-1, 0);
[bg2 setScale:0.5];
[self addChild:bg2];
}
现在,当新的重复图像进入时,您可以看到新图像的开始位置,有一条白线。他们是一种摆脱它或重叠两者的方式,所以你没有看到它的开始?
答案 0 :(得分:0)
for (int i = 0; i < 2; i++) {
_bg =
[SKSpriteNode spriteNodeWithImageNamed:@"nightbackground"];
_bg.anchorPoint = CGPointMake(0.5, 0.5);
_bg.position = CGPointMake(i * _ground.size.width, 0);
_bg.name = @"bg";
_bg.zPosition = 10;
[self addChild:_bg];
}
我会尝试这个解决方案,你将锚点作为精灵的中间部分,然后使用for-loop-value将它们放置出去。您只需要一个 addchild