Jump to content

Tween a sprite from one group to another


MorpheusZ
 Share

Recommended Posts

I have 2 sprite groups each representing a hand of cards. Each group has its own scale, rotation and position; same for each sprite (card) in each group.

I'm trying to create a smooth animation of the card moving from one hand to the other. I can calculate the local parameters (scale, rotation and position) of where the card should be in the new group, but I can't seem to find an easy way to create a tween between 2 sets of local parameters.

The only route I could think of at the moment is something along the lines of:

store 'sprite.world', 'sprite.worldScale' and 'sprite.worldRotation' => remove sprite from group => add sprite to temporary group => set temporary group's parameters to the stored world parameters => calculate the world parameters in the new group => tween to new world parameters => add sprite to new group and set it to its local parameters.

The becomes even more difficult if the destination could potentially change during the tween.

Is there an easier or a more robust way of achieving that?

 

Link to comment
Share on other sites

I'm not sure you need the intermediate group. You can just move the sprite to the World and tween it there.

For a changing destination: some people have been able to modify a tween's target values manually while it's running. You could also skip tweens and use linear interpolation instead.

Link to comment
Share on other sites

well, I tried some version of this and I faced two problems:

(1) the target group's transformation could change while the tween (in world co-ordinates) is in progress, which causes the sprite to land in the incorrect spot

(2) I don't have control over the tweened sprite Z-order relative to the sprites of the target group

I feel this problem essentially boils down to moving a sprite from one group to another without changing how it looks like on the screen, which we're now discussing in the topic below :) 

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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