Easing between a set number of locations

Get help using Construct 2

Post » Wed Oct 29, 2014 12:55 am

Hi there,

I'm doing a simple project that allows me to fight things falling down. http://part12studios.com/temp/Games/BoxNinja1/

the thing is that I want the 5 fixed positions to be something that "tweens". I have used tweenlite before but i'm not sure that's really the best way to do this. Feels a bit heavy handed for what seems like a relatively simple request to move between positions 1 2 3 4 and 5. The keyboard is what moves it.. but the move should still be very snappy but my current events do flat +130 and -130 pixels per move left or right till they hit the far left or right ranges.

I thought lerp would be appropriate, but it's not working well for me. So it's either the wrong approach or i'm doing it wrong.

Thanks!
Caleb
B
56
S
9
G
1
Posts: 938
Reputation: 6,458

Post » Wed Oct 29, 2014 8:17 am

You could try the moveto behaviour plugin or the litetween like you said..
These are probably the easiest methods..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Wed Oct 29, 2014 12:45 pm

Okay good to know I will try that out and see how it goes thanks for the confirmation :-)
B
56
S
9
G
1
Posts: 938
Reputation: 6,458

Post » Wed Oct 29, 2014 3:31 pm

You can always lerp the positions. Use an variable to store the target x position for the box (lets say "goToX") and when you press the left/right arrow keys subtract/add to this variable the 130 pix offset (you'll need to find a way to limit me minimum/maximum x position). Then, add an event that does the following:

every tick-----> Box | set X position to lerp(self.X, goToX, t)

where t is a number between 0 and 1. The closest to 1, the "snappiest" it will get.
composer - multimedia artist
www.eli0s.com/en/
B
68
S
26
G
4
Posts: 1,146
Reputation: 9,649

Post » Wed Oct 29, 2014 8:05 pm

B
82
S
39
G
15
Posts: 982
Reputation: 16,712

Post » Thu Oct 30, 2014 3:03 pm

@justifun thanks! :) That's great to see.
B
56
S
9
G
1
Posts: 938
Reputation: 6,458


Return to How do I....?

Who is online

Users browsing this forum: Darth Crusher, zsoldiers and 6 guests