FlxTween.linearPath() issues/questions

98 views
Skip to first unread message

drew tenenbaum

unread,
Dec 31, 2015, 3:30:20 PM12/31/15
to HaxeFlixel
I'd like to use the linear path so i dont have to set up the series of tweens and timers to do the same functionality, but i'm having some issues:

//p1 and p2 are fixed points that i have verified to be the correct values by using trace()
var currentLoc:FlxPoint = new FlxPoint(front.x, front.y);
var fp1:FlxPoint = new FlxPoint(p1.x, p1.y);
var fp2:FlxPoint = new FlxPoint(p2.x, p2.y);
var speed:Float = 15.0;

FlxTween.linearPath(front, [currentLoc, fp1, fp2], speed, true, { complete: doneMovingPath } );

I think I'm using this correctly. i want the sprite called "front" to move from its current location, to p1, and then to p2. basically, it's an "L" shape.
This doesnt work as expected though. what happens is that front jumps immediately to p1, and then spends speed seconds to reach p2.
Why could this be happening? what am i misunderstanding? or is there a bug?

Also not related to the above issue:
-If i want to use speed as opposed to duration (currently using duration), what does the speed variable have for it's units? it's a float. 
is it in pixels per second? seconds per pixel? pixels per gameloop? something else?

Thanks for any help.
-drew :-)

drew tenenbaum

unread,
Jan 7, 2016, 12:39:07 PM1/7/16
to HaxeFlixel
Sorry for the bump. I have yet to figure this out. any ideas?

Jeru Sanders

unread,
Jan 7, 2016, 4:16:15 PM1/7/16
to HaxeFlixel
I get the feeling linearPath() is a very seldomly used function. I recommend building it with Actuate, or FlxTween.tween().

drew tenenbaum

unread,
Jan 8, 2016, 2:58:11 PM1/8/16
to HaxeFlixel
Ok.Thanks for the response. I understand that it may be a seldom used function, but if it's available as part of the API, it should work. or be taken out.

Can anyone provide any information on if this is a bug, or a user error?

Also, Actuate is nice, but it fires every ENTER_FRAME event, and thus operates outside of HaxelFlixel's update() and time scheme. Unless you know how to make it update its tweens in the update loop in HF?

Gama11

unread,
Jan 8, 2016, 5:10:32 PM1/8/16
to haxef...@googlegroups.com
Works as advertised for me:


package;

import flixel.FlxSprite;
import flixel.FlxState;
import flixel.tweens.FlxTween;
import flixel.util.FlxPoint;

class PlayState extends FlxState
{
override public function create():Void
{
var sprite = new FlxSprite();
add(sprite);
var currentLoc = new FlxPoint(sprite.x, sprite.y);
var p1 = new FlxPoint(100, 0);
var p2 = new FlxPoint(100, 100);
FlxTween.linearPath(sprite, [currentLoc, p1, p2], 1);
}
}

Regarding speed, the unit is indeed pixels per second (which is the case for most speeds in flixel, like sprite.velocity).

Regarding Actuate, it looks like you can define actuate_manual_update which prevents Actuate from registering it's own ENTER_FRAME listener. You would then have to call SimpleActuator.stage_onEnterFrame() manually.

Jeru Sanders

unread,
Jan 8, 2016, 5:17:50 PM1/8/16
to HaxeFlixel
Looks fine to me.

What branch are you on? And can you isolate the problem?
Reply all
Reply to author
Forward
0 new messages