Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local localGroup = display.newGroup()
- local shapeGroup = display.newGroup()
- local shapesPrevArray = {}
- local shapeWidthCounter = nil
- local prevCurrentLevel = currentLevel --set the gobals to locals once they're loaded in to save resources.
- local prevCurrentLevelPack = currentLevelPack --set the gobals to locals once they're loaded in to save resources.
- local levelPacks = require "levelpacks"
- shapeWidthCounter = 0
- function new()
- for i, child in ipairs(levelPacks[prevCurrentLevelPack][prevCurrentLevel].shapes) do --iterates through information in levelpacks module.
- if levelPacks[prevCurrentLevelPack][prevCurrentLevel].shapes[i].type == "rectangle" then --if the shapes are rectangular then...
- prevShape = display.newRect(levelPacks[prevCurrentLevelPack][prevCurrentLevel].shapes[i].x, --assigns the information to the shape display object.
- levelPacks[prevCurrentLevelPack][prevCurrentLevel].shapes[i].y,
- levelPacks[prevCurrentLevelPack][prevCurrentLevel].shapes[i].width,
- levelPacks[prevCurrentLevelPack][prevCurrentLevel].shapes[i].height)
- prevShape.xScale = 0.4
- prevShape.yScale = 0.4
- prevShape.isVisible = false
- end
- shapeWidthCounter = prevShape.width + shapeWidthCounter + 15 -- use this for the scroller width, add 15 to every space between shapes.
- table.insert(shapesPrevArray, prevShape) -- inserts it into the array we created earlier.
- end
- print (shapeWidthCounter)
- local p = display.newRect(0, 0, shapeWidthCounter, 50)
- p.alpha = 0.5
- p.x = 200
- p.y = 41 --from top of screen
- shapeGroup:insert(p)
- local pCurrentShapeCounter = 1
- for col = 1, levelPacks[prevCurrentLevelPack][prevCurrentLevel].ammount do
- shapesPrevArray[pCurrentShapeCounter].x = 15 + shapesPrevArray[pCurrentShapeCounter].width
- shapesPrevArray[pCurrentShapeCounter].y = 41
- shapesPrevArray[pCurrentShapeCounter].isVisible = true
- pCurrentShapeCounter = pCurrentShapeCounter + 1
- end
- shapeGroup.x = -40
- localGroup:insert(shapeGroup)
Add Comment
Please, Sign In to add comment