Right, I have 2 objects in a side scrolling game.
what I would like to do is add a counter on screen showing the distance between the two objects (player) and (enemy).
I currently have this code acting as the distance section:
– distance
function distance(enemy,player)
return math.sqrt((enemy.x-player.x)^2)
end
– distance text
local distance_text = display.newText("", 0, 0, native.systemFont, 14)
distance_text.anchorX = 0,0
distance_text.anchorY = 0,0
distance_text:setTextColor(0,0,0)
end
however it only displays whatever is the “”
that code is probably completely wrong but…
how do I get it to dynamically show the distance between the two objects?
would it be some sort of onEveryFrame thing?
thanks in advance