About ccClass Release Mode

In Cocos2d-html5 2.1, we improved the performance of John Resig's javascript inheritance with "release mode"

John Resig's Javascript inheritance (extend) is used throughout the game engine. It is blazing fast and easy to use already.

But in order to mimic C style OOP pattern, there need to be a way to access parent version of a function. this._super() achieves this, but with some sacrifice in performance.

What we did is rewrite the functions that uses this._super() at run time to directly points to the parent's function. think it as a mini JIT compiler!

The result is at least 10% increase in performance, the down side is that it is now impossible to set break point inside functions that has this._super(), as that function was rewritten in run time!

So we added a flag that you can toggle this optimization on and off.

We call it release mode as it is recommended for release build only.

to turn it on, simply add the "CLASS_RELEASE_MODE:true" config to cocos2d.js

CLASS-RELEASE-MODE.png (30.5 kB) Hao Wu, 2012-12-05 02:41