Jump to content

Can't index into group.children


NewGuy
 Share

Recommended Posts

Hey, gais.

My issue is as the title says. I create my group like so;

this.cards = this.game.add.group();

and I populate my group like so;
 

...for (var i = 0; i < num_cards; i ++) {    card = new Card(this.game, this.game.width/2, this.game.height/2, 'card_unknown', i, cards[this.order_array[i] % pairs], scale);    card.scale.setTo(scale, scale);    card.anchor.setTo(0.5, 1.5);    card.angle = angle * (i - 2);    this.cards.add(card);    this.game.add.existing(card);    this.card_count ++;}...

And the issue appears when I try to access 'this.cards.children[ i ]', for example. With a group full of eight cards, I will try grab 'this.cards.children[ 0 ]' and I'll get undefined!

What am I missing here, peeps?

Link to comment
Share on other sites

Dammit guys, literally the second after I post I see my mistake. XekeDeath solved it the other day. Can I remove this post? The issue how I use 'this.game.add.existing'

Why would you want it the post deleted? Even if it's a silly mistake, it may be useful to other people.

Link to comment
Share on other sites

I've made lots of silly mistakes on public forums and open source projects. It's cool, we're all learning here. ( =

 

FTR, yeah, sprites can only have one parent so that call to "game.add.existing" takes them out of the card group you added them to previously.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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