2020-08-04 13:15:02 +08:00
|
|
|
#include "JoystickScene.h"
|
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
USING_NS_AX;
|
2020-08-04 13:15:02 +08:00
|
|
|
|
|
|
|
JoystickScene::~JoystickScene()
|
|
|
|
{
|
2022-07-16 10:43:05 +08:00
|
|
|
AX_SAFE_RELEASE(_joystick);
|
2020-08-04 13:15:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
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("");
|
|
|
|
});
|
|
|
|
}
|