1
votes

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
You can only extend a single class in Java; that's just how the language is.Dave Newton
android is java. cannot extend two classes.Bineesh
If you provide some code someone might be able to offer some alternatives.George Baker
sir @GeorgeBaker please check out the update. I already post my codes. thanksuser3691945

1 Answers

1
votes

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