Jump to content

Parenting and groups


Xaero
 Share

Recommended Posts

Hey guys, I'm new to Phaser and wondering about the best approach to this problem.

 

I'm making a Klondike clone as an exercise to learn Phaser's various ins and outs. What I want to do is be able to add the card I'm dragging as a child of another card so that they can move together. The problem I ran into though is that my only options seems to be making a group PER card which seems a bit excessive... I tried doing it by just parenting it directly to the sprite but that worked out poorly as they are then all treated as the parent sprite and I can't move the child individually any more.

 

Are groups for every card my best option or is there another way?

 

Thanks :)

Link to comment
Share on other sites

Hi, in my opinion group for every card should not be problem. If you have more than one DisplayObject per card, then it makes sense - I would create my custom class "Card" inheriting from Phaser.Group. If you have only one sprite per card, then making group may be unnecessary.

 

For moving cards together - maybe one empty group may come handy. Before moving, you put cards you want to move into it and when the move is finished, you take them out again...

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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