Hi, I’m new at Cocos2D-X but I’ve made some games before. I’ve always had Update() and Render() functions (update usually had a float for time) that were called every frame for each object shown (and/or not shown).
I was wondering where are these in the files such as CCSprite and the like? Or how would I go about knowing when it should update and what it should render?
All new to this, so any information would be appreciative! Thanks!
Rendering sprites is not your work, just add it to CCLayer with addChild() and engine would render it for you
If you want render something directly, CCLayer have method draw(), overload it
If you examine wikipage, that i refer before, you can find answer about update too
introduce member void update(ccTime dt) of course
and call somewhere in layer init func schedule( schedule_selector(YourLayer::update));
You don’t need to call update & render in your game logic. They are done in engine internal.
The message loop is wrapped in CCEGLView or CCApplication, depends on different platforms. You can read the source from these 2 class, and find the answer easily.