Skip to content
2d Math Library for Corona SDK / Lua
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
demos
.gitignore
README.md
point.lua

README.md

point

2d Math Library for Corona SDK / Lua

Point is a 2d math library for Corona SDK or just plain ol' lua. It allows us to think of positions within corona as single units (points) vs independent x and y coordinates.

This is how we'd move an object along a vector without point library.

local speed = 5
local angle = 90
local angleRad = (math.pi * angle) / 180
local normalizedX = math.cos(angleRad)
local normalizedY = math.sin(angleRad)

-- move object
obj.x = obj.x + (speed*normalizedX)
obj.y = obj.y + (speed*normalizedY)

With the point library.

local speed = 5
local angle = 90

-- move object
local vector = point.newFromAng(90):multiply(speed)
obj.x, obj.y = point.newFromAddition(obj, vector):getPosition()

For examples check out the demo folder. For full documentation look at the wiki.

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.