How do I Stop on Collision

Get help using Construct 2

Post » Mon May 05, 2014 5:18 pm

I am building a game like "unblock me", I have tried to use the Solid, Collision, 8 direction methods but can't seem to get the blocks(sprite) that are moving horizontal and vertical to stop before they collide. Can anyone point me in the right direction on how to make a sprite stop once it has encountered another object.

Thanks
B
4
Posts: 5
Reputation: 465

Post » Mon May 05, 2014 7:30 pm

Can you provide a capx?
composer - multimedia artist
www.eli0s.com/en/
B
69
S
27
G
6
Posts: 1,146
Reputation: 10,379

Post » Mon May 05, 2014 8:11 pm

hey thanks... the idea is for the blocks to stop once they collide and stay in the same place, what happens is that either block starts to shift to the sides... they should stay in the path. This is a plain version I've started over with the basic sprites..

Tony
You do not have the required permissions to view the files attached to this post.
B
4
Posts: 5
Reputation: 465

Post » Tue May 06, 2014 12:48 am

This is a way to do it with two blocks. I am afraid though that when you will add more blocks the logic will be much more complicated, you have to figure out a way to do proper picking of which block is neighboring which, and that is way over my abilities.

Maybe arrays will be the right way to approach this, but, as I never get bored to mention in every occasion I get, I don't understand arrays... :oops:
You do not have the required permissions to view the files attached to this post.
composer - multimedia artist
www.eli0s.com/en/
B
69
S
27
G
6
Posts: 1,146
Reputation: 10,379

Post » Tue May 06, 2014 11:00 am

Using events that disable the drag and drop behavior of the object, stops the object. But it'll also make it immovable afterwards. So you have to add events that will re-enable the drag and drop again.

Not sure if this will work but try this anyways.

Make an event where the conditions are
-Gold bar is above the brick bar(that is gold.Y is less than brick.Y as Y decreases as you go up)
-Brick is overlapping gold(brick comes in contact with gold, similar to collision)
Make an action where it disables brick drag and drop.

Now this will stop the brick in it's tracks but you'll notice you cant move it anymore.

Now this might only work if you have preview over lan to your phone cause you'll have to use the touch objects accelerometer option. By seeing if you swipe up or down you'll get positive or negative values for the accelerometer value.

So say if you swipe up you get a negative Y accelerometer value (i'm not sure if it's negative or posotive, you'll have to find it out) So what you can do is add the condition(to the one i already mentioned) 'touch Y accelerometer value is less than 0 i.e negative. So now if it works it'll still disable movement if you swipe up and the gold is above brick

Now to reenable movement , you make another action where conditions are
-Gold above brick or Gold is not right below brick
-Brick is overlapping gold ( if it is already overlapping )
-touch Y accelerometer is greater than zero i.e positive
And the event is, enable drag and drop for brick

So now if this method actually works, when you swipe down and the gold bar is not below the brick, it should re-enable movement.
Touch accelerometer does not work on desktop. So i'm not sure if this will work at all. Sorry

Obviously putting Gold above brick conditions is not the only one, if the gold is to the far right and the brick is to the far left , it'll still disable movement even tho gold is not right above brick, so you have to add other conditions like comparing distance between the two.

Please look around the tutorials, search for keywords, cause there will definitely be a more simpler and working answer.
B
18
S
5
Posts: 144
Reputation: 1,616

Post » Tue May 06, 2014 11:43 am

thanks to both of you for your help!
B
4
Posts: 5
Reputation: 465

Post » Wed Aug 02, 2017 6:13 am

pandy ? do you have a capx file ?
B
6
Posts: 12
Reputation: 276

Post » Wed Aug 02, 2017 7:35 am

how about not going outside the box ??
B
6
Posts: 12
Reputation: 276

Post » Wed Aug 02, 2017 7:38 am

@nikkdj

This thread is over 3 years old - the OP was resolved a long time ago.
If your vision so exceeds your ability, then look to something closer.
Moderator
B
137
S
31
G
87
Posts: 5,557
Reputation: 60,458

Post » Wed Aug 02, 2017 10:36 am

@zenox98
do you have a copy of a solution ? or example ? capx?
B
6
Posts: 12
Reputation: 276

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 34 guests