Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- The overall group (this could represent the scene.view in storyboard)
- local sceneGroup = display.newGroup()
- -- Your group, where everything resides
- local gameGroup = display.newGroup()
- sceneGroup:insert( gameGroup )
- -- Create some items within it
- for i = 1, 10 do
- local rect = display.newRect( gameGroup, math.random( 0, 430 ), math.random( 0, 270 ), 50, 50 )
- end
- -- My first quick attempt at the 'change origin of groups'
- local function setGroupOrigin( group, x, y )
- -- Store parent
- local parentGroup = group.parent
- -- Create in-between group and offset
- local topGroup = display.newGroup()
- local bottomGroup = display.newGroup()
- group.parent:insert( topGroup )
- topGroup:insert( bottomGroup )
- bottomGroup:insert( group )
- topGroup.x = x
- topGroup.y = y
- bottomGroup.x = -x
- bottomGroup.y = -y
- -- Return the new group
- return topGroup, bottomGroup
- end
- -- Change the origin of the group to the middle of the
- --gameGroup = setGroupOrigin( gameGroup, 240, 160 )
- -- Now set it rotating
- local function enterFrame( event )
- gameGroup.rotation = gameGroup.rotation + 5
- gameGroup.xScale = 1 + math.random( -10, 10 ) / 100
- gameGroup.yScale = 1 + math.random( -10, 10 ) / 100
- end
- Runtime:addEventListener( "enterFrame", enterFrame )
Add Comment
Please, Sign In to add comment