Sign in to follow this  
ChetD90

How to make a close button for menu

Recommended Posts

I recently made a pop-up menu for my game which pops up after pushing a button. The problem is now that I need to figure out how to make a function that closes the menu. Here is the code:

this.input.keyboard.once("keydown_D", event => {
	var StoreWindow = this.add.image(0, 0, 'StoreWindow').setOrigin(0);
    var backbutton = this.add.image(32, 34, 'backbutton', 0).setOrigin(0).setInteractive();
    var testButton = this.add.image(64, 110, 'testButton', 0).setOrigin(0).setInteractive();

    var storeContainer = this.add.container(32, 70, [ StoreWindow, backbutton, testButton]);

    storeContainer.setInteractive(new Phaser.Geom.Rectangle(0, 0, StoreWindow.width, StoreWindow.height), Phaser.Geom.Rectangle.Contains);

    this.input.setDraggable(storeContainer);

    storeContainer.on('drag', function (pointer, dragX, dragY) {

        this.x = dragX;
        this.y = dragY;

    backbutton.on('pointerup', function (storeContainer) {

       this.deletecontainer(true);

    }, this);

      
 })
.setScrollFactor(0)
.setDepth(30);

 

Share this post


Link to post
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.

Guest
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.

Loading...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.