**How do I tween an object to an array?
What is the expected result
In my card drawing game, I expect an object /card to tween to the last position of an array, placing a card next to the other cards in hand; this “tween to array” will simulate drawing a card.
What is the actual result
I am currently tweening to a position x,y, but I need something more dynamic to keep even spacing between cards in hand.
Thank you!
For me I will have a scene variable to keep tracking how long or size of my hand
for example if a card has 200px width
When I draw a card:
tween from starting point to x = variable HandSize
Add value of card’s width (200px) to my variable HandSize
When you delete / use a card:
Action: remove value of card width (200) from the HandSize variable
Here it’s dynamic now.
MrMen
May 26, 2024, 9:40pm
3
You could tween to #cards_in_hand * offset, 600
, where
#cards_in_hand
is the number of cards in the array, and
offset
is the gap you want between two adjacent cards
davy
May 26, 2024, 9:45pm
4
In this example, when a card is removed from a row the ones on the right move automatically. Maybe it can help for what you want to do.
Hi Mr Men,
Is there a way to tween to an array with rows and columns?
The solutions shown so far just offset the row, but I have a 4 x 2 array of cards.
THank you!
MrMen
June 7, 2024, 5:58am
6
There will be, it just depends on how you want to fill the cells of the array.
You could use the formula I gave in my previous post, but use different X & Y starting points in it. So it would become:
#cards_in_hand * offset + target_cell_position_x, 600 + target_cell_position_y