[SOLVED] How to tween a stamp in a graphic-list?


#1

Hello…

follows i tried:

public var STL1Mot:LinearMotion= new LinearMotion(); //motion tween to tween the star
public var SternL1:Stamp; // a graphic of a star
public var SL1PosE:Point; //the end position of the tween
public var SL1PosA:Point; //the start position of the tween
public var GList:Graphiclist=new Graphiclist(); // the graphic-list of the entity... 

SternL1 = new Stamp(STERN_LINKS_1);
GList.add(SternL1);
            SL1PosE.x = 54;
            SL1PosE.y = 184;
            SL1PosA.x = SL1PosE.x+93; 
            SL1PosA.y = SL1PosE.y+35; 
            SternL1.x = SL1PosA.x;
            SternL1.y = SL1PosA.y;
STL1Mot.setMotion(SL1PosA.x, SL1PosA.y, SL1PosE.x, SL1PosE.y, 0.5);
STL1Mot.object = SternL1;
STL1Mot.start();

but nothing happens… the star is like thought on the start-position, but don´t tween to the declared end-positions… what do i wrong???

thanks in advance kolibri


(Darrin) #2

It is interesting I learned actionscript with FP at the same time so I didn’t bring much Flash with me. I’m not sure why you are using tween. Hopefully this note is not totally off. The entity class has moveTo and moveTowards. The frame rate is already set up in main. Just create an entity, then in the override function update, tell it where you want the entity to moveToward. Make sure to use FP.elapsed * speed to smooth things out. You can use standard math functions to calculate all the x,y coordinates so sine waves, circles, etc. But you still should use the FP.elsapsed.

	override public function update():void
	{
		
		x -= speed * FP.elapsed; //Move the alien towards the left
		y += (Math.cos(x / 70)  * 70) * FP.elapsed; //Use Math.cos to give the aliens wavy movement
		if (x < -width) //if the alien has gone off screen, delete it
		{
			destroy();
		}
		
		var bullet:iBullet = collide("bullet", x, y) as iBullet;
		if (bullet)
		{ 
			dropPowerUp();
			HUD.score++;
			bullet.destroy();
			destroy();
		}
					
	}

#3

hello darrin,

sorry… but your post is completely useless for me… i don´t want to make for every (roundabout 20) stars an own entity… to move an entity you can use linear/quad/circular motions perfectly…

that is the reason, i use a tween … i must no calculate/keep eyes of speed/fp.elapsed/width/heights… i say “move this from x,y to x,y in timespan x… and use by the way an ease to e.g. bounce it in/out” its hard to programm it over your update-function-way… :smiley:

my question was: “why the tween don´t functionate on a stamp that was part of a graphic-list”…

and your post is not an answer for my question… sorry again…

greets kolibri


(Jacob Albano) #4

The LinearMotion class is rather poorly docuented, or it was the last time I used it anyway. Try setting object before you call setMotion().


#5

thanks for the tip… i will try it…

i tried also, to setup a multivars-tween on the x and y of the stamp… but the same… no movement…

is it possible, there must be done an update of the graphic-list?

greets kolibri


(Jacob Albano) #6

Oh, I missed something obvious: you have to add tweens to the entity or world you’re managing them on.

addTween(STL1Mot, true);

#7

thats the problem!!!

i cannot use addTween… it´s NOT an entity… its only a stamp, whos part of a graphiclist of an entity… you know?? if i use addTween, then the whole graphiclist will be affected by the tween…


#8

in the end i will have roundabout 20 tweens (for 20 different stars)… and i cannot add more than one tween to an entity…

and it must be a graphiclist… i dont want to correct in each frame the x and y of every entity in offset to another entity (which is the main-part of all)… it must be possible… i know it… lol


(Jacob Albano) #9

Eh? You can add as many tweens as you want, and only the object you explicitly tween will be affected. Whether you add the tween to the Entity your graphiclist is attached to, the world that entity is in, or FP.tweener, the behavior will not change.

Every tween object has to be added to a tweener or it will never update.


#10

yess…

sorry… that was a fat error in my thoughts… i´d added now addTween and it works like a charm!

thanks for your help. kolibri