I have been messing around with the flight path code found here : https://github.com/ansca/Flight-Path I have picked it apart but a few questions have came to mind which I cannot solve.
The method to spawn a plane looks like this:
-- Will Spawn a random plane outside the screen, that will be traveling towards the center of the screen
function spawnRandomPlane()
local angle = math.random(1, 360)-- Generate a random angle for this plane to be positioned relative to the center of the screen
local lengthFromCenter = display.contentHeight \* (3/4) -- How far the planes will spawn from the center
local plane = getRandomPlane(lengthFromCenter \* math.cos(math.rad(angle)) + display.contentWidth / 2, lengthFromCenter \* math.sin(math.rad(angle)) \* -1 + display.contentHeight / 2)
plane.rotation = -90 - angle -- Calcualte the rotation of the plane (so it faces towards the center)
plane.touch = onPlaneTouched
plane:addEventListener("touch", plane)
plane.collision = onPlaneCollision
plane:addEventListener("collision", plane)
-- Set the plane speed
plane:setLinearVelocity( math.cos(math.rad(angle)) \* planeSpeed \* -1, math.sin(math.rad(angle)) \* planeSpeed )
end
function getRandomPlane(posX, posY)
local planeIndex = math.random(1, #planeImages)
local planeImage = planeImages[planeIndex]
local plane = display.newImage( planeImage.body)
plane.x = posX
plane.y = posY
local physicsData = (require "planeShape").physicsData(1)
physics.addBody(plane, "dynamic", physicsData:get("plane"))
plane.type = planeIndex
return plane
end
Is there anyway to edit this code so that I can specify a set of coordinates on the screen for planes to spawn from?
how would the coordinates of say:
x-------x
| |
| |
| |
x-------x
be listed?
Thanks in advance, Lewis.
[import]uid: 68741 topic_id: 11518 reply_id: 311518[/import]