Custom UI - Popups, Buttons

I’ve made a few helpful classes for ui that i’d like to share e.g. ( Custom Buttons, Popups, D-pad etc)

Custom Buttons :
A cocos2d-x class that allows you to create cool animated buttons.

Usage:

UICustom::CustomButton *cb = UICustom::CustomButton::create(UICustom::CUSTOM_BUTTON_IMAGES::SQUARE, UICustom::COLOR::GREEN, nullptr, [=](Ref *sender){
    
    log("Button pressed");
});
this->addChild(cb);

Popup:
A cocos2d-x class that allows you to create Popups for Messages and confimation.
This class swallows all touch events until the popup is closed.
Popup can be closed by tapping outside the bg or pressing the cancel button.
Pressing ok button will fire an event.

Alt Text

Usage:

//Confimation:

UICustom::Popup *popup = UICustom::Popup::createAsConfirmDialogue("Test 1", "This is a confirmation Popup", [=](){
 log("Ok is pressed");
});
this->addChild(popup);



//Message:

UICustom::Popup *popup = UICustom::Popup::createAsMessage("Test 2", "This is a Message Popup");
this->addChild(popup);





//Creating with Label 

Label *lbl = Label::createWithTTF("This Popup is created with a label and its properties the width of the label is 300px.","fonts/Dimbo Regular.ttf" , 40);
lbl->setWidth(300);
UICustom::Popup *popup = UICustom::Popup::create("Test 3", "", lbl, [= ](){

});
this->addChild(popup);

To create your own popup inherit from class PopupDelegate


make sure you follow I’ll be adding more modules soon.

Thanks. I hope you like them.

8 Likes

I think it’s very helpful !Thanks you very much !

1 Like

The buttons and popups in action:

2 Likes

Wow… !Nice game!

1 Like