How do I fix my sliding menu?

Get help using Construct 2

Post » Fri Nov 04, 2016 4:25 pm

Message: Eltondrknss can only post plain text URLS until they have 500 rep. 2 URLS modified. Why?
Hi everyone

Im trying to make a sliding menu using a simple trigger: you click, it goes left, click again and it goes right (returning to its initial point).
The problem is that when I do it, it makes the same move twice after the first time
E.g. click = left / click = right / click = right / click = left / click = left and so on
I tried bullet behavior and custom movement, both the same thing. Any ideas?

https://img42.com/wPcyN

.capx attached
http://expirebox.com/download/35b23e1a9%20...%20aa69c.html

Thanks in advance

[EDIT]

Sorry, cant attach files yet :|

[EDIT2]

Now I can :D
Last edited by Eltondrknss on Fri Nov 04, 2016 5:17 pm, edited 1 time in total.
B
8
S
2
Posts: 23
Reputation: 555

Post » Fri Nov 04, 2016 4:39 pm

try
Image
B
67
S
24
G
7
Posts: 1,518
Reputation: 11,072

Post » Fri Nov 04, 2016 5:21 pm

Thanks man, it worked :D
The only "bug" I noticed is that if double click it, you bug the movement, but that is really not a problem.
If its not asking much, can you explain me what is that "(slide+1)%2"?
Thanks again!
B
8
S
2
Posts: 23
Reputation: 555

Post » Fri Nov 04, 2016 5:30 pm

You should consider using lerp, like this:

Image

And this is what it looks like in-game:

Image
B
125
S
43
G
41
Posts: 849
Reputation: 28,260

Post » Fri Nov 04, 2016 5:57 pm

andreyin wrote:You should consider using lerp, like this:

Image

And this is what it looks like in-game:

Image



Thanks andreyin, it looks pretty cool due to the acceleration effect, but i have no ideia about how lerp work :?
B
8
S
2
Posts: 23
Reputation: 555

Post » Fri Nov 04, 2016 7:01 pm

Here's more about it:
https://www.scirra.com/blog/ashley/17/u ... delta-time

But to keep it simply, you just use lerp(a,b,c) where:

a: is the current position of the object
b: is the position you want the object to go to
c: is the speed you want the object to go there (you should always multiply it by dt so the movement is framerate independent)

So if you do "every tick -> set sprite X position to lerp(sprite.x,100,2*dt) it will move the sprite horizontally until it gets to X=100, at 2*dt speed.
B
125
S
43
G
41
Posts: 849
Reputation: 28,260

Post » Tue Nov 08, 2016 2:33 pm

Ooooh it looks pretty easy
Ill try that as well
Thanks @andreyin !
B
8
S
2
Posts: 23
Reputation: 555


Return to How do I....?

Who is online

Users browsing this forum: Baidu [Spider], Zzarkz and 24 guests