Get the distance?

I would like to get the distance in pixels from the center of a circle to several other pixels on the screen but I don´t know how to do it.
Is there anybody who can help me?

//Maholm [import]uid: 5717 topic_id: 1731 reply_id: 301731[/import]

You can use the x,y properties of display objects to compute the distance between them using some simple math. By default the x,y values are referenced to the center of the objects. This site should help you compute the distance: http://www.1728.com/pythgorn.htm

-Tom [import]uid: 7559 topic_id: 1731 reply_id: 5112[/import]

That is easy, you should search for 2D vector math in the net. Anyway:

[lua]local mSqrt = math.sqrt

local getDistance = function(x1,y1,x2,y2)
return mSqrt( ( (x2-x1)*(x2-x1) ) + ( (y2-y1)*(y2-y1) ) )
end[/lua]

Cheers
Michael Hartlef

http://www.whiteskygames.com
http://www.twitter.com/mhartlef

[import]uid: 5712 topic_id: 1731 reply_id: 5116[/import]