As the first thing to do, what about creating a
JSComponent, or perhaps a
ScriptComponent (instead of the Physics2d component) and that component will send all the events to Lua/JS.
Instead of hardcoding the JS/Lua callbacks in Node, just move it a component.
We should have the
onExit a few more.
And the idea is to see if we can create a game in Lua / JS using it as component.
Benefit of Lua/JS as component:
The interface is cleaner. Right now, when you subclass an Sprite in JS, you are not really subclassing it... you can only override certain methods, not all of them.
But creating the component, it is cleaner which messages you can receive.
Also, it will be cleaner from a GUI point of view... you just right click on an Node and say "attach script / callback"... in that sense is cleaner.
if could break compatibility... if so, we can't do it for v3.x but it is a good starting point.
BTW, the Cocos Studio guys should be involved in this discussion since having that feature in the GUI is a must. Could you ask them to join this thread? thanks.