2013-12-16 43 views
0

我正在Cocos2d和xcode中創建側​​滾動遊戲。側滾動遊戲背景

我有一個編碼的問題,用於爲levelscene添加背景。 我試圖實現一個視差背景無濟於事,所以選擇只是有一個背景玩家將滾動。

但是此刻背景隨着玩家穿過屏幕,坦率地看起來很垃圾。

我的代碼是

(void)setupParallax { 

NSString *backgroundName = [self.tilemap propertyNamed:@"BackgroundImage"]; 

CCSprite *background = [CCSprite spriteWithFile:[AssetHelper getDeviceSpecificFileNameFor:[NSString stringWithFormat:@"background-noon.png]]]; 
background.anchorPoint = ccp(0,0); 
background.position = CGPointMake(0, 0); 

[self addChild:background z:0]; 
} 

我知道它必須是一些與位置或anchorPoint但是這些值僅參照它們加載屏幕改變。

回答