Cocos2d-x v3.10 + Cocos Studio v3.10
My Code
bool OptionLayer::init() {
if (!Layer::init()) {
return false;
}
_layer = dynamic_cast<Layer*>(CSLoader::createNode("OptionLayer.csb"));
Size size = Director::getInstance()->getVisibleSize();
_layer->setContentSize(size);
_layer->setAnchorPoint(Vec2::ANCHOR_MIDDLE);
_layer->setPosition(size/2);
ui::Helper::doLayout(_layer);
this->addChild(_layer);
// touch event
auto panel = dynamic_cast<ui::Layout*>(UtilsExtra::findChildrenFront(*_layer, "Panel"));
auto listener = EventListenerTouchOneByOne::create();
listener->setSwallowTouches(true);
listener->onTouchBegan = CC_CALLBACK_2(OptionLayer::onTouchBegan, this);
listener->onTouchEnded = CC_CALLBACK_2(OptionLayer::onTouchEnded, this);
listener->onTouchMoved = CC_CALLBACK_2(OptionLayer::onTouchMoved, this);
listener->onTouchCancelled = CC_CALLBACK_2(OptionLayer::onTouchCancelled, this);
panel->getEventDispatcher()->addEventListenerWithSceneGraphPriority(listener, panel);
panel->setTouchEnabled(true);
CCLOG("panel : %d %d", panel->isTouchEnabled(), panel->isEnabled());
return true;
}
iOS: Working.
Android: Not Working.
My Projects There are a lot Button.
Working, reduce the ui::Button in Cocos Studio. (reduce object touchble)
Why???
thank you.