Distance between two points problem.

Discussion and feedback on Construct 2

Post » Fri Sep 05, 2014 4:42 pm

Hi guys,

I expect the player to be able to touch a sprite, drag and release to determine the direction and force to launch the sprite. So the further away I drag the greater the force in the direction of the touch end.

However, I find that the force seems to be inconsistent to if I drag left and release compared to when I drag right and release.

I have attached the capx so you friendly people can help my find out what I've missed.

My thoughts at the moment at potential problems are maybe different co-ordinate systems or taking touch co-ordinates incorrectly or at the wrong time? Thoughts?

Kind regards,
Wyrm
You do not have the required permissions to view the files attached to this post.
ImageImageImageImageImage
B
19
S
5
G
1
Posts: 614
Reputation: 2,542

Post » Fri Sep 05, 2014 5:45 pm

A few more details.

-Dragging from the sprite to top left produces small distances than dragging to the top.
-Sometimes the sprite can get stuck. Just refresh and try again.
ImageImageImageImageImage
B
19
S
5
G
1
Posts: 614
Reputation: 2,542

Post » Fri Sep 05, 2014 5:52 pm

and a general observation that i noticed is the further right the sprite is in the scene the greater the resulting distance.
ImageImageImageImageImage
B
19
S
5
G
1
Posts: 614
Reputation: 2,542

Post » Fri Sep 05, 2014 6:05 pm

Ok guy, I post you my version of what your are expecting.
I guess you looking too complicated ^^

Hope it help :)
You do not have the required permissions to view the files attached to this post.
http://armaldio.xyz - Image - Join now our Discord Server ;) - https://discord.gg/0eLPLj96B4tUr1D3
B
56
S
16
G
1
Posts: 249
Reputation: 5,721

Post » Fri Sep 05, 2014 6:19 pm

Thanks you're a star. So essentially you used absolute position of the touch on start and again at touch end. Where absolute refers to the current position of a touch over the canvas area. So I may use this as it side steps the problem.

HOWEVER, I am still interested in why my original doesn't work to further my knowledge. Anybody have any ideas?
ImageImageImageImageImage
B
19
S
5
G
1
Posts: 614
Reputation: 2,542

Post » Fri Sep 05, 2014 7:05 pm

Maybe just a little error ^^
When you make this action :

Code: Select all
Set GobalDistance to distance(Player.X,Touch.X,Player.Y,Touch.Y)


If you read carrefully the documentation, you see :

distance(x1, y1, x2, y2) Calculate distance between to points


So you probably just have to invert y1 and x2 in you expression :

Code: Select all
distance(Player.X,Player.X,Touch.Y,Touch.Y)


And it solve the problem ô/

PS:After that, for me the block never get stuck another time O_o
http://armaldio.xyz - Image - Join now our Discord Server ;) - https://discord.gg/0eLPLj96B4tUr1D3
B
56
S
16
G
1
Posts: 249
Reputation: 5,721

Post » Fri Sep 05, 2014 7:16 pm

ah ok, that explains it! I assumed it was the same as the math order!

Image

Good spot! Thanks again!
ImageImageImageImageImage
B
19
S
5
G
1
Posts: 614
Reputation: 2,542


Return to Construct 2 General

Who is online

Users browsing this forum: Google [Bot] and 8 guests