Jump to content

Using button as toggle


Recommended Posts

Hi everyone,


I'm starting to use Phaser to play with html5 development.

I'm trying to make a toggle for sound, for muting.


Is it possible to use a button as a toggle?

I found http://www.html5gamedevs.com/topic/1730-click-sprite-and-button-question/?hl=%2Bbutton+%2Bframe#entry11867 but I wanted to know if there is a solution that is not a tricky for doing it.


Link to comment
Share on other sites

I succeed to do what I wanted.


I did what you did Alvin but I just used the frame of my spritesheet, no need for two images.


That's what I did:

this.soundToggle = this.game.add.button(this.game.world.width - 150, 15, 'button', this.toggleSound, this);this.soundToggle.frame = 1;

And when cick I toggle the frame from 1 to 0 and from 0 to 1.

That's it.

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