Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function main()
- local st = display.getCurrentStage()
- local g = display.newGroup()
- local re = display.newRect(g, 0, 0, 100, 50)
- re:setReferencePoint( display.TopLeftReferencePoint )
- re.x = 0; re.y = 0
- g.x = 100 ;g.y = 100 ;
- local objs = {} ; g.objs = objs
- local function create( id )
- local id = id
- local constx = 100/6
- local consty = 50*0.5
- local result = {}
- if id == 2 then id = 3
- elseif id == 3 then id = 5 end
- result.center = {x = constx*id, y = consty}
- return result
- end
- for i =1 , 3 do -- create 3 virtual obj in g, it just a center point in g coordination.
- objs[i] = create(i)
- end
- local function setref( id )
- g.xReference = objs[id].center.x
- g.yReference = objs[id].center.y
- end
- setref(1);g.x = 100 ;g.y = 100 ;
- g.rotation = 0
- --print( g:localToContent(g.objs[1].center.x, g.objs[1].center.y))
- g.rotation = 60 -- after rotation
- --print( g:localToContent(g.objs[1].center.x, g.objs[1].center.y)) -- this line make bug
- -- if remove comment
- setref(2);g.x = 100 ;g.y = 100 ;
- local point = display.newCircle(0, 0, 5); point:setReferencePoint( display.CenterReferencePoint )
- point.x = 100; point.y = 100
- point:setFillColor(225, 0, 0)
- end
- main()
Advertisement
Add Comment
Please, Sign In to add comment