Advertisement
lvs

Reference Point -> Anchor Point

lvs
Nov 18th, 2013
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.91 KB | None | 0 0
  1. -- Set reference point
  2. function _M.setRP (object, ref_point)
  3.     ref_point = string.lower(ref_point)
  4.     if ref_point == 'topleft' then
  5.         object.anchorX, object.anchorY = 0, 0
  6.     elseif ref_point == 'topright' then
  7.         object.anchorX, object.anchorY = 1, 0
  8.     elseif ref_point == 'topcenter' then
  9.         object.anchorX, object.anchorY = 0.5, 0
  10.     elseif ref_point == 'bottomleft' then
  11.         object.anchorX, object.anchorY = 0, 1
  12.     elseif ref_point == 'bottomright' then
  13.         object.anchorX, object.anchorY = 1, 1
  14.     elseif ref_point == 'bottomcenter' then
  15.         object.anchorX, object.anchorY = 0.5, 1
  16.     elseif ref_point == 'centerleft' then
  17.         object.anchorX, object.anchorY = 0, 0.5
  18.     elseif ref_point == 'centerright' then
  19.         object.anchorX, object.anchorY = 1, 0.5
  20.     elseif ref_point == 'center' then
  21.         object.anchorX, object.anchorY = 0.5, 0.5
  22.     end
  23. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement