.cpp
layout->setBackGroundImageScale9Enabled(true);
layout->setBackGroundImage("green_edit.png"); layout->setPosition(Point(0,0));
addChild(layout); alert = Text::create("Layout", "fonts/Marker Felt.ttf", 30 );
alert->setColor(Color3B(159, 168, 176));
alert->setPosition(Point(widgetSize.width / 2.0f,
widgetSize.height / 2.0f - alert->getSize().height * 3.075f)); layout->addChild(alert);
auto size = Director::getInstance()->getWinSize(); /**************************************************************/ auto sprite = Sprite::create("btn-about-normal-vertical.png");
sprite->setRotation(5);
sprite->setPosition(Point(size.width/2,size.height/3));
sprite->setScale(2);
layout-> addChild(sprite); auto sprite2 = Sprite::create("btn-about-normal-vertical.png");
sprite2->setRotation(-85);
sprite2->setPosition(Point(size.width/2,size.height * 2/3));
sprite2->setScale(2);
layout->addChild(sprite2); auto listener = EventListenerTouchOneByOne::create();
listener->setSwallowTouches(true); listener->onTouchBegan = [=](Touch* touch, Event *event) {
auto pos = touch->getLocation();
_lastPos = pos; return true; }; listener->onTouchMoved = [=](Touch* touch, Event *event) {
auto pos = touch->getLocation();
auto offset = pos - _lastPos;
auto layerPos = getPosition();
auto newPos = layerPos + offset;
layout->setPosition(newPos);
_lastPos = pos; }; _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);