@xxYxx wrote:
The following code for my button compiles but it does not register when I touch the button.
.h file
void touchEvent(cocos2d::Ref *pSender, cocos2d::ui::Widget::TouchEventType type);
.cpp init
auto button = cocos2d::ui::Button::create("button1.png", "button2.png"); button->addTouchEventListener(CC_CALLBACK_2(HelloWorld::touchEvent, this)); this->addChild(button);
.cpp touchEvent
void HelloWorld::touchEvent(cocos2d::Ref *pSender, cocos2d::ui::Widget::TouchEventType type) { cocos2d::log("pressed"); }
Any help would be appreciated.
Posts: 4
Participants: 2