初始化UI的代码如下,运行程序后 ,按钮不能被点击,完全不能接受到触摸事件。
设置setTouchEnabled(true) 也无效果,交互属性也都勾上了
Widget* root = static_cast<Widget*>(GUIReader::shareReader()->widgetFromJsonFile("MyDemoShop_1/MyDemoShop_1.json"));
this->addChild(root);
初始化UI的代码如下,运行程序后 ,按钮不能被点击,完全不能接受到触摸事件。
设置setTouchEnabled(true) 也无效果,交互属性也都勾上了
Widget* root = static_cast<Widget*>(GUIReader::shareReader()->widgetFromJsonFile("MyDemoShop_1/MyDemoShop_1.json"));
this->addChild(root);
你好,请把事件添加方法贴上来。
单独添加Widget貌似不行,需要创建一个UILayer后addWidget到UILayer,然后当前layer添加UILayer,为什么一定要创建一个UILayer???这是一个什么机制呢?版主解答解答
UILayer* ul =UILayer::create();
Layout* layout = static_cast<Layout*>(GUIReader::shareReader()->
widgetFromJsonFile("NewUI/NewUI_1.ExportJson"));
ul->addWidget(layout);
this->addChild(ul,1);
uilayer还有个别名叫做touchgroup,这个层是cocostudio用于分配事件的。