Moving blocks back and forth

Get help using Construct 2

Post » Mon Jan 06, 2014 2:34 pm

Hello,

I need help in the method where there are two blocks on the screen and they move back and forth across the screen on contact with each other. This is being used as a trap that the player has to pass.

In code I would increment the X value until it reached a certain point and then I would decrement the value and then just repeat the process.

I can't see a way of doing this on construct 2. I tried a number of things like adding the bullet behaviour and have it bounce of the other block but that was too glitchy.

Any suggestions would be appreciated,
Thanks.
B
4
S
1
Posts: 15
Reputation: 455

Post » Mon Jan 06, 2014 3:25 pm

@ulysses 31

You could add the sine behavour to your objects.
B
51
S
16
G
9
Posts: 1,098
Reputation: 11,252

Post » Mon Jan 06, 2014 3:26 pm

If you'd like to do it the way you would code it, you could do something like this:

give the block a boolean forth

block is forth - block set x : block.x + 1
block is not forth - block set x : block.x -1
block compare x = 250 - block toggle boolean forth
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 » Tue Jan 07, 2014 12:24 pm

Thanks guys, that worked
B
4
S
1
Posts: 15
Reputation: 455


Return to How do I....?

Who is online

Users browsing this forum: dop2000 and 9 guests