Jump to content

Can't remove all my pause menu component


Recommended Posts

Hi, i tried to make a game with a pause menu but, i only success to supress resume button (not the restart or the menu button) when i click on it.
 I've tried with remove child and remove but it's don't work.


RestartButton =game.Class.extend({   init:function(){       this.sprite = new game.Sprite('run');       this.sprite.interactive = true;       this.sprite.mousedown= this.sprite.tap = function() {           game.scene.stage.pausedGame=false;           this.remove();           //Need Help here                  };       this.restartChoice = new game.Text("Restart", {font: '40px wallfont',fill: "#ffffff",align: "center"});       this.restartChoice.position = {x: 30, y:120};       this.restartChoice.interactive = true;       this.restartChoice.click = this.restartChoice.tap = function () {           game.system.setScene(TestGame, true);       };       this.menu = new game.Text("Menu", {font: '40px wallfont', fill: "#ffffff", align: "center"});       this.menu.position = {x: 30, y: 160};       this.menu.interactive = true;       this.menu.click = this.menu.tap = function () {           game.system.setScene(MenuGame, true);       };   },    displayButton:function() {        this.sprite.position.x=5;        this.sprite.position.y=50;        game.scene.stage.addChild(this.sprite);        game.scene.addObject(this.sprite);        game.scene.stage.addChild(this.restartChoice);        game.scene.addObject(this.sprite);        game.scene.stage.addChild(this.menu);        game.scene.addObject(this.sprite);    }});
Link to comment
Share on other sites

It only work for the sprite, if i try to remove restartChoice and menu with the same way

    mousedown:function() {        this.sprite.remove();        this.restartChoice.remove();        this.menu.remove();    }

i get this error

"this.restartChoice.remove is not a function"

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...