setOpacity() with cc.Sprite?

setOpacity() with cc.Sprite?
0.0 0


Hello there,

I’m trying to port my cocos2d game Lexigon to the html5 framework.

When I create a sprite it seems that setOpacity has no effect?

@ = cc.Sprite.create( this.name1 ); cc.p( this.centerx, this.centery) ); this.scaleFrom ); 0 );
this.daddy.addChild(, 0);

Changing the opacity in an animation sequence works ok.

I am a bit new to javascript, am I doing something silly?




It works for me, which version of cocos2d-html5 are you using?


Downloaded in the last few days, so version cocos2d-html5-v2. (web console says v2.1.0)

Copied the directories -
template (renamed to my project), box2d, cocos2d and CocosDenshion to create my new project.

I’m pretty much just porting from my [obj-c / c++] versions of the game, and so far most things
work ok apart from this addChild is visible when setOpacity is 0?

No issues in browser dev console.

Any ideas?


In the end I added this to my code where I want to add an invisible sprite… cc.FadeTo.create(0.01,0) ); // FUDGE




Actually, I think the reason it didn’t work before was that my graphics were not in the global variable ‘g_resources’.

I found this while trying to get LabelBMFonts to work. Not sure what the significance is of g_resources, but I guess
make sure you have all your resources in there.