I’ve been trying to change my director into storyboard and failed and went back to director. So I need help for this code
[code] module(…, package.seeall)
– Main function - MUST return a display.newGroup()
function new()
local localGroup = display.newGroup()
local physics = require (“physics”)
physics.start()
–physics.setDrawMode(“hybrid”)
physics.setGravity(0,0)
require( “ice” )
local ui = require(“ui”)
local function powertwin ()
twinb = loadFile (“twinb.txt”)
if twinb == “empty” then
twinb = 1
saveFile(“twinb.txt”, twinb)
end
end
powertwin()
local dis = 0
local Life = 100
local kil = 0
local amount = 0
great = false
local bank = ice:loadBox( “bank” )
local bankText = bank:retrieve(“total”)
local bk = display.newImageRect(“bk.png”, 480, 320)
bk.x = 240
bk.y = 160
localGroup:insert(bk)
local distance = display.newText(“m:0”, 30, 10,“Arial”, 18)
localGroup:insert(distance)
local health = display.newText(“Health: 100”, 10, 40,“Arial”, 18)
localGroup:insert(health)
local highText = display.newText("", 0,0,“Arial”,22)
highText.x = display.contentWidth/2
highText.y = 160
localGroup:insert(highText)
local baseline = 315
local sky1 = display.newImage (“road.png”)
sky1:setReferencePoint(display.CenterLeftReferencePoint)
sky1.x = 0
sky1.y = baseline - 20
localGroup:insert(sky1)
local sky2 = display.newImage (“road.png”)
sky2:setReferencePoint(display.CenterLeftReferencePoint)
sky2.x = 480
sky2.y = baseline - 20
localGroup:insert(sky2)
local sky3 = display.newImage (“broken city.png”)
sky3:setReferencePoint(display.CenterLeftReferencePoint)
sky3.x = 90
sky3.y = baseline - 100
localGroup:insert(sky3)
local sky4 = display.newImage (“broken city.png”)
sky4:setReferencePoint(display.CenterLeftReferencePoint)
sky4.x = 480
sky4.y = baseline - 100
localGroup:insert(sky4)
local sky5 = display.newImage (“broken city.png”)
sky5:setReferencePoint(display.CenterLeftReferencePoint)
sky5.x = -70
sky5.y = baseline - 100
localGroup:insert(sky5)
local tPrevious = system.getTimer()
local function move(event)
local tDelta = event.time - tPrevious
tPrevious = event.time
local xOffset = ( 0.1 * tDelta )
sky1.x = sky1.x - xOffset
sky2.x = sky2.x - xOffset
sky3.x = sky3.x - xOffset
sky4.x = sky4.x - xOffset
sky5.x = sky5.x - xOffset
if (sky1.x + sky1.contentWidth) < 0 then
sky1:translate( 480 * 2, 0)
end
if (sky2.x + sky2.contentWidth) < 0 then
sky2:translate( 480 * 2, 0)
end
if (sky3.x + sky3.contentWidth) < 0 then
sky3:translate( 480 * 2, 0)
end
if (sky4.x + sky4.contentWidth) < 0 then
sky4:translate( 480 * 2, 0)
end
if (sky5.x + sky5.contentWidth) < 0 then
sky5:translate( 480 * 2, 0)
end
end
Runtime:addEventListener( “enterFrame”, move )
local box = display.newRect(30, 30, 30, 30)
localGroup:insert(box)
local heli = display.newImageRect(“helicopter.png”,120, 80 )
heli.x = 50
heli.y = 100
heli.hit = “heli”
localGroup:insert(heli)
physics.addBody(heli,{bounce = 0, radius = 20})
local wall = display.newRect(-10, 0, 10, 320)
wall.hit = “wall”
localGroup:insert(wall)
physics.addBody(wall ,“static”)
local wall2 = display.newRect(300, 0, 10, 320)
wall2.hit = “wall2”
localGroup:insert(wall2)
physics.addBody(wall2 ,“static”)
local left = display.newRect(30, 220, 30, 30)
localGroup:insert(left)
local right = display.newRect(100, 220, 30, 30)
localGroup:insert(right)
local down = display.newRect(65, 260, 30, 30)
localGroup:insert(down)
local up = display.newRect(65, 180, 30, 30)
localGroup:insert(up)
local function shoot (event)
if event.phase == “release” then
if tonumber(twinb) == 2 then
local bullet = display.newImageRect(“bullet.png”, 10, 10)
bullet.x = heli.x + 40
bullet.y = heli.y
bullet.hit = “bullet”
bullet.isFixedRotation = true
transition.to (bullet, {time = 2000, x=550})
physics.addBody (bullet, {bounce=0.6})
localGroup:insert(bullet)
bullet:addEventListener(“collision”, bullet)
function bullet:collision (event)
if event.other.hit ~= “heli” then
bullet:removeSelf()
end
end
elseif tonumber(twinb) == 1 then
local twin = display.newImageRect(“bullet.png”, 10, 10)
twin.x = heli.x + 40
twin.y = heli.y
twin.hit = “twin”
twin.isFixedRotation = true
transition.to (twin, {time = 2000, x=550})
physics.addBody (twin, {bounce=0.6})
localGroup:insert(twin)
local twin2 = display.newImageRect(“bullet.png”, 10, 10)
twin2.x = heli.x + 40
twin2.y = heli.y + 15
twin2.hit = “twin”
twin2.isFixedRotation = true
transition.to (twin2, {time = 2000, x=550})
physics.addBody (twin2, {bounce=0.6})
localGroup:insert(twin2)
twin:addEventListener(“collision”, twin)
function twin:collision (event)
if event.other.hit ~= “heli” then
twin:removeSelf()
twin2:removeSelf()
end
end
end
end
end
ButtonA = ui.newButton{
default = “buttonoverA.png”,
over = “buttonA.png”,
x = 360,
y = 280,
onEvent = shoot,
}
localGroup:insert(ButtonA)
local function enemies (event)
local enem1 = display.newRect(0, 0, 40, 40)
enem1.y = math.random(40, 280)
enem1.x = 500
enem1.isFixedRotation = true
transition.to (enem1, {time = 5000, x=-50})
physics.addBody (enem1, {bounce=0.6})
enem1.hit = “enem1”
enem1.hits = 0
localGroup:insert(enem1)
enem1:addEventListener(“collision”, enem1)
function enem1:collision (event)
if event.other.hit == “twin” then
enem1.hits = enem1.hits + 1
if enem1.hits > 2 then
amount = 1
bank:increment( “total”, amount )
display.remove(enem1)
enem1 = nil
end
end
if event.other.hit == “bullet” then
enem1.hits = enem1.hits + 1
if enem1.hits > 2 then
amount = 1
bank:save()
bank:increment( “total”, amount )
display.remove(enem1)
enem1 = nil
end
end
if event.other.hit == “wall” then
display.remove(enem1)
end
if event.other.hit == “heli” then
display.remove(enem1)
Life = Life - 1
health.text = “Health:”… Life
enem1 = nil
end
end
local badbull = display.newRect(0,0, 20, 20)
badbull.x = enem1.x - 30
badbull.y = enem1.y
badbull.isFixedRotation = true
transition.to (badbull, {time = 3000, x=-50})
physics.addBody (badbull, {bounce=0.6})
localGroup:insert(badbull)
badbull.hit = “badbull”
badbull:addEventListener(“collision”, badbull)
function badbull:collision (event)
if event.other.hit == “wall” then
display.remove(badbull)
badbull = nil
end
if event.other.hit == “heli” then
display.remove(badbull)
Life = Life -1
health.text = “Health:”… Life
badbull = nil
end
end
end
timer1 = timer.performWithDelay(2000, enemies, -1)
local motionx = 0 --X Motion
local motiony = 0 – Y Motion
local speed = 5 – Speed
local function stop (event)
if “ended” == event.phase then
motionx = 0
motiony = 0
end
end
Runtime:addEventListener(“touch”, stop )
local function moveship (event)
heli.x = heli.x + motionx
heli.y = heli.y + motiony
end
Runtime:addEventListener(“enterFrame”, moveship)
function up:touch()
motionx = 0
motiony = -speed
end
up:addEventListener(“touch”, up)
function down:touch()
motionx = 0
motiony = speed
end
down:addEventListener(“touch”, down)
function left:touch()
motionx = -speed
motiony = 0
end
left:addEventListener(“touch”,left)
function right:touch()
motionx = speed
motiony = 0
end
right:addEventListener(“touch”,right)
– The above adds functions and listeners to each bullet and to the ship
local function wrap (event)
if heli.x < -50 then
heli.x = -50
end
if heli.x > 485 then
heli.x = 485
end
if heli.y > 280 then
heli.y = 280
end
if heli.y < 10 then
heli.y = 10
end
if speed < 0 then
speed = 0
end
end
Runtime:addEventListener(“enterFrame”, wrap)
function endGame( )
bank:save()
highText.text = “$” … bank:retrieve( “total” )
end
Runtime:addEventListener(“tap”, endGame )
local function change2 ()
bank:save()
Runtime:removeEventListener(“enterFrame”, wrap)
Runtime:removeEventListener(“enterFrame”, move)
Runtime:removeEventListener(“enterFrame”, moveship)
timer.cancel (timer1)
director:changeScene(“menus”)
end
box:addEventListener(“tap”, change2)
return localGroup
end[/code]
The above code I want that code to be turned into a storyboard instead of director anyone please help thanks
[import]uid: 17058 topic_id: 22160 reply_id: 322160[/import]