Button

What is it ?

Button is made to detect a click with interface on your screen. And with this click you can do some actions like icrement value or active / disactive or load a scene.

How create it ?

You have to add Button component in a GameObject. All component require will be added by the Button.

Example :

auto buttonObject = scene.createScene("My Button");

auto button = std::make_shared<KapEngine::UI::Button>(buttonObject, "Button Text");
buttonObject->addComponent(button);

Functions

  • setText : set the button text

  • setTextPosition : set the position of text inside the button

  • setTextColor : set the text color

  • setBackground : set an image in background of button

Example :

auto buttonObject = scene.createScene("My Button");

auto button = std::make_shared<KapEngine::UI::Button>(buttonObject, "Button Text");
buttonObject->addComponent(button);

//call all available functions
button->setText("Other text");
button->setTextPosition({10, 10});
button->setTextColor(KapEngine::Color::Red());
button->setBackground("path/image.pnng", {0, 0, 100, 100});

Last updated