
Share Your Code
Browse Code
- All (915)
-
(95)
-
(87)
-
(45)
-
(4)
-
(42)
-
(136)
-
(22)
-
(41)
-
(13)
-
(66)
-
(153)
-
(211)
Make outside edge walls module
This is hardly groundbreaking.
It is a faster and easier way to make outside edges.
I heard something about a corona update involving modules so this may be broken. meh.
save as "walls.lua"
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | module(..., package.seeall) local W = _W --display.contentWidth local H = _H --display.contentHeight function make() wallGroup = display.newGroup() local background = display.newRect(0,0,W,H) background:setFillColor(40,40,40) local wall = {} wall[1] = display.newRect(0,0,0,H) wall[2] = display.newRect(0,0,W,10) wall[3] = display.newRect(W,0,0,H) wall[4] = display.newRect(0,H,W,0) for i = 1, 4 do physics.addBody(wall[i], "static", {bounce = 0}) wallGroup:insert(wall[i]) wall[i].id = "wall" end end |
Called using
1 2 | walls = require("walls") walls.make() |
Replies
Posted on Tue, 2012-03-06 00:30
#2
hey anddrewscott,
one question... If u load the module and u r using storyboard, how do u clean up when going on to next storyboard scene?
Just "wallGroup:removeSelf();" and everything cleans up?
Thank you.
Nick
Ha, no way! this is too cool! thanks Andrew!!!
Much appreciated,
J.K.