Jump to content
This forum will be closing down. Please move to the respective dedicated project forums.

Issue with group


Recommended Posts

I'm having a issue with the group elements; I'm trying to remove them all or kill them and it won't work, it doesn't even trigger an error on console. I don't know if i'm forgetting something, but if anyone can help i will be really glad. 

This is my shortened code:

create: function () {    this.choices = game.add.group();},displayChoices: function(index) {    for(var i = 0; i < 3; i++){       this.choice = this.choices.create(130, 110, 'choice');       this.choice = game.add.text(130, 140, game.global.script[index].choice);       this.choice.inputEnabled = true;       this.choice.events.onInputDown.add(this.choiceTest, this);    }},choiceTest: function(clicked) {    this.choices.callAll('kill');    //this.choices.removeAll();}

I want to kill all the 'choice' created when the choiceTest() is triggered, i tried both methods but neither worked, if i am overlooking something i apologize in advance lol




Link to comment
Share on other sites

Oh! i said it was something i overlook lol 

Thanks rich!

i can do the following right? 

besides it, it's better to enable the input in the group object(this.choices) right?

this.choice = game.add.text(0, 0, "Text", {/*style*/}, otherGroup);

Edit: got it from this link http://www.html5gamedevs.com/topic/2606-can-text-be-added-to-a-group-or-only-sprites/

Link to comment
Share on other sites


  • Recently Browsing   0 members

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