Search code examples
androidcocos2d-android

Cocos2D Android How to have a scene object?


I can get the scene from a layer, but I don't know how to have a Scene that manages layers. I can do this on iPhone, but on Android my code doesn't even get called.

This is in my start Activity:

CCDirector.sharedDirector().runWithScene(EditorScene.node());

This is my scene class:

public class EditorScene extends CCScene
{


public EditorScene()
{

    CanvasBackgroundLayer canvasBackgroundLayer = (CanvasBackgroundLayer) CanvasBackgroundLayer.node();
    CanvasEditorLayer canvasEditorLayer = (CanvasEditorLayer) CanvasEditorLayer.node();

    addChild(canvasBackgroundLayer,0);
    this.addChild(canvasEditorLayer);

}
}

My constructor here is never called. Any ideas on what to do?


Solution

  • Any subclasses of CCScene have to reimplement the static method node(). Have a look at the bottom of CCScene.h.