Quantcast
Channel: Cocos Forums - Latest topics
Viewing all articles
Browse latest Browse all 17083

TouchEventListener on button not working

$
0
0

@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

Read full topic


Viewing all articles
Browse latest Browse all 17083

Trending Articles