Jump to content
Search Community

greenhornsock

Members
  • Posts

    15
  • Joined

  • Last visited

greenhornsock's Achievements

0

Reputation

  1. For whom it may concern... I came up with an ugly but effective hack as a solution: private const MAXDIST:Number=44; //and at the end of the buildTimelines function var car0:Sprite=_train.cars[0] var car1:Sprite=_train.cars[1] // var delay:Number=0 while (dist(car0.x, car1.x, car0.y, car1.y)<MAXDIST){ for (i = 0 ; i< _timelines.length; i++){ delay+=0.00001 var tl=_timelines[i] tl.progress(1-delay*i).timeScale(0); tl.pause(); } }; // just a little distance check function DistanceTwoPoints(x1:Number, x2:Number, y1:Number, y2:Number): Number { var dx:Number = x1-x2; var dy:Number = y1-y2; return Math.sqrt(dx * dx + dy * dy); }
  2. hmm, is there anyway TweenMax / TimeLineMax gives me the length of the path? i only found duration() totalDuration() as a time value.
  3. Hello Carl, thanks for your time. Unfortunately though, this is still not the answer. When changing the length of the track, the distance between the "wagons" still changes. with the Value 0.15 and the length of this demo "track" it is barely noticable. however when you change the values to something a higher it is there. hmm
  4. hi guys, i hacked together a new version with external assets. will work now also with older flash versions. you just need to define the DocumentClass as TrainDemo and add the greensock classes. cheers! TrainDemo.zip
  5. hmm, ok, maybe i produce a version which works with ye olde flash 5
  6. hello and thanks! well the reason for doing so, is that i want the train to have the same speed no matter what the length of the track is. to do this i introduced the SPEEDPERTILE multiplier. this way the speed stays constant no matter how long the track is. i hacked up a little simplified example with fixed path values. ( in my original, the tracks get created dynamically and always a little different. you can click on the switch to see the difference. Thanks!
  7. hi carl, no each track is different in its lengths. this is why i used the SPEEDPERTILE multiplier and then used the progress/delay per car as a relativ value based on percentage.
  8. Hello Carl, sorry, here is some more code (simplified for the example): private const SPEEDPERTILE:Number=.2 private const NUMCARS:Number=3 // this gets computed at runtime by the trackparts the player used. private var _path_values:Array _speed=_path_values.length*SPEEDPERTILE; for (var i:int = 0 ; i< NUMCARS; i++){ var tl = new TimelineMax({repeat:1}); tl.add(getTrainPartAnimation(i)); tl.progress(1-DELAY*i).timeScale(0); tl.pause(); } private function getTrainPartAnimation(i:int):TweenMax { var car:Sprite=_train["train_"+i]; TweenLite.set(car, {x:_path_values[0].x,y:_path_values[0].y}); var tween:TweenMax = new TweenMax(element, _speed, { bezier:{ type:"soft", values:_path_values, autoRotate:true }, ease:Linear.easeNone } ); return tween; } the time() method gives me the same issue ... hmmm
  9. hmm, one more thing: in order to create the illusion of the "waggons" following each other, i used tl.progress(1-delay*i).timeScale(0); where delay is a factor from tl.totalDuration() / DELAY *100 and DELAY a constant. the "speed" or length of the timeline depends on the number of trackparts in oder to keep the animationspeed constant no matter how long the track is. unfortunately with this method i do not get consistent delays between the "waggons" any idea where my mistake might be? thanks!
  10. Hello Carl, i did it now with multiple timelines. it works pretty good. dont know about the performance hit though ...
  11. hi carl, i played around with your code. problem is: if you see the begin and endpoints of the "track" the illusion does not work anymore. in my case you see a closed track including the beginning and end ... hmm
  12. Hello Folks, i am trying to build a little educational application in which i need a train to follow a dynamically created bezier path. i have alredy built the whole thing using TweenMax and the Bezierplugin. TweenMax.to(train, SPEED, {bezier:{type:"soft", values:path_values, autoRotate:["x","y","rotation",0,false]}, ease:Linear.easeNone}); however i would like the train to consist of at least 3 to 5 separate parts, which should move like a real train on the tracks. at the moment my brain seems to be blocked, so i do not know how to do this using the TweenMax/Lite Tools. for example how can i make the second "waggon" follow the first one? Thanks for all tips!
×
×
  • Create New...