Here’s just a quick look at how you could start making your own graphic layout tool — so you don’t have to place graphics on the iPhone screen (or simulator) by trial and error.
This is NOT a full blown app, but I think I’ll be using this little chunk of code in my next project.
The video runs right about five minutes and the small chunk of code that does the magic is down below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
-- Project: Asset Layout Test -- From http://GameDevNation.com local movieclip = require("movieclip") display.setStatusBar(display.HiddenStatusBar) local sky = display.newImage("sky.jpg", 0, 0) local myPics = { "grass.png", "bamboo.png", "palm.png" } local pieces = {} local function dropPiece() for x = 1, #myPics do local pname = pieces[x].thename local px = pieces[x].x local py = pieces[x].y local codestr = "local " .. pname:sub(0, -5) .. " = display.newImage(\"" .. pname .. "\", " .. px .. ", " .. py .. ")" print(codestr) end end local i = 1 for i = 1, #myPics do pieces[i] = movieclip.newAnim{ myPics[i] } pieces[i].thename = myPics[i] pieces[i]:setDrag{ drag = true, onRelease = dropPiece} pieces[i]:setReferencePoint(display.TopLeftReferencePoint) pieces[i].x = i * 30 pieces[i].y = 20 end |