Sign in to follow this  
mtburdon

Grouping buttons

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

Share this post


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

Share this post


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

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.