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

 Share

  • Recently Browsing   0 members

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