Jump to content
This forum will be closing down. Please move to the respective dedicated project forums.

Cordova Buttons do not work


Mattward
 Share

Recommended Posts

Hi,

 

This works when I run it in cordova:

    game.input.onUp.add(jump, this);

 

However this doesn't:

    enPlayButton.onInputDown.muff.add(PlayFunction, this);

 

And when I change it to use the first example, like so:

    enPlayButton.input.onUp.add(PlayFunction, this);

 

It still won't work.. Does anyone know why?

 

Here is the full code if you need it: http://pastebin.com/UyPh1U9F

 

First example is on line 1728.  Second example is on line 554.

Link to comment
Share on other sites

Instead of using a button, I used a sprite which mimics the behavior of a button and now everything works well:

    this.toggleButton = this.game.add.sprite(0, 0, 'toggleButton');    this.toggleButton.frameName = 'onUp.png';    this.toggleButton.inputEnabled = true;    this.toggleButton.events.onInputDown.add(downState, this);    this.toggleButton.events.onInputUp.add(upState, this);    this.toggle = false;    function downState () {        if(this.toggle === false) {            this.toggleButton.frameName = 'onDown.png';            this.toggle = true;	    //add your callback        }        else{            this.toggleButton.frameName = 'offDown.png';            this.toggle = false;            //add your callback        }    }    function upState () {        if(this.toggle === true) {            this.toggleButton.frameName = 'offUp.png';            this.toggle = true;            //add your callback        }        else{            this.toggleButton.frameName = 'onUp.png';            this.toggle = false;	    //add your callback                   }    }
Link to comment
Share on other sites

This doesn't seem to work for me?

I used this:

            this.homeButton = this.game.add.sprite(homeButtonX, homeButtonY, 'homeButton');

            this.homeButton.inputEnabled = true;

            this.homeButton.events.onInputDown.add(HomeFunction, this);

I can't figure out why?! The sprite displays and everything runs fine but nothing happens when I click it?

Link to comment
Share on other sites

For your game you can try something more simple:

    this.toggleButton = this.game.add.sprite(0, 0, 'toggleButton');    this.toggleButton.frameName = 'onUp.png';    this.toggleButton.inputEnabled = true;    this.toggleButton.events.onInputDown.add(downState, this);    function downState () {            this.toggleButton.frameName = 'onDown.png';	    //add your callback        }
Link to comment
Share on other sites

  • 1 month later...
 Share

  • Recently Browsing   0 members

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