Hello, I made a test run of adding my csb scenes into android studio. My environment is
Cocos2dx-3.15
Android Studio 2.3.1
So after adding my test scene i added the rest of my code and ran the build, i use my lg g4 as a physical emulator and when i run the app it does not even open and crashes instantly. I checked logcat and this is what it tells me is the problem.
04-28 18:19:41.143 14161-14307/org.cocos2dx.cpp D/cocos2d-x debug info: Assert failed: Argument must be non-nil.
04-28 18:19:41.143 14161-14307/org.cocos2dx.cpp E/cocos2d-x assert: C:/Users/Genesis/Desktop/ManaDiceX/cocos2d/cocos/./2d/CCNode.cpp function:addChild line:1003.
04-28 18:19:41.144 14161-14307/org.cocos2dx.cpp A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x0 in tid 14307 (GLThread 23985).
if it helps, here is my cpp file
#include “MMScene.h”
#include “…/cocos2d/cocos/2d/CCNode.h”
Scene* MMScene::createScene()
{
// ‘scene’ is an autorelease object
auto scene = Scene::create();
// ‘layer’ is an autorelease object
auto layer = MMScene::create();
// add layer as a child to scene
scene->addChild(layer);
// return the scene
return scene;
}
// on “init” you need to initialize your instance
bool MMScene::init() {
//////////////////////////////
// 1. super init first
if (!Scene::init()) {
auto rootNode = CSLoader::createNode(“MMScene.csb”);
this->addChild(rootNode);
auto MMAbilitiesButton = rootNode->getChildByName<ui::Button *>("btnBack"); //find button
MMAbilitiesButton->retain();
MMAbilitiesButton->addTouchEventListener(
[&](Ref *ref, ui::Widget::TouchEventType touchEventType) {
if (touchEventType != ui::Widget::TouchEventType::ENDED) return;
//button clicked
});
return false;
}
}