This functions works quite well, and if I want multiple cards to flip in sequence all I have to do is chain the functions together. My problem occurs when I want to flip over a large group of cards all at the same time. If I just set the tween to run in parallel, then all three stages of the animation happen simultaneously and it looks terrible. I can’t think of a good way of running each stage of the animation in parallel with all other cards while still having those stages run one after another.
I’ve thought of maybe creating a separate function for each stage of the animation (which feels quite clunky), or creating a separate tween for each card (which would make it difficult to pause the tweens), but I’m not sure which is better or if there is a better way I don’t know of. How should I do this?
How about you run a tween that sets your scale, but have it send the scale to a function that can then update all your cards at once.
Something like:
func _ready():
var tween = create_tween()
tween.set_trans(Tween.TRANS_SINE)
tween.set_ease(Tween.EASE_IN)
tween.tween_method(scale_all_cards, 0.0, 1.0, 2)
func scale_all_cards(new_scale: float):
# here you can update all your cards with the scale value
print(new_scale)
I guess that could work, but because I use different eases for the size change tweens I would have to split everything into multiple functions. If that’s the best option then I’ll try that.
Well, if I were doing this, I would have the cards tween as part of the card as I think you do now. Your question was how do you flip them all at once. Just fire all the cards all at once. (Send a signal like “flip_all_cards” and when the card collects it, it does the flip. All the cards will collect it and all the cards will flip.)
But then you said:
If I just set the tween to run in parallel, then all three stages of the animation happen simultaneously and it looks terrible.
Why would you run the animation in parallel? Lets say you have 10 cards, that would be ten different tweens all happening at the same time.
I can’t think of a good way of running each stage of the animation in parallel with all other cards while still having those stages run one after another.
So that to me sounded like you were asking, “with a single tween how can I animate several cards”. Hence my answer above using tween_method.
If you just want to flip all the cards at the same time, start all the tweens at the same time (presuming each card has it’s own tween).
Does that not solve the problem? If not, what am I missing?