2012-09-18 51 views
1

我正在開發汽車遊戲,我想以縱向模式移動背景圖像(圖像大小爲320×1024),爲此我不想使用CCParallaxNode來移動背景圖像,甚至沒有TiledMap.Is還有其他方式可以在縱向模式下移動背景。在Cocos2d中,如何移動背景精靈圖片?

2分鐘後,我想提高背景精靈的速度,任何人都可以幫助我如何做到這一點。

在此先感謝。

+0

你的意思是,你要滾動你的背景下病房..? 像無限滾動回地面..? – Shailesh

+1

每更新一次更改精靈的位置屬性?使用CCMoveTo操作? – LearnCocos2D

回答

1

只需在預定更新方法上設置背景精靈的位置即可。

-(void) anUpdate:(ccTime)dt { 

    bgSprite.position = ccp(<new x coordinate>, <new y coordinate>); 
1

在更新方式的位置您bgImage:

-(void) update:(ccTime)dt{ 
    total_time_ += dt; 
    if(total_time_> 2*60) 
     speed_ *=2; 
    bgSprite.position = ccp(bgSprite.position.x, bgSprite.position.y+speed_*dt); 
}