mirror of https://github.com/axmolengine/axmol.git
29 lines
676 B
C++
29 lines
676 B
C++
#include "JoystickScene.h"
|
|
|
|
USING_NS_AX;
|
|
|
|
JoystickScene::~JoystickScene()
|
|
{
|
|
AX_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("");
|
|
});
|
|
} |