How can i move sprite smoothly using lerp?

Get help using Construct 2

Post » Tue Sep 16, 2014 2:03 am

Hi everyone
I want to move a sprite from A to B smoothly using lerp and without Variables.
Can i make this?

Thank's for any help.
B
60
S
10
G
10
Posts: 1,013
Reputation: 9,165

Post » Tue Sep 16, 2014 5:17 am

Well if you want the object to move after a click, you got to have some vars.
If you want it to follow the mouse/touch you can do it without vars.

check this out:

lerptest.capx
You do not have the required permissions to view the files attached to this post.
Image
B
82
S
30
G
12
Posts: 517
Reputation: 12,763

Post » Wed Sep 17, 2014 2:45 am

Thank's for the capx.
What i want is when i click a button the sprite go from Position X to Position X2, i think can be done without var.
B
60
S
10
G
10
Posts: 1,013
Reputation: 9,165

Post » Wed Sep 17, 2014 3:00 am

Does Lof's capx not answer your question? and I'm curious, why avoid variables?

can you take what Lof did (the one without the variables) and plug in your positions instead of the touch positions?
B
88
S
43
G
71
Posts: 601
Reputation: 43,669

Post » Wed Sep 17, 2014 3:04 am

I am not an expert, but i am not sure you can and i don't see what's the problem with storing the values?
Lerp is not an action that runs once, you run it every tick and the object keeps moving until it reaches point B.
So you must have access to point B .X .Y all the way through, when you click you get the .X .Y but it's not stored anywhere.
Image
B
82
S
30
G
12
Posts: 517
Reputation: 12,763

Post » Wed Sep 17, 2014 3:23 am

Well, it sounds like his point B is a constant anyway, so that shouldn't matter, right? If I'm not misunderstanding, he knows what two points he wants, and just wants to move between them on the click of a button.

EDIT: So like this, I'm thinking:
lerpbutton.capx
You do not have the required permissions to view the files attached to this post.
Last edited by spacedoubt on Wed Sep 17, 2014 3:29 am, edited 1 time in total.
B
88
S
43
G
71
Posts: 601
Reputation: 43,669

Post » Wed Sep 17, 2014 3:26 am

If that's the case and it's a one time movement to a predefined point B, than yes.
Image
B
82
S
30
G
12
Posts: 517
Reputation: 12,763

Post » Wed Sep 17, 2014 3:31 am

Now that i think of it, you will still need a var for triggering the movement, unless you hold your click/touch.

Or grouping may also work :)
Image
B
82
S
30
G
12
Posts: 517
Reputation: 12,763

Post » Wed Sep 17, 2014 3:47 am

I added a capx to my post earlier, I did it with grouping. heh..
B
88
S
43
G
71
Posts: 601
Reputation: 43,669

Post » Thu Sep 18, 2014 2:03 pm

Thank's guys for the help and the capx.
I don't want to use Var because i have already lot of it.
I hope some day the custom movement behavior will be improved so we can move sprites to target positions.
B
60
S
10
G
10
Posts: 1,013
Reputation: 9,165


Return to How do I....?

Who is online

Users browsing this forum: Yahoo [Bot] and 6 guests