Jump to content

Group as a Button


scottgroovez
 Share

Recommended Posts

I've just started using Phaser and I have a question about groups and buttons.

 

I have a button and a text that I've added to a group as I need to animate them. When I click the button the action performs on the button rather than the group even though I've set the callbackContext to be the group.

 

I tried adding the text to the button, but that just gave me a black screen.

 

What's the best approach on creating a clickable object made up of different display objects?

var duck;for (var x = 0; x < 8; x++) {        duck = game.add.group();        duck.x = 100+(130*x);        duck.y = 330;        var d = game.add.button(0,0, 'duck',onDuckPress,duck);	var t = game.add.text(60,55,"2");	duck.add(d);	duck.add(t);	ducks.push(duck);}
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.

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

  • Recently Browsing   0 members

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