Tweening a title screen isn't working properly


(TaylorAnderson) #1

So I have a title screen. When the game loads, the title screen tweens in, no problem. If you wait until the title screen is in the right position and press space, the title screen tweens out no problem. The trouble comes when you try to press space before the title screen has moved into position. I’ve done everything I can to avoid this-- see code below. What I was wondering is if anyone has had experience with this and would like to help me out.

Thanks, Taylor Anderson

	override public function update():void
	{
		
		graphic = new Graphiclist(logo, space, orb)
		if (Input.check(Key.SPACE) && !moveIn)
		{
			sounds.menuTheme.stop();
			exit = true;
		}
		if (moveIn)
		{
			var sTween:VarTween = new VarTween(Stop)
			sTween.tween(logo, "x", logoDest.x, 32, Ease.sineOut)
			addTween(sTween)
			
			var oTween:VarTween = new VarTween(Stop);
			oTween.tween(orb, "x", orbDest, 32, Ease.sineOut)
			addTween(oTween)
			
			var pTween:VarTween = new VarTween(Stop);
			pTween.tween(space, "y", spaceDest.y, 32, Ease.sineOut)
			addTween(pTween)
		}
		
		if (exit && !moveIn)
		{
			var olTween:VarTween = new VarTween()
			olTween.tween(logo, "x", logoExit.x, 32)
			addTween(olTween)
			
			var ooTween:VarTween = new VarTween()
			ooTween.tween(orb, "x", logoExit.x, 32)
			addTween(ooTween)
			var opTween:VarTween = new VarTween()
			opTween.tween(space, "y", spaceExit.y, 32)
			addTween(opTween)
		}
		

		
		if (logo.x <= logoExit.x)
		{
			FP.world = new GameWorld();
		}
		
	}

(Jacob Albano) #2

Did you forget to include the code?


(TaylorAnderson) #3

Oh shoot! Sorry. I got interrupted in the middle of writing this post.


(Jacob Albano) #4

Try calling clearTweens() in your input check on the Spacebar. It’ll cancel any currently running tweens so you can start a new set without worrying about them overwriting each other.


(Zachary Lewis) #5

Where do you set the value of moveIn?


(TaylorAnderson) #6

that worked! i did not know clearTweens() existed. thanks a lot!