This is kind of a big question, so please stay with me. I’m creating a game for IOS. I’ve been trying to figure out how to make my jet shoot re-spawning lasers The jet moves up and down the screen as you touch the screen. I want to know how to set the touch events so that when you touch the left side of the screen, force is applied to the jet. I don’t know how to distribute the areas of the screen to respond to different functions as I’m very new to developing games. I want the right side of the screen to respond to the function where the jet shoots lasers to the obstacles coming it’s way and to remove the obstacles with a exploding sprite as they hit the laser beam. I also want to make the obstacles increase in number as the jet shoots them. I’m in a dead end to finish my game because I haven’t figured out what to do, it would be really great if you can help me out. This is my first time asking a question, so please don’t mind if this is confusing.
Here’s basically what I’ve been doing
[lua]local physics = require “physics”
physics.start()
local screenGroup = self.view
local background = display.newImage(“background.png”)
screenGroup:insert(background)
city1 = display.newImage(“city1.png”)
city1:setReferencePoint(display.BottomLeftReferencePoint)
city1.x = 0
city1.y = 640
city1.speed = 18
screenGroup:insert(city1)
city2 = display.newImage(“city2.png”)
city2:setReferencePoint(display.BottomLeftReferencePoint)
city2.x = 1136
city2.y = 640
city2.speed = 18
screenGroup:insert(city2)
Jet = display.newImage(“Jet.png”)
Jet.x = 300
Jet.y = 180
physics.addBody(Jet, “dynamics”, {density=100, bounce=0.1, friction=10, radius=13})
screenGroup:insert(Jet)
dragon1 = display.newImage(“Dragon.png”)
dragon1.x = 1136
dragon1.y = 320
dragon1.speed = math.random(4,8)
dragon1.initY = ufo1.y
dragon1.amp = math.random(125,126)
dragon1.angle = math.random(150,600)
physics.addBody(ufo1, “static”, {density=1, bounce=0.1, friction=2, radius=67})
screenGroup:insert(dragon1)
dragon2 = display.newImage(“Dragon.png”)
dragon2.x = 1136
dragon2.y = 320
dragon2.speed = math.random(5,10)
dragon2.initY = ufo2.y
dragon2.amp = math.random(125,126)
dragon2.angle = math.random(150,600)
physics.addBody(dragon2, “static”, {density=1, bounce=3, friction=100, radius=67})
screenGroup:insert(dragon2)
end
function scrollCity(self,event)
if self.x < -1100 then
self.x = 1100
else
self.x = self.x - self.speed
end
end
function moveDragons(self,event)
if self.x < -300 then
self.x = 1250
self.y = math.random(120,400)
self.speed = math.random(4,8)
self.initY = Dragon1.y
self.amp = math.random(125,150)
self.angle = math.random(150,600)
else
self.x = self.x - self.speed
self.angle = self.angle + .1
self.y = self.amp*math.sin(self.angle)+self.initY
end
end
function activateJets(self,event)
self:applyForce(0, -2500, self.x, self.y)
end
function touchScreen(event)
– print(“touch”)
if event.phase == “began” then
Jet.enterFrame = activateJets
Runtime:addEventListener(“enterFrame”, Jet)
end
if event.phase == “ended” then
Runtime:removeEventListener(“enterFrame”, Jet)
end
function onCollision(event)
if event.phase == “began” then
storyboard.gotoScene(“restart”, “fade”, 200)
end
end
function scene:enterScene(event)
Runtime:addEventListener(“touch”, touchScreen)
city1.enterFrame = scrollCity
Runtime:addEventListener(“enterFrame”, city1)
city2.enterFrame = scrollCity
Runtime:addEventListener(“enterFrame”, city2)
Runtime:addEventListener(“collision”, onCollision)
end
function scene:exitScene(event)
Runtime:removeEventListener(“touch”, touchScreen)
Runtime:removeEventListener(“enterFrame”, city1)
Runtime:removeEventListener(“enterFrame”, city2)
Runtime:removeEventListener(“collision”, onCollision)
end
function scene:destroyScene(event)
end
scene:addEventListener(“createScene”, scene)
scene:addEventListener(“enterScene”, scene)
scene:addEventListener(“exitScene”, scene)
scene:addEventListener(“destroyScene”, scene)
return scene
[/lua]