Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Create n random parachuters
- function createPara(copter)
- local randX = math.random(100, 200)
- if copter.x ~= nil then
- if tonumber(copter.x) > 50 and tonumber(copter.x) < 470 then
- if copter.isAlive then
- local paraChuter = display.newSprite( getSheet( obj.paraChuter.paraGlide), getSequenceData.paraData )
- paraChuter.x = copter.x-10
- paraChuter.y = copter.y+5
- paraChuter:play()
- paraChuter.name = "paraChuter"
- physics.addBody(paraChuter, "dynamic", physicsData:get("paraglider"))
- paraChuter.isFixedRotation = true
- paraChuter.linearDamping = 5
- end
- end
- end
- end
- --Precollision
- local function onLocalPreCollision( event )
- if (not event.target.Skipped or event.target.Skipped == event.other) and event.other.myName == "platform1" then
- event.contact.isEnabled = false
- event.target.Skipped = event.other
- end
- end
- --If bullet hits the parachuter
- function onCollision(self, event)
- ---- if bullet hits parachuter
- if event.phase == "began" and (self.name == "bullet" and event.other.name == "paraChuter") then
- event.other:setSequence( "paraDead" )
- event.other.name = "paraDead"
- event.other:addEventListener( "preCollision", onLocalPreCollision )
- event.other.isFixedRotation = true
- event.other.linearDamping = 5
- event.other:play()
- display.remove(self)
- self = nil
- end
- end
- --First platform (platform1)
- function setUpCatchPlatform()
- local platform = display.newRect( 0, 0, display.contentWidth * 4, 0)
- platform.myName = "platform1"
- platform.x = (display.contentWidth / 2)
- platform.y = (display.contentHeight / 2) + 40
- physics.addBody(platform, "static", collisionTable.firstParaPlatformProp)
- platform.collision = onCatchPlatformCollision
- platform:addEventListener( "collision", platform )
- end
- --Second platform (platform2)
- function setUpCatchPlatform2()
- local platform2 = display.newRect( 0, 0, display.contentWidth * 4, 0)
- platform2.myName = "platform2"
- platform2.x = (display.contentWidth / 2)
- platform2.y = (display.contentHeight / 2) + 150
- physics.addBody(platform2, "static", collisionTable.secondParaPlatformProp)
- platform2.collision = onCatchPlatformCollision2
- platform2:addEventListener( "collision", platform2 )
- end
- --Change the sequence gliding to landing
- function onCatchPlatformCollision(self, event)
- if event.phase == "began" and event.other.name == "paraChuter" then
- if event.other ~= nil then
- event.other:setSequence( "paraLand" )
- event.other.name = "paraLander"
- event.other:addEventListener( "preCollision", onLocalPreCollision )
- event.other:play()
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement