[ccbi] cocos2d-x 3.0rc0, registerScriptTouchHandler raises error : ASSERT FAILED ON LUA EXECUTE: this dictionary does not use string as key

I load a layer from CocoaBuilder file by CCBReaderLoad.
Then, I called the registerScriptTouchHandler as:

    layer:registerScriptTouchHandler(onTouch, true)
    layer:setTouchEnabled(true)

Then, I got the error: ASSERT FAILED ON LUA EXECUTE: this dictionary does not use string as key.

I step by step the code, I found the error caused by:

    auto dict = static_cast<__Dictionary*>(self->getUserObject());
    auto touchModeValue = static_cast<__Integer*>(dict->objectForKey("touchMode"));

The dict is cocosbuilder::CCBAnimationManager. Then dict->objectForKey(“touchMode” ) raised the error.

How to fix it?

screenshot


8EC1C9F5-392B-4BDF-A6FD-8CB9FC29D1CE.png (416.4 KB)

The 3.0rc already used new eventdispatcher to dispatch the touch event,you can refer to testlua\NewEventdispatcehrTest.The error would be caused by the compatibility,I will check it.

I would like to see this bug be corrected asap.

This bug was triggered by the mechanism of setUserObejct Because the change of the Layer is very big in version 3.0, it is hard to be totally compatible.Why don’t you use the new EventDispatcher?

@samuele3hu
I use EventDispatcher to instead of. It works. But it causes some minor bugs.

Is there any possible to change CCBReader to make it compatible with registerScriptTouchHandler?

1.I think it must modify the cpp code.
Use other mechanism instead of setUserObject,such as global map?
or Add priority member var in the Layer,so touchMode,swallowToucher and priority all are saved in Layer,it also needs to modify some implements of Layer

2.EventDispatcher would cause some minor bugs,can you tell the details?

Concerning the minor bug of EventDispatcher, it is caused by implementation of our game logic.