HELP converting from AS3 to LUA

hello, i wrote this in AS3 and was wondering if I could get help with this.

[code]

var angle:Number = Math.atan2(mouseX,mouseY-180)-Math.PI/2;
var xNew:Number = 20*Math.cos(angle);
var yNew:Number = -20*Math.sin(angle);[/code]

I tried this so far

local angle = Math.atan2(event.x,event.y-180)-Math.PI/2;  
  
local xNew = 20\*Math.cos(angle);  
local yNew = -20\*Math.sin(angle);  

I am using event.x and event.y because this will be inside a function that fires on “touch”

Thanks! [import]uid: 6500 topic_id: 9735 reply_id: 309735[/import]

Hi,

You’re close…but a couple things need to change…mainly, the “Math” needs to be “math” (note…all lowercase :slight_smile:

So it would be something like this…

local angle = math.atan2(event.x,event.y-180)-math.pi/2;  
  
local xNew = 20\*math.cos(angle);  
local yNew = -20\*math.sin(angle);  

Here’s a link to a lua math library tutorial…
http://lua-users.org/wiki/MathLibraryTutorial
[import]uid: 12700 topic_id: 9735 reply_id: 35477[/import]