Jump to content
Search Community

k1rsan

Members
  • Posts

    2
  • Joined

  • Last visited

k1rsan's Achievements

0

Reputation

  1. Hello ) I'm trying to create a stream of tweens with Timeline and I have very confused results. //init var bulletsTween:TimelineMax = new TimelineMax( { autoRemoveChildren:true, paused:true } ); //add tween to stream public function fire(mouseX:Number, mouseY:Number){ var bullet:GrenadeLauncherBullet = new GrenadeLauncherBullet(); if(bulletsTween.time() > 0){ bulletsTween.pause(); } //...some calculations here var bulletTween:TweenMax = new TweenMax(bullet, distance / GameSpace.HEIGHT + BULLET_TIME, { bezier: { autoRotate:false, curviness:0, values:[ { x:bezierPoint.x, y:bezierPoint.y }, { x:mouseX, y:mouseY } ] }, frame:19, onComplete:onBulletAnimComplete, onCompleteParams:[mouseX, mouseY, bullet], ease:Cubic.easeIn } ); bulletsTween.add(bulletTween, bulletsTween.time()); bulletsTween.play(bulletsTween.time()); } //pause stream public function pauseTweens():void { if (bulletsTween.time() > 0) { bulletsTween.pause(); } //...pause other tweens } //resume stream public function pauseTweens():void { if (bulletsTween.time() > 0) { bulletsTween.play(bulletsTween.time()); } //...pause other tweens } I tried a lot of combinations to organize the stream. This solution works, but it has unpredictable behavior. I can fire 7 bullets, pause it, then resume and all works fine. Another time I fire, for example, 3 bullets, make a little pause, then fire another one and first 3 bullets complete their animations immediately and fires onComplete event, but another time this event does not fire. In same situation once everything works ok, but the second time it crashes. If I delete the if statement here: if(bulletsTween.time() > 0){ bulletsTween.pause(); } and pause timeline if it is just createt and empty, then the first added tween to the timeline completes immediately without render and fires the onComplete event. After that other tweens works fine. This bug appears only for the first added tween to the timeline. If I use the resume() function it causes glitches that I have mention above. I use play with the concrete position, but it also causes the glitches. Some tweens dissapear from timeline, do not remove the tween target and do not fire the onComplete event. if (bulletsTween.time() > 0) { bulletsTween.play(bulletsTween.time()); } I think that I do not understand how to create a stream of tweens. Is there any pattern or sample to watch how to do it right?
  2. Hello, I have a question about tweens that have a delay at the beginning. //init var highScoreTween:TweenLite= new TweenLite(highScore, 0.4, { delay:1, alpha:1 } ); //here is the question if (highScoreTween.time() < highScoreTween.duration()) { highScoreTween.seek(highScoreTween.duration()); } If I want to check tween for activity, when it has already started, but delay time has not passed. The function time() returns 0 and propertie _active is false. How can I know that this tween has already begun?
×
×
  • Create New...