Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
MacShrike

realtime Tweenlite.to calls v.s. a timeline & garbage collection

Recommended Posts

Ls,

 

I'm not new to the greensock product but I previously only used it for animation sequences.

Now, i'm trying to use it in a as3 script to control several background animation effects.

 

The Display object attributes get updated almost every EnterFrame to give a continues feel.

I'm changing mostely values like the rotation of objects and Y values.

I used simple Tweenlite.to's wich works "really well"; on a desktop anyway.

i.e.:

TweenLite.to(globals.backgroundManager, .5, {rotation:-baseCirGrid.speed /2 * myPlayer.current_mode * Math.PI / 180});

 

 

TweenLite.to(this, .1, {rotation:(globals.myJoystick.JSrc.x * Math.PI / 4)})


On mobile, the garbage collection from all these tweenlites.to's makes it unusable (makes sense too)

So...

 

I tried making a timelinelite instance where I used .insert and/or .add's to the timeline (with and without using overwrite:"all"/"auto" and insert at 0 time)

 

This has the effect that the tweened values don't update continues but only after the last call and happen only after no new changes are made (player stops moving for a sec)

 

I'm sure there's a way to get the simple tweenlite.to call to work with a timeline but I haven't been able to get it to work.

I'm not using the starling.juggler so just adding tweens to it is not usable for me.

 

Please help.

 

In short:

I want to tween.to the , say rotation, of  a sprite every frame(update) to reflect the x/y position on the screen relative to the screen center (just an example).

But I dont want to create a new tweenlite.to instance every frame/reuse tweenlite's

How do I accomplish that?

 

Highest regards,

 

Mac

 

 

 

 

Link to comment
Share on other sites

The performance overhead of creating new tweens or running thousands of them concurrently is extremely low as the engine is highly optimized and AS3 execution is incredibly fast. 99% of the hangups you see in Flash are due to rendering performance. Only under severe stress would you have to really worry about creating new tweens

 

That aside, I'm really not understanding what you need to do. A TweenLite.to() tween has a finite duration, start and end values. If you need to change the end values of a to() tween while it is running we have the dynamicPropsPlugin: http://greensock.com/asdocs/com/greensock/plugins/DynamicPropsPlugin.html (for Club GreenSock members). 

 

It sounds to me like you may not need a tween for this, perhaps just an ENTER_FRAME event like

addEventListener(Event.ENTER_FRAME, update);

function update(e:Event):void {
  somcMC.rotation = globals.myJoystick.JSrc.x / 2;
}
  • Like 1
Link to comment
Share on other sites

Hello Carl

 

Thx for the reply 8-)

 

The performance is great indeed!

Just the way I am using it showed up as humongous GC spikes in adobe Scout.

 

Some devices handle it, my galaxy tab10.2 choked and died.

 

I did do a quick resculpt to something like a custom tween calculation but the tweenlite.to gave a far superior easing into the motions look and feel.

Especially with rotating the background to the inverse of the player and with adjusting the virtual horizon (its a kind of 2d 3d ) when it lags behind a bit and settles into the end result is very smooth and natural.

 

Am I correct to understand that if I use the dynamic props thing I can write 1 tweento that keeps updating to the new values?

That would be awesome.

 

Highest regards,

 

Mac

Link to comment
Share on other sites

Am I correct to understand that if I use the dynamic props thing I can write 1 tweento that keeps updating to the new values?

 

A tween using DynamicPropsPlugin still needs to have a duration, it doesn't run constantly.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×