Jump to content
Search Community

Starling and GreenSock integration

Max test
Moderator Tag

Recommended Posts

Hi GreenSock guys,

 

I just about to release my first game. It is based on Starling and I use GreenSock for tweening.

 

I have a problem with GreenSock and application deactivation event - because after calling Starling.stop() my tweens are still running. Basically my question is how I can pause/unpause all my tweens and delayedCalls at one place with GreenSock.

 

There is also another similar approach which is described on starling forums:

 

http://forum.starling-framework.org/topic/benefits-if-things-to-juggler

 

and here is code for it:

 

https://gist.github.com/joshtynjala/5950460

 

but it uses GTween.

 

So, for now I see three options:

 

1. Use Starling juggler for all animations - it is secure but it is time penalty

2. Use GTween - it is well explained + very similar syntax to GreenSock

3. GreenSock? - it should be able to do what I need. It does everything else very well and I bet I am not the only one with this type of problem.

 

How would you suggest me to approach this problem?

 

How it is possible to integrate Starling and GreenSock properly?

Link to comment
Share on other sites

Hi Max,

 

Sounds like TimelineLite.exportRoot() is the perfect solution here:

 

http://api.greensock.com/as/com/greensock/TimelineLite.html#exportRoot()

 

I can't explain it any better than the docs, so just give them a glance.

 

---

 

As for what that guy did with GTween, I'm sure its possible with GSAP to do the same sort of thing, but it would take quite a bit of time for us to dig into Starling, add that functionality, test and document it all. 

 

We'll definitely keep our ears open to gauge interest, but quite frankly we don't get a lot of requests relating to Starling. 

 

Good luck with the release of your game. 

Let us know where we can check it out.

  • Like 1
Link to comment
Share on other sites

For the record, I think you'll find that GSAP offers a lot more flexibility...not even close, really. Did you see the exportRoot() method Carl suggested? It's probably EXACTLY what you needed. There's also TweenMax.pauseAll() and resumeAll(), but the nice thing about exportRoot() is that it allows you to wrap all of the existing stuff into one timeline and pause it so that you can have other/new tweens active independently. We use this, for example, on the main greensock.com home page - notice when you click the "get GSAP" button, the main animation banner pauses while the download window animates into place. And then when you close that window, the banner animation continues. 

 

Plus GSAP allows you to do very complex things easily with nested timelines. It can make your code much more modular. I'm not sure if you can do that with Starling.juggler or GTween. 

 

Anyway, if you can accomplish what you're after with another tool, go for it. We wish you the best of luck with your game. Cheers!

Link to comment
Share on other sites

Hi Jack!

 

Thank you for your explanation! I was with GSAP for a long while but now I needed simple and bulletproof solution - so, Starling.jugglet did its job.

 

GSAP is great and nobody else is even close to you guys by features or performance! But these days we do mobile stuff, and basis for AS3 mobile is Starling, so good integration to Starling is the must for me.

 

Best regards,

Max

Link to comment
Share on other sites

  • 1 year later...

HI Joe,

 

We aren't aware of any issues with exportRoot(), it really shouldn't matter whether you are using Starling or not.

 

Can you share some code or a very very basic demo that shows a timeline generated by exportRoot() not working?

 

your code should look like

var tl:TimelineLite = TimelineLite.exportRoot();
tl.pause();

at that point any GreenSock animations that you created should be paused.

Link to comment
Share on other sites

Hi Carl,

 

Thanks for the quick response! I am using it just like you show above. I'm using Starling to create an iOS app. It does work fine if I just pause it while in the app like by pressing a button. Where it doesn't work is when I press the home button on the iPad. I'm using Event.DEACTIVATE to handle this and in the event handler I call the starling.stop() method and also call a custom method that does the exportRoot and pause. Just like the user mentioned above, it's there where the problem occurs. The tweens continue running. When I come back to the app the tweens have advanced. I've been looking around online and from what I've seen it appears to be a problem with Starling using a different ENTER_FRAME than GSAP. I was wanting to know if there is a version that uses the same ENTER_FRAME or what that would take. I really love GreenSock and would rather use it over the Starling Tween, but I'm running into this problem. Any help would be greatly appreciated.

Link to comment
Share on other sites

I can't imagine why running on a different ENTER_FRAME loop would cause this sort of problem - are you 100% sure that your exportRoot() and pause() code is actually executing? If, for example, you starling.stop() and then your exportRoot() code is dependent on starling advancing to another frame or something, perhaps that's where the problem is? Have you tried making sure that starling.stop() is called AFTER you do the exportRoot() and pause()? 

  • Like 1
Link to comment
Share on other sites

I just changed it so that it waits until I have done the exportRoot and pause. After that is finished it dispatches an event to call the starling.stop. I put a trace in and can see it in the console. I'm pretty sure that everything has executed.

Link to comment
Share on other sites

And you're saying it still doesn't pause things? Are you sure that the animations that aren't paused existed at the time you called exportRoot()? Keep in mind that one of the coolest things about exportRoot() is that it allows you to segregate the current/live animations from future ones, meaning you can control them independently. Like for a modal window that animates normally, but all the background animations that pre-existed slow down or pause while the modal is open, and then resume() later. 

 

In other words, I'm wondering if you've got code that's creating other/new tweens AFTER you called exportRoot() and you expected those to be paused as well (which wouldn't be the case). 

Link to comment
Share on other sites

As far as debugging goes, after you exportRoot() please try getting the duration() and getChildren() Array like

trace("timeline duration = " + tl.duration());
trace("number of children = " + tl.getChildren().length);

If the export worked you should get some values for both.

 

also it might be worth trying tl.restart() when your app becomes active again.

Link to comment
Share on other sites

Sure, you're welcome to send us a zip that has everything necessary to publish (including Starling files and a .FLA), but be warned: we have pretty much zero experience with Starling and we don't "officially" support it, but I'd be happy to at least hit compile on the file and see if anything pops out as an obvious error. 

Link to comment
Share on other sites

It would work best if I could email it. It would also be good if you could build it and run it on the iPad, but I would need to add your iPad to the provisioning profile, so I don't know if that's possible. If it's something that you have time to look at further send me an email. My email is linked to my account.

Link to comment
Share on other sites

Are you saying it works fine on the desktop and you're only experiencing the problems on the iPad? 

 

Oh, and the link you provided gets me: Error 404 - Page Not Found. 

 

If there's no FLA for us to test on the desktop or it's required to run a Starling project on an iPad to see the problem, unfortunately we don't have the resources to do that. Sorry. 

Link to comment
Share on other sites

By the way, that starling forums thread had some bad info. Someone was saying that if you use GSAP and your frame rate happens to bog down (like from 60fps down to 30fps), all your tweens will run slower. Totally false unless you're specifically setting your tweens or timelines to use frames (useFrames:true). The default timing mode prioritizes time, not ticks.

 

I glanced at the code you referenced and I can't fathom why GSAP would have to create a dependency on Starling's juggler and add/remove things there. Can you explain why that'd be useful/necessary? GSAP has its own ENTER_FRAME listener...so what? Even if its code runs immediately before or after the juggler's ENTER_FRAME loop, why would that suddenly cause it not to work at all? I just can't see the logic unless there's a problem in Starling that's somehow messing with other objects' event listeners. I can't imagine they'd overreach like that. 

 

It's especially odd that you're saying it works fine on the desktop. That makes it sound like it may be an issue with AIR or Starling. It's not as if GSAP is different. See what I mean?

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.
×
×
  • Create New...