How do I get an X & Y position relative to an object.

Get help using Construct 2

Post » Fri Feb 06, 2015 9:33 am

I'm trying to figure out how to get a value.

I have an object at position X 100 . Y 100
and another object 20 pixels above and 30 pixels to the left. X 70 . Y 80

How do i get the relative value of -30 and -20 from these two?

I want to return the difference between two XY positions.

Just can't figure it out.
Follow my progress on Twitter
or in this thread Archer Devlog
B
31
S
14
G
16
Posts: 920
Reputation: 11,462

Post » Fri Feb 06, 2015 9:55 am

Sprite1.X-(Sprite1.X-Sprite2.X)?
B
15
S
4
G
1
Posts: 286
Reputation: 1,988

Post » Fri Feb 06, 2015 10:40 am

relativePositionX = object.x - anotherObject.x
relativePositionY = object.y - anotherObject.y

If you want distance then relativeDistance = distance(object.x,object.y,anotherObject.x,anotherObject.y)
B
12
S
6
G
2
Posts: 99
Reputation: 1,727


Return to How do I....?

Who is online

Users browsing this forum: Baidu [Spider], PauloMarcio and 2 guests