[HOW TO] Tween engine

Any community contributions to libgdx go here! Some may get included in the core API when permission is granted.

[HOW TO] Tween engine

Postby palves1978 » Mon Oct 31, 2011 2:48 pm

Hi,

I'm having a problem controlling tween engine.
When i tween a sprite to go from a place to another the tween manager works like a charm taking care of my animation until it reaches it's destination, the thing is that while the animation isn't over i want my code to freeze/wait until the tween is over.
How do i manage to do this?
I thought on having states in my sprite and in my TweenSprite class controlling that states so that while my tween ins't over my sprite state is one (e.g. MOVING) when the tween is over i change the sprite state to IDLE or something like that...

Thanks!
palves1978
 
Posts: 21
Joined: Sat Sep 03, 2011 12:59 am

Re: [HOW TO] Tween engine

Postby Obli » Wed Nov 02, 2011 10:21 am

Hello,

You can check if a tween is actually running by using TweenManager.contains(). This method takes as parameter your Tweenable target, and optionally the type of the tween you want to check. By using it, you can know if some tweens are still valid for your objects. If it returns true, just keep your game idled, else resume it :)
Obli
 
Posts: 616
Joined: Mon Jan 10, 2011 6:18 pm
Location: Bordeaux, France

Re: [HOW TO] Tween engine

Postby palves1978 » Wed Nov 02, 2011 11:03 am

Thanks a lot!
I'll try that and see if it works for me.

Cheers.
palves1978
 
Posts: 21
Joined: Sat Sep 03, 2011 12:59 am


Return to Libgdx Contributions

Who is online

Users browsing this forum: No registered users and 1 guest