Skip to content

Instantly share code, notes, and snippets.

@omidahourai
Created June 27, 2013 17:18
Show Gist options
  • Save omidahourai/5878372 to your computer and use it in GitHub Desktop.
Save omidahourai/5878372 to your computer and use it in GitHub Desktop.
function character:enterFrame(event)
--Get speed and angle
local speed = self.speed or 0
local angle = self.angle or 0
--Claculate x-y distances
local xval = math.cos(angle) * speed
local yval = -math.sin(angle) * speed
--Move the character's group/ sprite/ image
self.group:translate(xval, yval)
end
Runtime:addEventListener('enterFrame', character)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment