Jump to content

Grouping buttons


mtburdon
 Share

Recommended Posts

Hi all,

 

I'm looking for a way to group buttons so I can animate between them.

 

For example I have 15 levels in my game split between 3 worlds so 5 levels per world. I want to show buttons to these levels with 5 on the screen at one time, when the user clicks an arrow, the first 5 buttons slide left off screen and the next 5 slide in from the right.

 

I initially thought of adding buttons to a group much like you do with sprites, then animating the groups on/off screen but it doesn't seem as though I can do this.

 

What would be the correct way of doing this?

 

Thanks,

Martin

Link to comment
Share on other sites

For me using buttons in groups is working fine.

 

If the problem is getting the buttons into a group, here is the code from my memory game that does that:

//create a groupvar cardGroup = this.game.add.group();//put a button invar card = this.game.add.button(this.game.width / 2, this.game.height, 'cards', this.cardClick, this, 0, 0, 0, 0, this.cardGroup); 

You can move, scale and tween this group around, and all buttons in it will be affected.

Link to comment
Share on other sites

Hi jpdev,

 

Thanks for your answer, for some reason this doesn't seem to be working for me, I'm getting no objects added to the group  :wacko:

 

I did however manage to get a workaround before I got your answer where I basically increase the bounds of the game and move the camera between 3 predefined locations which show the different world levels.

 

Thanks,

Martin

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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