2013-03-24 69 views
1

我有一個遊戲引擎寫在我的團隊中,它是基於組件的。它具有邏輯組件和可視化組件。在可視組件中有一個名爲updateVisual(delta)的函數,並且在那裏繪製所有內容。在cocos2d-x中渲染循環

例如,讓我們物理球實體世界:

class LogicBallComponent 
{ 
    // ... 
}; 

class VisualBallcomponent 
{ 
    sfml::Texture mBallTexture; 

    void updateVisual(float) 
    { 
     mBallTexture.translate(...); 
     GlobalDisplayManager::instance().draw(mBallTexture); 
    } 
}; 

GlobalDisplayManager回報它創建GL-狀態等(SF :: RenderWindow的在SFML)一些窗口表示。這個系統很容易整合。

現在我需要使用我的引擎製作Android遊戲。我選擇了cocos2d-X用於窗口創建,渲染,字體,資源等

還有另一種方式來完成這項工作:

class Ball : public CLayer 
{ 
    bool Ball::init() { 
     CSprite* sprite = CSprite::create(...); 
     this->addChild(sprite, 0); // [!] 
    } 
}; 

而且我不知道如何使用它以我的方式。有這種可能嗎?

回答

0

你應該檢查一下函數「void CCDisplayLinkDirector :: mainLoop(void)」,它是coco2d-x渲染引擎的主循環。

coco2d-x爲定期調用循環提供包裝。在iOS中,您應該檢查platform/ios中CCDirectorCaller.mm的startMainLoop函數。