You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Edit the Game.layers.js
To remove a sprite you need to add a sprite to a layer, and the layer to the game.
Here are four examples on how to remove the sprite.
Game.layers[1].extend=cc.Layer.extend({init: function(){this._super();vargame=this;Game.layers[1].start(game);}});Game.layers[1].start=function(game){varsize=cc.director.getWinSize();layer=cc.LayerColor.create(newcc.Color(0,0,0,250),960,640);// R+G+B+Opacity+X+Ygame.addChild(layer);// add layer to gamevarsprite=cc.Sprite.create("HelloWorld.png");sprite.setTag(1);sprite.setPosition(x,y);layer.addChild(sprite,0);// add sprite to layer setTimeout(function(){//layer.removeChild(sprite); // remove sprite of layer//layer.removeChildByTag(1); // remove sprite by tag//layer.removeAllChildren(); // remove all children//layer.removeFromParent(); // remove from parent},3000);// after 3 seconds};
The text was updated successfully, but these errors were encountered:
07 | How to remove a sprite of screen
Game.layers.js
Edit the Game.layers.js
To remove a sprite you need to add a sprite to a layer, and the layer to the game.
Here are four examples on how to remove the sprite.
The text was updated successfully, but these errors were encountered: