1、在.h中加入头文件
#include "extensions/cocos-ext.h"
USING_NS_CC;
USING_NS_CC_EXT;
添加方法:
void touchUpInside(Ref* pSender,Control::EventType event);
2、在实现文件之中:
添加控件的实现:
auto btn1=Scale9Sprite::create("stone.png");
auto btn=ControlButton::create(btn1);
btn->setPosition(Vec2(400,300));
this->addChild(btn,1);
btn->addTargetWithActionForControlEvents(this,cccontrol_selector(StartScene::touchUpInside),Control::EventType::TOUCH_UP_INSIDE);
添加点击的事件:
void StartScene::touchUpInside(Ref* pSender,Control::EventType event)
{
log("touchUpInside");
}