Hi, I was using AndEngine (Java) and switched to Cocos2d-x and I loved it but I’m not too familiar with C++. So I don’t know this:
Can I have a “Button” subclass of Sprite class, I want to use this class to create button objects easily, for example look at this code:
public Button extends Sprite(String buttonText, int x, int y, Function touchFunction)
{
...
Create sprite with "button.png" image,
Attach buttonText Text object on top of the image,
Set its position at (x,y),
Set callback function which will be called when the button is touched.
...
}
Can I create a class like this and use it for all my buttons, for example like this:
Button button1 = new Button("New Game", 100, 100, startGame());
Button button2 = new Button("Options", 200, 200, openOptions());
Hope you understand me, I just want to customize the Sprite class to make it like a button…