How do I properly move items down as they pile up?

Just started using Construct 2? Post your questions here

Post » Thu Nov 17, 2016 12:52 am

Hello everyone!

I'm trying to achieve something, and after searching for some ideas here, found nothing (or did not know how to properly search :oops: )

I'm working on a game concept in which objects pile on top of others. When they reach a certain object (which I already detect by collision with an invisible sprite), I want the object pile to move down smoothly by a certain amount of pixels, so the objects never reach the top of the screen.

Which is a proper way of making it?

Thanks in advance for any help.

Marcelo
B
9
S
3
Posts: 40
Reputation: 780

Post » Thu Nov 17, 2016 3:26 am

That's a really good question.
There's probably lots of ways to do it, but I played around and found 2 possibilities. You can download my capx here.

Press "space" to run a cycle. The orange blocks use the sine behavior, and the blue ones use bullet. Neither method gets you the exact position you want, especially if the framerate varies, so both sets of blocks set their positions explicitly when a cycle ends.

If I only had these 2 to choose between, I would probably go with sine. You might be able to play with the "period" settings and the duration of the timer to get motion closer to exactly what you want.

P.S. Google drive is a little weird for capx files. When the screen comes up, just click the download button at the top.
Eh, Steve!
B
113
S
54
G
13
Posts: 112
Reputation: 16,090

Post » Thu Nov 17, 2016 5:00 pm

Thanks @calebbennetts! It helped a lot. I've used the sine approach, as you suggested - now I've got to polish the way items behave when piled up, so they won't fall due to ground moving down 8)
B
9
S
3
Posts: 40
Reputation: 780


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 1 guest