Bugs report

Hello, this might not be the the appropriate place to report bugs but I’m in a bit of a rush so I apologize.

  1. SetEnabled doesn’t work for cc.MenuItemToggle.
  2. Sometimes(but relatively often) on IPhone resource loading gets to 100% but the Main Scene is never shown. This only happens on mobile browsers, haven’t seen it on desktop browsers. The JS console doesn’t show any errors.

About the native bindings:

  1. If you extend cc.LayerColor there is a crash in the native cocos2dx library. I had to extend cc.LayerGradient in order to have semi transparent layers in my project.
  2. cc.DrawNode - coloring doesn’t work if you use real numbers in cc.c4f() function call. For example: cc.c4f(1,0,1,1) is ok but cc.c4f(0.5, 0.5, 0.5, 1) isn’t
  3. The drawn polygons and lines with cc.DrawNode are lost after screen lock/unlock.
  4. Is there any reason to not be possible to extend cc.LabelTTF ?

There were a few more but I can’t remember them now :frowning: I will try to report them as soon as I remember.

Oh one more thing. Is there an article where I can read about object lifetimes in a native bindings project? One thing I find particularly weird is that even global objects get destroyed. For example if I do var myLayer= cc.Layer.create(); in the global scope but then do not use myLayer it gets destroyed.

Best Regards and congratulations on the great work you have done.

Thanks for bug reporting.

  1. SetEnable doesn’t work for cc.MenuItemToggle.
    I tested it and fixed it now, thanks for reminding me.

  2. Sometimes(but relatively often) on IPhone resource loading gets to 100% but the Main Scene is never shown. This only happens on mobile browsers, haven’t seen it on desktop browsers. The JS console doesn’t show any errors.
    I will test it more.

For JSB bugs, James will reply soon.

  1. If you extend cc.LayerColor there is a crash in the native cocos2dx library. I had to extend cc.LayerGradient in order to have semi transparent layers in my project.

I have tested it by ProgressActionTest in TestJavascript. This test case defines a class which extends from cc.LayerColor, and it works fine.

var SpriteDemo = cc.LayerColor.extend({
    ctor:function() {
        this._super();
        cc.associateWithNative( this, cc.LayerColor );
        this.init(cc.c4b(0, 125, 0, 255));  Changed the alpha value from 255 to 100, it works too.
    },
  1. cc.DrawNode - coloring doesn’t work if you use real numbers in cc.c4f() function call. For example: cc.c4f(1,0,1,1) is ok but cc.c4f(0.5, 0.5, 0.5, 1) isn’t

DrawPrimitivesTest works ok.

        var draw = cc.DrawNode.create();
        this.addChild( draw, 10 );

...
       //
        // Segments
        //
        draw.drawSegment( cc.p(20,winSize.height), cc.p(20,winSize.height/2), 10, cc.c4f(0, 1, 0, 1) );   // Tested by changing cc.c4f(0, 1, 0, 1)  to cc.c4f(0.5, 1, 0, 1) 
        draw.drawSegment( cc.p(10,winSize.height/2), cc.p(winSize.width/2, winSize.height/2), 40, cc.c4f(1, 0, 1, 0.5) );
  1. The drawn polygons and lines with cc.DrawNode are lost after screen lock/unlock.

Did it happen on Android? Since the texture of drawing things can’t be saved, developer has responsibility to redraw the line or polygons after entering foreground.

  1. Is there any reason to not be possible to extend cc.LabelTTF ?
    No, you could simply achieve that by adding cc.LabelTTF.extend=cc.Class.extend in jsb_cocos2d.js

Oh one more thing. Is there an article where I can read about object lifetimes in a native bindings project? One thing I find particularly weird is that even global objects get destroyed. For example if I do var myLayer= cc.Layer.create(); in the global scope but then do not use myLayer it gets destroyed.

Now, there are no articles to describe the life cycle of native object and js object. But if you want to save the objects that were not added to any node, you have to invoke myLayer.retain; .

draw.drawSegment( cc.p(20,winSize.height), cc.p(20,winSize.height/2), 10, cc.c4f(0, 1, 0, 1) ); // Tested by changing cc.c4f(0, 1, 0, 1) to cc.c4f(0.5, 1, 0, 1)

yes you can set the values to real numbers nothing is going to crash but the color is not correct. So if you use cc.c4f(0.5, 0.5, 0.5, 1) as your color you are going to get a completely white line.Oh and I forgot to mention - this happens on android(don’t know if this is important)

  1. The drawn polygons and lines with cc.DrawNode are lost after screen lock/unlock.
    >
    Did it happen on Android? Since the texture of drawing things can’t be saved, developer has responsibility to redraw the line or polygons after entering foreground.

Yes it happens on Android, I redraw the lines, recreate the DrawNode but lines and polygons do not get drawn. DrawPrimitivesTest behaves the same way.

Best Regards