Sign in to follow this  
MorpheusZ

Tween a sprite from one group to another

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?

 

Share this post


Link to post
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.

Share this post


Link to post
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 :) 

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.