LinearMotion Tween (Solved)


(christopf) #1

How do i apply a motion tween on an entity if that is possible anyway?
In the documentation is written about a possibility to apply the tween on an object. so do you have to create a single object or maybe transform the entity into one?

in my case i want the camera to move a distance from one point to another on event always different in distance but same in duraction.

to now, i tried it with VarTween and LinearMotion but i guess i’m to beginner to get this working on my own :x


(Jacob Albano) #2

What do you mean? An Entity is an Object already.

This might be helpful to get you started: Basic of Tween Classes


(christopf) #3

Crazy. Ive searched the declarations for a hint if so but didnt find :smiley: now im feeling pretty stupid.
I already know the thread you postet but since i didnt found a hint for linearMotion i thought this is to handle in a special way.

my code looks after a few tries like this

override public function update():void 
{
	super.update();
		
	if (mori.trans == true)
	{	
		if (r == true) 
		{ 
			move.setMotion(mori.transPoint.x, mori.transPoint.y, 1271, 768, 3, Ease.quadOut);
			camboi.addTween(move); r = false }	
			
		FP.camera.y = camboi.y - (FP.halfHeight);
		FP.camera.x = camboi.x - (FP.halfWidth);
	}
}

in the begin() function it looks like this

override public function begin():void
{
	super.begin();

	move = new LinearMotion(respawn, ONESHOT);
		
	camboi = new Entity();
	add(camboi);
}

and + the variables at the top of the world class.

when my hero dies (trans = true) the camera switches into the off (behind some mountains) and after the tween finished it jumpes back to the spawn point (man, cause of this writing i realized that the tween must work…i have to check on this after this sentence). i guess it doesnt applies on the entity but my head is burning (its nearly 12o’clock and my baby doesnt let me sleep long these days :smile: ). what do you think?


(Jacob Albano) #4

This should be what you want:

var motion:LinearMotion = new LinearMotion();
motion.setMotion(FP.camera.x, FP.camera.y, spawnX, spawnY, speed);

// this is probably what you need. 
// set the camera as the target of the motion
motion.object = FP.camera;

FP.tweener.addTween(motion, true);

(christopf) #5

haar! in this moment i wanted to post the solution!
found it over here Tweening appears to be working properly

thanks again anyway @jacobalbano (and the solution with camera i tried before but forgot about it now - even mor elegant)