How do I stop a sprite overlapping an object?

Get help using Construct 2

Post » Sat Feb 13, 2016 9:40 am

Hi,
I'm developing an iOS game, in that, there is a sprite in the form of a circle and a grey shaded box. The circle can be moved across the screen with the finger or mouse but I don't want the circle to overlap the grey box as shown in the below picture. Is there any way to do that. Please help.


http://prntscr.com/a2nhwe
B
24
S
7
Posts: 335
Reputation: 2,220

Post » Sat Feb 13, 2016 8:14 pm

This way ?

https://
drive.google.com/file/d/0B1SSuCVV8v74d0ZrUDJmaENDQWs/view?usp=sharing
B
33
S
18
G
27
Posts: 2,441
Reputation: 20,346

Post » Thu Feb 18, 2016 8:11 pm

@99Instances2Go Not exactly but it is close to what I asked. Thank you so much for the example. Learned new things.

The problem was solved.
B
24
S
7
Posts: 335
Reputation: 2,220

Post » Tue Mar 01, 2016 10:03 pm

Hi,
I could solve this problem using one finger. Now, I want the same to happen using two fingers which brings two circles. I defined the same code of one finger for two fingers as well as but I'm not sure where it went wrong, only the circle with one finger is working while the finger with second circle isn't working.

Could you please help me with this? @99Instances2Go
B
24
S
7
Posts: 335
Reputation: 2,220

Post » Wed Mar 02, 2016 4:42 pm

If we had a look at your capx it would be an easy fix. Have you tried duplicating your code used for 1 finger and just simply change the instances as needed for your 2nd circle ???
B
9
S
3
Posts: 56
Reputation: 801

Post » Wed Mar 02, 2016 8:25 pm

@fr0z3n Yes, I did. Only one circle with finger 1 is working.

Here is the code I used for one finger,
I created a transparent barricade 1 to make the Circle1 to stop at that position
if -> Circle 1 is overlapping Barricade1
-> is in touch -> Circle 1 set position to (Touch.X (0), Circle.Y)

I created barricade 2 to set the Circle1 to position to the finger1. When the finger1 touches the barricade 2, Circle1 will be moving along with finger1.
if -> is in touch
-> touch is touching Barricade2 -> Circle 1 set position to (Touch.X (0), Touch.Y (0))


I used the same technique for Circle2 with finger2 but it is not working, I don't know why.

if -> Circle 2 is overlapping Baricade1
-> is in touch -> Circle 2 set position to (Touch.X (1), Circle.Y)

if -> is in touch
-> touch is touching Baricade2 -> Circle 2 set position to (Touch.X (1), Touch.Y (1))
B
24
S
7
Posts: 335
Reputation: 2,220

Post » Wed Mar 02, 2016 8:29 pm

upload your capx so i can look at it. not sure whats going on with out seeing the capx
B
9
S
3
Posts: 56
Reputation: 801

Post » Thu Mar 03, 2016 11:52 pm

@fr0z3n Here is the .capx, please check.

https://app.box.com/s/4ijc63wc9ug4yxxqrdf3je4iqit9evxg
B
24
S
7
Posts: 335
Reputation: 2,220

Post » Sat Mar 05, 2016 4:05 pm

@fr0z3n Did you get the chance to check the .capx?
B
24
S
7
Posts: 335
Reputation: 2,220

Post » Fri Mar 11, 2016 9:01 am

Can somebody help me on this?
B
24
S
7
Posts: 335
Reputation: 2,220

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 8 guests