How do I make a object go up and down from behind

Get help using Construct 2

Post » Sun Mar 29, 2015 8:08 pm

Hi,

I am trying to figure out how to make a spike come out from behind a wall tile repeatedly, it comes down then goes back up behind the wall tile and then does it again and again like a loop. I have tried all variants of movement, sine, 8 direction, bullet etc... either I am doing something wrong with those or not doing it correctly at all as I could not get it working. If someone could show me in contstruct 2 via an example file or give me specific instructions on how to achieve this, would be great?
B
10
S
3
Posts: 109
Reputation: 1,080

Post » Sun Mar 29, 2015 8:12 pm

well define the object as a sprite.. then add the sine behaviour, and change the movement to being vertical.

then using layers, put it behind another object so that it is not visible when it is "down" and then it pokes up.
B
7
S
3
G
1
Posts: 184
Reputation: 1,352

Post » Sun Mar 29, 2015 8:31 pm

ok thanks will give it a try.
B
10
S
3
Posts: 109
Reputation: 1,080

Post » Sun Mar 29, 2015 8:44 pm

ok so I defined my object as a sprite which I was not doing before. Added sine movement to vertical. Do not get what you mean about the layers exactly. Anyway it does not work I need it to only go up and down only by a few pixels, using sine I can't figure out how you define such a thing?
B
10
S
3
Posts: 109
Reputation: 1,080

Post » Sun Mar 29, 2015 9:11 pm

Hey, here's a little example with spikes that goes underground endlessly. I set up three types of spikes, just changing the "wave" property of the Sine behavior. Note that the "sawtooth" wave equation is probably what you want. Just check the collision with the sprite and players/entities and do as you like. You can add randomized values to the Sine behavior if you want it to be less predictable. The "width/height" parameters of the "movement" property could be good too as it scales the objects. The magnitude is how large is the movement, in pixels or percents.

You can see that the spikes are on the "behind" layer, with "tilemap" layer in front.

This is a simple way to do that. You can also have custom movement by writing your own and changing state and position of the spike object every tick or less. For example you can add a "active" bolean variable to the sprite and set it true only while it's rising from the ground, setting false while retracting. When you're checking for collisions you can also check for if the spike is active or not. If it is, hurt the player, if not, the player can walk upon it.

Hope this helps if you haven't already find a solution.

https://www.dropbox.com/s/9xusp6gx0y00e0u/spikes.capx?dl=0

Cheers

Nabu
B
14
S
4
Posts: 112
Reputation: 1,287

Post » Mon Mar 30, 2015 4:45 pm

The only way I have figured out how to achieve this is by changing my tiles, where I only use one I now use two which solves the problem I am having. Thanks for your help!
B
10
S
3
Posts: 109
Reputation: 1,080


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 33 guests