bejoy, I am trying to make a game similar to age of war, I am using levelhelper also, my view1.lua is this:
[code]
–
– view1.lua
– hide default status bar (iOS)
display.setStatusBar( display.HiddenStatusBar )
local physics = require( “physics”)
physics.start()
require “LHAnimationsExt”
game = require( “beebegames” )
local storyboard = require( “storyboard” )
local scene = storyboard.newScene()
require “LevelHelperLoader”
loader = LevelHelperLoader:initWithContentOfFile(“ageingwar.plhs”)
–path notifiers and event listener for all sprites should be placed here
–see “Collision Handling and Events” and “Beziers” sections for more info
loader:instantiateObjects(physics, camera)
local camera = display.newGroup()
application.LevelHelperSettings.directorGroup = camera
local ground = loader:spriteWithUniqueName(“cloud2”)
local minip = loader:spriteWithUniqueName(“minip”)
camera:insert(ground)
– move camera
local myTouchListener = function( event )
if(event.phase == “began”)then
lastTouchLocation = { x= event.x}
end
if(event.phase == “ended”)then
lastTouchLocation = { x= event.x}
end
if(event.phase == “moved”)then
local delta = { x = event.x - lastTouchLocation.x};
lastTouchLocation = { x= event.x}
camera.x = camera.x + delta.x
end
end
Runtime:addEventListener( “touch”, myTouchListener )
–stop camera
local function stopit(event)
if camera.x < -1030 then
camera.x = -1030
elseif camera.x > 0 then
camera.x = 0
end
end
Runtime:addEventListener(“enterFrame”, stopit)
local function spawn(event)
minip:removeEventListener(“touch”, spawn)
playern = loader:newSpriteWithUniqueName(“player”)
physics.addBody(playern, “dynamic”, {friction=0, bounce=.2, density=.2})
playern:setLinearVelocity(40,0)
playern.x = 46
playern.y = 260
local winner = display.newText(“You WIN”, 200, 100, system.defaultFont, 30)
winner.isVisible = false
local function endit(event)
if playern.x > 100 then
winner.isVisible = true
end
end
playern:addEventListener(“enterFrame”, endit)
local secsText = 3
local timeText = display.newText(secsText, minip.x-5, minip.y-7, “Helvetica”, 24)
timeText:setTextColor(255,255,255)
local function updateTime (event)
secsText = secsText - 1
if secsText == 0 then
timeText:removeSelf()
minip:addEventListener(“touch”, spawn)
end
timeText.text = secsText
end
timer.performWithDelay(1000, updateTime, 0)
end
– first countdown
local secsText = 3
local timeText = display.newText(secsText, minip.x-5, minip.y-7, “Helvetica”, 24)
timeText:setTextColor(255,255,255)
local function updateTime (event)
secsText = secsText - 1
if secsText == 0 then
timeText:removeSelf()
minip:addEventListener(“touch”, spawn)
end
timeText.text = secsText
end
timer.performWithDelay(1000, updateTime, 0)
local mRand1 = math.random(4000, 5000)
local function spawnc(event)
enemy = loader:newSpriteWithUniqueName(“gb_walk_12”)
physics.addBody(enemy, “dynamic”, {friction=0, bounce=.2, density=.2})
enemy:setLinearVelocity(-40,0)
enemy.x = 1500
enemy.y = 250
end
timer.performWithDelay(mRand1, spawnc, 9999999999999)
return scene [import]uid: 38977 topic_id: 19429 reply_id: 75137[/import]