Cocos2dx - 3.16 seem buggy? Anyone else?

Hi All,

I’ve seen a few issues using version 3.16 - I used to use this code to create a physics seen now it seems to duplicate layers & sprites and not work with follow action.

auto scene = Scene::createWithPhysics();
scene->getPhysicsWorld()->setDebugDrawMask( PhysicsWorld::DEBUGDRAW_ALL );

// 'layer' is an autorelease object
auto layer = cchMain::create();
layer->SetPhysicsWorld( scene->getPhysicsWorld() );

// add layer as a child to scene
scene->addChild(layer);

// return the scene
return scene;

I found this post (Cocos2dx - Chipmunk c++) and used code added debug drawall to follow sprite and now when it hits a certain point the debug mask now goes off screen???

I dont think I’ve ever had any issues using previous versions but this totally flakey… thinking about going down a version or two. Anyone else with similar experiences?

@minggo what do you think? Should I run through cpp-tests and see how things are behaving?

Thanks for looking into it slackmoehrle. I have just tested this on version 3.14 exactly same config with IOS 10.3.1 everything is working fine follow action with physics & debug draw??

Has version 3.16 gone through a rehaul… the only differences I am seeing is the way physics scenes are getting set up and possible layering issues.

Version 3.14

HelloWorld.h

class HelloWorld : public cocos2d::Layer
{
public:
    
    static cocos2d::Scene* createScene();
    //virtual void onEnter();
    virtual bool init();
    
    // implement the "static create()" method manually
    CREATE_FUNC(HelloWorld);
    
private:
    Sprite *cocoTooth;
    // Setting up PhysicsWorld
    cocos2d::PhysicsWorld *sceneWorld;
    void SetPhysicsWorld( cocos2d::PhysicsWorld *world ) { sceneWorld = world; };
    // Physics contact
}

HelloWorld.cpp
Scene* HelloWorld::createScene()
{
    // 'scene' is an autorelease object
    auto scene = Scene::createWithPhysics();
    scene->getPhysicsWorld()->setDebugDrawMask(PhysicsWorld::DEBUGDRAW_ALL);
    // 'layer' is an autorelease object
    auto layer = HelloWorld::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 HelloWorld::init()
{
    //////////////////////////////
    // 1. super init first
    if ( !Layer::init() )
    {
        return false;
   }
}

Version 3.16 -

HelloWorld.h
class HellloWorld : public cocos2d::Scene
{
public:
    
    static cocos2d::Scene* createScene();
   // virtual void onEnter();
    virtual bool init();

    // implement the "static create()" method manually
    CREATE_FUNC(HelloWorld);
  
private:
    Sprite *cocoTooth;
    // Setting up PhysicsWorld
    cocos2d::PhysicsWorld *sceneWorld;
    void SetPhysicsWorld( cocos2d::PhysicsWorld *world ) { sceneWorld = world; };
}

HelloWorld.cpp
Scene* HelloWorld::createScene()
{
    auto scene = Scene::createWithPhysics();
    auto layer = HelloWorld::create();
    scene->addChild(layer);
    scene->getPhysicsWorld()->setDebugDrawMask(PhysicsWorld::DEBUGDRAW_ALL);
    return scene;
 
}

// Print useful error message instead of segfaulting when files are not there.
static void problemLoading(const char* filename)
{
    printf("Error while loading: %s\n", filename);
    printf("Depending on how you compiled you might have to add 'Resources/' in front of filenames in HelloWorldScene.cpp\n");
}

// on "init" you need to initialize your instance
bool HelloWorld::init()
{
    //////////////////////////////
    // 1. super init first
    if ( !Scene::initWithPhysics() )
    {
        return false;
    }
 }

Maybe I am not using scene right in the headers for physics or scene creation. Is there any new documentation for 3.16… for the way it works and this new fundamental change?

Thanks for the effort. Yes, new docs for v3.16 but the content is still being added. You will see the new docs in a day or 2.

@zhangxm What do you think?

I don’t remember there is any code changed related with it. @chint can i just use your code to reproduce it?

Thanks both for the help - @zhangxm I have messaged you with the files.

@slackmoehrle @zhangxm any updates on this one?

Sorry, i don’t have time to take a look. And i am not familiar with physics, so it make take me more time on it.

Just need to leave a comment on an issue I saw but this post fixed. When transitioning scenes to a scene with physics, it would not load the scene. Just a black screen. I was doing this:

cocos2d::Scene *FrogScene::createScene() { 
     return FrogScene::createWithPhysics();

FrogScene inherited from cocos2d::Scene. Thanks to @chint I see you got to do it this way to make it load properly:

cocos2d::Scene *FrogScene::createScene() { 
    auto scene =  Scene::createWithPhysics();
    auto layer = FrogScene::create();
    scene->addChild(layer);
    return scene;
} 

Did I just miss the documentation on this or should this be added?
Thanks guys!

@nite @slackmoehrle

cocos2d-x 3.16 is totally messed up;/ we don’t have time to investigate issues so we not using it anymore - but it is just crashing on Android and IOS. Someone should do something about it.

This really doesn’t help us at all. Messed up how?

Like we getting some mystic crashes on IOS, now after trying to run Android app crashing:

Fatal Exception: java.lang.UnsatisfiedLinkError
dlopen failed: cannot locate symbol “rand” referenced by “libMyGame.so”…
java.lang.Runtime.loadLibrary (Runtime.java:365)
java.lang.System.loadLibrary (System.java:526)
org.cocos2dx.lib.Cocos2dxActivity.onLoadNativeLibraries (Cocos2dxActivity.java:100)
org.cocos2dx.lib.Cocos2dxActivity.onCreate (Cocos2dxActivity.java:126)
org.cocos2dx.cpp.AppActivity.onCreate (AppActivity.java:219)
android.app.Activity.performCreate (Activity.java:5389)
dalvik.system.NativeStart.main (NativeStart.java)

And some other mystic crashes in OnCreate method.

ok. Thanks for updating.

Which std lib are did you use while building it?

If we talking about Android:

LOCAL_WHOLE_STATIC_LIBRARIES := PluginSdkboxPlay
sdkbox
PluginGoogleAnalytics
PluginIAP

LOCAL_STATIC_LIBRARIES := cocos2dx_static