Jump to content

Trigger Function on Spacebar release


dasneko
 Share

Recommended Posts

I want to make a code where if you hold down the spacebar key, it will charge up and shoot with that amount of power on its release.

            //charging power            if (this.fireButton.isDown) {                this.power += 5;            }            this.fireButton.onUpCallBack = function() {                console.log("hi")                //fire function            };

where this.fireButton = 

        this.cursors = this.input.keyboard.createCursorKeys();        this.fireButton = this.input.keyboard.addKey(Phaser.Keyboard.SPACEBAR);

Everything work great beside the fact that onUpCallback doesn't work and I am looking for the one that does. Thank you very much!

Link to comment
Share on other sites

            //charging power            if (this.fireButton.isDown) {                this.power += 5;                firing = true;            }            if (this.fireButton.isUp) {                if (firing == true) {                    console.log("hi");                    firing = false;                }            }

Got something like this working but still looking for a better solution.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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