Here is a short list of things we had to patch onto the Cocos2D implementation
on the HTML5 side:
-----
The IOS/Android code inheritates BoardLayer from cc.Layer, which will crash
under HTML5:
- Uncaught TypeError: Object [object Object] has no method 'setOpacity'
(CCActionInterval.js:1505)
In the cpp version this will work due they have a dynamic cast check which
prevents the crash (CCActionIntervval.cpp: 1781)
void CCFadeIn::update(float time)
{
CCRGBAProtocol *pRGBAProtocol = dynamic_cast<CCRGBAProtocol*>(m_pTarget);
if (pRGBAProtocol) { pRGBAProtocol->setOpacity((GLubyte)(255 * time)); }
}
-----
Missing functions in HTML5 can primary be found in our "Main.js"
https://github-ca.corp.zynga.com/stg-js/xwf/blob/master/Web/source/class/Main.js
- cc.SpriteFrame does not provide a "retain(void)" function.
- BoardLayer does not provide a "setMouseEnabled(void)" function
- BoardLayer does not provide a "setTouchEnabled(void)" function
- cc.Director does not provide a "enableRetinaDisplay(boolean)" function
- cc.Application does not provide a "applicationDidFinishLaunching(void)"
function even if it is called from the "cc.Application.run()" inside the
cocos2d-html5 code
- there is no global "__getPlatform(void)" function
- there is no global "__associateObjWithNative(scope, parent)" function
- there is no global "log(msg)" function, in JS it's "console.log(msg)", which
we have to patch onto the window object
-----
The CCTextureCache does return an native HTML5 image while it returns a
CCTexture2D on cpp side.
There seems to be a CCTexture2D on HTML5 port but this one seems not to be
implemented or used.
The native image does not have functions like image.getPixelWide(void) or
texture.getPixelHigh(void)
-----
For a colored CCSprite with a attached texture the cpp uses the OpenGL fixed
function pipeline which results in (alpha * texture color) + (1-alpha * sprite
color).
On HTML5 the sprite color does not affect the final color.
-----
In HTML5 a Sprite cannot be created by cc.Sprite.create(void). It has to be a
minimum of 1 parameter, the filename.
In cpp there is a function which will return a initialized and empty sprite for
such a call.
And this one:
As mentioned this morning, there’s currently a incompatibility between the
JSBindings and Cocos2d-HTML.
On the Node class, HTML exports a method getBoundingBox, while the JSBindings
have boundingBox.
Original issue reported on code.google.com by ricardoq...@gmail.com on 1 Oct 2012 at 8:42
Original issue reported on code.google.com by
ricardoq...@gmail.com
on 1 Oct 2012 at 8:42