Cocos2d: Activity class & CCLayer class

388 Views Asked by At

Im building a game using eclipse and now I wanted to use Cocos2d engine. My problem is I want to merge my done program and sliding menu of cocos2d engine. And now my question is how can I extend my Menu Class to Activity class so I can call onCreate and setContentView for my XML and to extend also to CCLayer Class to make my Menu Class connected on my Sliding Menu of Cocos2d.

thanks for any suggestions and help. And please apologize my question.

UPDATE: heres the code

public class Menu extends Activity implements OnClickListener{
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        .... //some codes here
    }
    @Override
    public void onClick(View view) {
        // some codes here.
    }
}

and here's the method that I wanted to use from CCLayer but it needs to extend it from that class.

public static CCScene scene()
{
    CCScene scene = CCScene.node();
    CCLayer layer = new Menu();
    scene.addChild(layer);
    return scene;
}
1

There are 1 best solutions below

8
On

Can't extend 2 classes in Java. But you could use interfaces, or the observer / listener pattern.