2014-02-23 80 views
-1

這是我的一個滾動背景代碼:如何停止sprite kit Xcode背景邊緣上的白線?

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
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來放置它們。你只需要一個加號