Jump to content
GreenSock

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

omoptical

Members
  • Posts

    4
  • Joined

  • Last visited

omoptical's Achievements

Newbie

Newbie (1/14)

2

Reputation

  1. Ahh, thanks for the explanation, that's interesting stuff. So, it's a frame based thing :: If a tween gets added to a paused parent timeline within 16ms (mes o menos) of being instantiated, it signs up to that queue. Otherwise, if the frame passes without it being added to timeline, it grabs the next frame to start dancing in (unless it's paused already itself) ? And... please don't take any of this as a grumble - really, I haven't enjoyed coding this much in years - just trying to get my head around it. About a week in, and I'm sure most of the code I write now will look terrible after a few months of picking up decent patterns and techniques.
  2. sure, in the interests of greater happiness, though this is likely to bring some horrible coding 'techniques' to light. in, say "main.html" which does setting timeout and initialising the graphics I declared a tll = new TimelineLite({paused:true, onComplete:gameLogic}); and someTweenArr = []; then in "functions.js" I have a function which is setting up all of the tweens in advance to keep them out of the main cycle function setUpTweens(){ ... var tweenNo126 = new TweenLite(tileImages[cur], ant6, {kinetic:{y:"+=" + threeTilelHeight}, ease:Elastic.easeOut, easeParams:[easeP1, easeP2]}); someTweenArr.push(tweenNo126) .... } In this case the tweens start running as soon as they're created. The strange (well, it seemed a bit odd to me anyway, but it's been a long night...) solution was to add a bogus var bogusTl = new TimelineLite({paused:true}); to the top of the function and after minting each new TweenLite do a bogusTl.add(tweenNo126); So the whole function becomes function setUpTweens(){ var bogusTl = new TimelineLite({paused:true}); var tweenNo126 = new TweenLite(tileImages[cur], ant6, {kinetic:{y:"+=" + threeTilelHeight}, ease:Elastic.easeOut, easeParams:[easeP1, easeP2]}); bogusTl.add(tweenNo126); someTweenArr.push(tweenNo126); } It seems to me like the tweens look around for a timeline in their local scope and if they can't find one decide maybe they're on their own and free to start doing their thing. But I didn't actually realise that tweens could be started in a paused state, so that might have saved me a lot of grief
  3. It was paused ! That was what was throwing me ! It seems that if there isn't a fairly local timeline in view the tweens see that as a sign to start.
  4. So, this one had me going for about 5 hours yesterday. Maybe it was a late night, but in case anyone else runs into the same problem I thought I'd post about it. The story so far :: I've been programming a game for mobiles using kinetic & the lite greensock libraries. In order to keep the main animation loop nice and tight the plan was to generate all of the tweens during the initialisation phase, store them in an array and call them by adding them to a timelinelite instance depending on what phase the game was in. The problem :: every time I created a new tween it ran ! Not so handy when trying to pre-compute them. I looked at test code I had written when coming up with a strategy and that code was running fine. I could create the tweens, store them in variables, and they'd be ready. There seemed no difference in the code, but the results were different. The (eventual) solution :: It turned out to be a scoping thing. Because most of the functions for the game are in a different js file, and I was creating the main work-horse timelinelite instance in the main page when adding the tweens in the function stored in the js file, I'm guessing the library thought "hmm, I can't see a TLL object, I better run these right away" So it was a really easy fix in the end, I just declared a paused dummy TLL object in the function which sets up the tween presets, add the tweens to this a few lines of code after setting them up and all is well. They're ready for use when needed. It's probably just a case of me not RTFM correctly, but I couldnt' see any info about it. Hope this nugget helps someone avoid the head scratching and beard pulling I went through ! Bests om
×