axmol/tests/fairygui-tests/Classes/JoystickScene.cpp

29 lines
676 B
C++
Raw Normal View History

2020-08-04 13:15:02 +08:00
#include "JoystickScene.h"
USING_NS_AX;
2020-08-04 13:15:02 +08:00
JoystickScene::~JoystickScene()
{
CC_SAFE_RELEASE(_joystick);
}
void JoystickScene::continueInit()
{
UIPackage::addPackage("UI/Joystick");
_view = UIPackage::createObject("Joystick", "Main")->as<GComponent>();
_groot->addChild(_view);
_joystick = JoystickModule::create(_view);
_joystick->retain();
GObject* tf = _view->getChild("n9");
_joystick->addEventListener(JoystickModule::MOVE, [tf](EventContext*context) {
tf->setText(context->getDataValue().asString());
});
_joystick->addEventListener(JoystickModule::END, [tf](EventContext*context) {
tf->setText("");
});
}