I am using radamanthus director for a simple program. I have multiple levels but once I enter my code I can’t seem to get it to return to the main menu. Here is my trimmed down code but includes all codes. I’ve tried everything I can think of and looked at a bunch of examples. Any help would be appreciated.
[blockcode]
module(…, package.seeall)
– Main function - MUST return a display.newGroup()
function new()
local localGroup = display.newGroup()
local moviecliptestwarn = require(“moviecliptestwarn”)
local movieclip = require(“movieclip”)
local physics = require(“physics”)
physics.start()
physics.setGravity(0,0)
local gameUI = require(“gameUI”)
local f = false
local t = true
local background = display.newImageRect(“images/sky.png”, 678, 642)
background:setReferencePoint(display.CenterReferencePoint)
localGroup:insert(background)
background.x = 235
background.y = 160
local fltdeck = display.newImageRect(“images/safetyfd.png”,678, 642)
localGroup:insert(fltdeck)
fltdeck:setReferencePoint(display.CenterReferencePoint)
fltdeck.x = 235
fltdeck.y = 160
fltdeck:scale(.9,.9)
–NOSE WHEEL DOOR
ngdoor = display.newRect(200,200,100,110)
ngdoor:setFillColor(255,255,255)
localGroup:insert(ngdoor)
ngdoor.alpha = 0.01
ngdoor.isVisible = f
–HOME BUTTON
home = display.newRect(200,200,100,100)
home:setFillColor(255,0,0)
localGroup:insert(home)
home.alpha = .9
home.isVisible = t
–home.isSensor = f
local function startDrag( event )
local t = event.target
local phase = event.phase
if “began” == phase then
display.getCurrentStage():setFocus( t )
t.isFocus = true
t.x0 = event.x - t.x
t.y0 = event.y - t.y
event.target.bodyType = “kinematic”
–event.target:setLinearVelocity( 0, 0 )
–event.target.angularVelocity = 0
elseif t.isFocus then
if “moved” == phase then
t.x = event.x - t.x0
t.y = event.y - t.y0
elseif “ended” == phase or “cancelled” == phase then
display.getCurrentStage():setFocus( nil )
t.isFocus = false
if ( not event.target.isPlatform ) then
event.target.bodyType = “dynamic”
end
end
end
return true
end
fltdeck:addEventListener( “touch”, startDrag )
– set frame boundaries
local speed = 15
local function wrap (event)
if fltdeck.x < 165 then
fltdeck.x = 165
end
if fltdeck.x > 300 then
fltdeck.x = 300
end
if fltdeck.y > 285 then
fltdeck.y = 285
end
if fltdeck.y < 30 then
fltdeck.y = 30
end
if speed < 0 then
speed = 0
end
end
Runtime:addEventListener(“enterFrame”, wrap)
–NOSE GEAR DOOR
local function toNgDoor (event)
if event.phase == “began” then
ngdoor:removeSelf()
home.isVisible = true
ngdoor:removeEventListener(“touch”, toNgDoor)
ngdoorpic = display.newImage(“images/ngdoor.png”)
ngdoorpic.x = display.contentWidth / 2
ngdoorpic.y = 120
ngdoorpic:scale(.7,.7)
ngdoorText = display.newText(“NOSE GEAR DOOR CLOSED”, 0, 0, native.systemFontBold, 32)
ngdoorText:setTextColor( 9, 250, 43)
ngdoorText.x = display.contentWidth / 2
ngdoorText.y = 250
transition.to( ngdoorpic, { time=3000, delay=2200, alpha=0 } )
transition.to( ngdoorText, { time=3000, delay=2200, alpha=0 } )
end
end
ngdoor:addEventListener( “touch”, toNgDoor )
–MATCH FLIGHT DECK POSITION
local match = function()
if ngdoor.isVisible then
ngdoor.x = fltdeck.x + 239
ngdoor.y = fltdeck.y + 242
end
end
–local function homeMatch ( event )
–home.x = fltdeck.x
–home.y = fltdeck.y
–end
Runtime:addEventListener(“enterFrame”, match)
–GO TO MAIN MENU
local function touched ( event )
if event.phase == “ended” then
director:changeScene(“menu”,“fade”)
end
end
home:addEventListener(“touch”, touched )
unloadMe = function()
end
–MUST return a display.newGroup()
return localGroup
end
[import]uid: 31005 topic_id: 8170 reply_id: 308170[/import]