Hi,
I am trying to create a function where an eye is looking at the direction where the player taps.
i am not a mathematic genius so some help would be great!
display.newCircle( 200, 200, 110 )
local object = display.newCircle( 200, 290, 20 )
object:setFillColor(128,128,128)
local originX,originY = 200,200 -- Center position of the circle
local radius = 100 -- Radius of the circle
local cosCounter = 0 -- position of the object thats going to move around the circle
-- each lap takes math.pi\*2
function enterFrame()
object.x = math.sin(cosCounter)\*radius + originX
object.y = math.cos(cosCounter)\*radius + originY
cosCounter = cosCounter + -0.3 -- speed of the object ( + is clockwise )
end
function check( event )
local playerangle = math.floor(180-math.atan2(event.x - object.x, event.y - object.y)\*(180/math.pi))
object.x = ??
object.y = ??
end
--Runtime:addEventListener("enterFrame",enterFrame)
Runtime:addEventListener("tap", check)
Regards, Joakim [import]uid: 81188 topic_id: 21645 reply_id: 321645[/import]
[import]uid: 52491 topic_id: 21645 reply_id: 86055[/import]