dellos

Untitled

Jun 25th, 2013
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.22 KB | None | 0 0
  1. local function main()
  2.     local st = display.getCurrentStage()
  3.     local g = display.newGroup()
  4.     local re = display.newRect(g, 0, 0, 100, 50)
  5.     re:setReferencePoint( display.TopLeftReferencePoint )
  6.     re.x = 0; re.y = 0
  7.     g.x = 100 ;g.y = 100 ;
  8.  
  9.     local objs = {} ; g.objs = objs
  10.     local function create( id )
  11.         local id = id
  12.         local constx = 100/6
  13.         local consty = 50*0.5
  14.         local result = {}
  15.         if id == 2 then id = 3
  16.         elseif id == 3 then id = 5 end
  17.         result.center = {x = constx*id, y = consty}
  18.         return result
  19.     end
  20.     for i =1 , 3 do -- create 3 virtual obj in g, it just a center point in g coordination.
  21.         objs[i] = create(i)
  22.     end
  23.     local function setref( id )
  24.         g.xReference = objs[id].center.x
  25.         g.yReference = objs[id].center.y
  26.     end
  27.     setref(1);g.x = 100 ;g.y = 100 ;
  28.     g.rotation = 0
  29.     --print( g:localToContent(g.objs[1].center.x, g.objs[1].center.y))
  30.     g.rotation = 60 -- after rotation
  31.     --print( g:localToContent(g.objs[1].center.x, g.objs[1].center.y)) -- this line make bug
  32.                                        -- if remove comment
  33.     setref(2);g.x = 100 ;g.y = 100 ;
  34.    
  35.     local point = display.newCircle(0, 0, 5); point:setReferencePoint( display.CenterReferencePoint )
  36.     point.x = 100; point.y = 100
  37.     point:setFillColor(225, 0, 0)
  38. end
  39. main()
Advertisement
Add Comment
Please, Sign In to add comment