Math formula to get new position coordinates?

Get help using Construct 2

Post » Mon Dec 29, 2014 1:55 am

Image

What I am trying to achieve is: When the player clicks on something, all the red balls will change their position to that represented by the yellow balls. And when the player clicks again, it changes its position back, and so on.

Let's say that the balls are 128 pixels in width and length, and the black line separating it from its new position is 16 pixels. What is the formula I would need to use if I wanted the red balls to go to the positions shown by the yellow balls? The black shape is made out of the same sprites, but each with an adjustment to its angle, so the angle can be easily obtained for the formula.

I am not that good in maths, so any help would be greatly appreciated.
B
45
S
23
G
31
Posts: 687
Reputation: 20,600

Post » Mon Dec 29, 2014 3:07 am

it should work with no math knowledge to if you use image points

Read this:
https://www.scirra.com/manual/63/image-points
Read this:
yeah, i really like to say that you should "Read this:"
B
12
S
5
Posts: 138
Reputation: 1,490

Post » Mon Dec 29, 2014 5:47 am

Hmm....I honestly never thought of using imagepoints, but if I use three image points and always maintain the correct angle for the ball, I think it just might work. TIme to try it out! Thanks!
B
45
S
23
G
31
Posts: 687
Reputation: 20,600

Post » Mon Dec 29, 2014 6:40 am

Or you could go the lazy route and just make an animation like [O ] [ O] pin it at the contour and on switch set the animation frames with abs(currentframe-1) for example - they will auto flip in one event.
B
19
S
6
G
6
Posts: 1,101
Reputation: 5,646

Post » Mon Dec 29, 2014 10:07 am

Thanks for the tip @Somebody. Right now the imagepoints work perfectly so I am sticking with it for now, but it is always good to learn new approaches and methods. Thanks!
B
45
S
23
G
31
Posts: 687
Reputation: 20,600


Return to How do I....?

Who is online

Users browsing this forum: dop2000, namaewayukidesu and 6 guests