@BennyB wrote:
Hi All,
I'm having a small issue with setOpacity on Sprites. I'm using cocos2d 3.9.
Basically what happens is if I set the opacity of the Sprite directly after adding to another node (layer), then I can't change the opacity again using setOpacity.
ctor:function(){
this.bckGrnd = new cc.Sprite(res.Background);
this.addChild(this.bckGrnd);
this.bckGrnd.setOpacity(0);
},onBtnPress:function(){
if ( this.bckGrnd.getOpacity() == 0 )
this.bckGrnd.setOpacity(255); // This line seems to have no affect.
else
this.bckGrnd.setOpacity(0);
}If I don't set the opacity directly after adding the child - then the opacity can be changed - and the button press works.
If I leave the line "this.bckGrnd.setOpacity(0);" in ctor, then the opacity can't be toggled...The actual opacity value of the sprite is being changed - getOpacity is returning the right value - but the Sprite isn't being displayed on screen
Has anyone else run into this issue before?
Cheers,
Ben.
Posts: 2
Participants: 2