Jump to content

sprite.group query (not working in v1 to v2 migration)


charlie_says
 Share

Recommended Posts

This is essentially a v1 to v2 migration question:

 

I have this code:

holder = game.add.group();holder.bg = holder.create(0, 0, 'bg');holder.bg.events.onInputDown.add(this.level_clicked, this);

then later

level_clicked: function(bg){var holder = bg.group;...

this was working in v1, but fails in v2.

 

I guess I could set a variable myself - but is this information now stored elsewhere?

 

Link to comment
Share on other sites

Have you enabled holder.bg for input?

holder.bg.inputEnabled = true;

This was on by default in v1, and is off by default in v2.

 

Also be careful with the approach you're using. Basically you are creating a new property ('bg') on the holder Group, so just make sure you don't name your property the same as any of the methods of properties a Group actually really has and needs! Otherwise there is no telling what may happen.

Link to comment
Share on other sites

There's no such property as 'group' on Sprite any more. You'd get that from Sprite.parent now.

 

It's well worth having a read through the Migration Guide btw as there may be other things like this we list in there that may catch you out.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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