Collision Detection

Currently on click of a button the object hides and shows but I want to move the text object with collision detection... can anyone pls help me out
[code]
#include <MultiWidgets/Application.hpp>
#include <MultiWidgets/TextWidget.hpp>
#include <MultiWidgets/StayInsideParentOperator.hpp>
int main(int argc, char ** argv)
{
MultiWidgets::Application app;

if(!app.init(argc, argv))
return 1;
/// [Load CSS-file containg texts and effects]
app.addStyleFilename("rendering.css");
/// [Load CSS-file containg texts and effects]
/// [Read css file containing images]
app.addStyleFilename("button-example.css");
/// [Read css file containing images]

/// [Create Button Widget]
auto button = MultiWidgets::create<MultiWidgets::Widget>();
//load CSS class containing attributes
button->addCSSClass("Button");
button->setInputFlags(MultiWidgets::Widget::INPUT_SINGLE_TAPS | MultiWidgets::Widget::INPUT_KEEP_GRABS);
/// [Create Button Widget]

button->setLocation(Nimble::Vector2f(100, 100));
app.mainLayer()->addChild(button);
auto plainText = MultiWidgets::create<MultiWidgets::TextWidget>();
plainText->setLocation(Nimble::Vector2f(550, 300));
app.mainLayer()->addChild(plainText);
/// [Add operator]
plainText->addOperator(std::make_shared<MultiWidgets::StayInsideParentOperator>());
/// [Add operator]
/// [Add Button Listener]
button->eventAddListener("single-tap", [&] {
if(plainText->isDisplayed()) plainText->hide();
else plainText->show();
});
/// [Add Button Listener]

return app.run();

}
Topic archived. No new replies allowed.