Hello. I am an inexperienced dev making a Solitaire game in Phaser 3. I have 53 gameObjects, 52 of which are representing face up cards and the last card being face down. When it comes to dragging the cards, I can hover and drag a single card at a time. I am looking for advice in dragging more than one gameObject at a time? I have considered adding the selected card and all other cards below it to a container and then dragging the container. Would this be the best way to go or am I missing something obvious? Many thanks in advance.
maybe you could assign each of the game objects a number (1 for on the top of the stack and 53 for on the very bottom of the stack) (i dont know how solitaire works). Then when the player clicks on a card only the card with a value of 1 will move. I dont know how solitaire works but this should be good for removing the top card from the deck.
when pointer touches card
{
if (cardNum == 1):
//you are able to drag thatcard
}
For moving multiple cards around, it sounds like the container approach would work. For your drag logic, you would just want to update the containers positioning to match the card that was clicked on and being currently dragged.
When I recreated Solitaire with Phaser 3, the approach I took was just keep track of the cards index in a given stack, and then for each card that needs to be moved, I manually updated that cards x and y position to match the card currently being dragged. I figured since the number of game assets that would be moved at one time would be maxed out at 13, then this approach should be fine.
If you are interested in checking out the approach I took, I shared a written and video series on this here: