This GlistEngine plugin draws a blue button on the screen with the given coordinates. The button sends the clicks to a callback function for further processes.
Fork & clone this project into ~/dev/glist/glistplugins
- Add gipButton into plugins of your GlistApp/CMakeLists.txt
set(PLUGINS gipButton)
- Include gipButton.h in GameCanvas.h
#include "gipButton.h"
- Create a callback function
void GameCanvas::buttonClicked(int buttonId);
- Define gipButton object
gipButton button;
- Set callback and position
void GameCanvas::setup() { button.setClickCallback(std::bind(&GameCanvas::buttonClicked, this, std::placeholders::_1)); button.setPosition(100, 100); }
- Draw
void GameCanvas::draw() { button.draw(); }
- Listen and process the clicks in your callback function
Apache 2