umair-khan Posted July 20, 2015 Share Posted July 20, 2015 Hi! I want to clear the whole canvas.I know there is one way by changing state, but I want to be in same state and clear whole canvas when a sprite is clicked.Something like: sprite.events.onInputDown(this.clearCanvas, this); Link to comment Share on other sites More sharing options...
drhayes Posted July 21, 2015 Share Posted July 21, 2015 It depends what you mean. Do you mean, "I want to remove every display object from the display graph?" That's "game.world.removeAll();". It'll remove every sprite from the world and you'll have to add them back in manually. Do you mean, "I want to show the player a black screen but *not* kill every sprite in my game?" That's :game.add.bitmapData(this.game.width, this.game.height, 'curtain', true).fill(0, 0, 0);game.stage.addChild(game.add.image(0, 0, 'curtain'));You'll want to track the result of that "addChild" call to remove it later. Link to comment Share on other sites More sharing options...
Recommended Posts