Hi guys,
I’m working on a game with Corona, and I have a problem and I can’t find any solutions to solved it.
local storyboard = require( "storyboard" ) local scene = storyboard.newScene() local widget = require "widget" local game = require("game") local function onbtn\_back() storyboard.gotoScene( "bg\_home", "fade", 500 ) return true end --[[local function onbtn\_startlevel1() storyboard.gotoScene( "bg\_level", "fade", 500 ) return true local Game Game = game.new("images/backgrounds/bg\_newyork.jpg") Game:startGame() storyboard.removeScene( "bg\_menulvl" ) end]] local function onbtn\_startlevel2() local Game Game = game.new("images/backgrounds/bg\_paris.jpg") Game:startGame() storyboard.removeScene( "bg\_menulvl" ) end local function onbtn\_startlevel3() local Game Game = game.new("images/backgrounds/bg\_lecaire.jpg") Game:startGame() storyboard.removeScene( "bg\_menulvl" ) end local function onbtn\_startlevel4() local Game Game = game.new("images/backgrounds/bg\_tokyo.jpg") Game:startGame() storyboard.removeScene( "bg\_menulvl" ) end local function onbtn\_startlevel5() local Game Game = game.new("images/backgrounds/bg\_moscou.jpg") Game:startGame() storyboard.removeScene( "bg\_menulvl" ) end local function onbtn\_startlevel6() local Game Game = game.new("images/backgrounds/bg\_rio.jpg") Game:startGame() storyboard.removeScene( "bg\_menulvl" ) end local function onbtn\_startlevelarcade() storyboard.gotoScene( "bg\_arcade", "fade", 500 ) end local function onbtn\_startlevelchallenge() storyboard.gotoScene( "bg\_challenge", "fade", 500 ) end function scene:createScene( event ) local group = self.view local background = display.newImageRect( "images/backgrounds/bg\_menulvl.jpg", display.contentWidth, display.contentHeight ) background.x, background.y = display.contentCenterX, display.contentCenterY btn\_back = widget.newButton { defaultFile = "images/boutons/b\_back.png", width = 200, height = 200, left = 150, top = 80, onRelease = onbtn\_back } options = { effect = "fade", params = { sample\_var = "anything", custom = "you want", data = "here", level1 = "new-york"} } btn\_newyork = widget.newButton { defaultFile = "images/boutons/b\_newyork.png", width = 200, height = 200, left = 350, top = 250, --onRelease = onbtn\_startlevel1 onRelease = function () storyboard.gotoScene( "bg\_level", options ) end } btn\_paris = widget.newButton { defaultFile = "images/boutons/b\_paris.png", width = 200, height = 200, left = 800, top = 180, onRelease = onbtn\_startlevel2 } btn\_lecaire = widget.newButton { defaultFile = "images/boutons/b\_lecaire.png", width = 200, height = 200, left = 890, top = 400, onRelease = onbtn\_startlevel3 } btn\_tokyo = widget.newButton { defaultFile = "images/boutons/b\_tokyo.png", width = 200, height = 200, left = 1550, top = 300, onRelease = onbtn\_startlevel4 } btn\_moscou = widget.newButton { defaultFile = "images/boutons/b\_moscou.png", width = 200, height = 200, left = 1100, top = 170, onRelease = onbtn\_startlevel5 } btn\_rio = widget.newButton { defaultFile = "images/boutons/b\_rio.png", width = 200, height = 200, left = 500, top = 650, onRelease = onbtn\_startlevel6 } btn\_arcade = widget.newButton { defaultFile = "images/boutons/b\_arcade.png", width = 360, height = 128, left = 800, top = 600, onRelease = onbtn\_startlevelarcade } btn\_challenge = widget.newButton { defaultFile = "images/boutons/b\_challenge.png", width = 481, height = 128, left = 740, top = 750, onRelease = onbtn\_startlevelchallenge } group:insert( background ) group:insert( btn\_back ) group:insert( btn\_newyork ) group:insert( btn\_paris ) group:insert( btn\_lecaire ) group:insert( btn\_tokyo ) group:insert( btn\_moscou ) group:insert( btn\_rio ) group:insert( btn\_arcade ) group:insert( btn\_challenge ) end scene:addEventListener( "createScene", scene ) return scene
This is normally the file how to choose my level,
After this, I have one other file :
local game = {} local widget = require "widget" local storyboard = require( "storyboard" ) local scene = storyboard.newScene() physics = require("physics") physics.start() physics.setGravity(0, 0) local function onbtn\_pause() local Game Game = game.new("images/backgrounds/bg\_pause.jpg") Game:pauseGame() end local function onbtn\_home() storyboard.loadScene( "bg\_home", "fade", 500 ) end local function onbtn\_map() storyboard.loadScene( "bg\_menulvl", "fade", 500 ) end local function onbtn\_score() storyboard.gotoScene( "bg\_score", "fade", 500 ) end function game.new(levelN) local game = display.newGroup() game.id = "game" local Missile = require("missile") local missiles function initGame() local background = display.newImageRect( levelN, display.contentWidth, display.contentHeight ) background.x, background.y = display.contentCenterX, display.contentCenterY btn\_pause = widget.newButton { defaultFile = "images/boutons/b\_pause.png", width = 150, height = 150, left = 1700, top = 40, onRelease = onbtn\_pause } end function initPause() local background = display.newImageRect( levelN, display.contentWidth, display.contentHeight ) background.x, background.y = display.contentCenterX, display.contentCenterY btn\_son = widget.newButton { defaultFile = "images/boutons/b\_son\_on.png", width = 200, height = 200, left = 150, top = 80, --onRelease = onbtn\_faq } btn\_fx = widget.newButton { defaultFile = "images/boutons/b\_fx\_on.png", width = 200, height = 200, left = 150, top = 300, --onRelease = onbtn\_faq } btn\_reprendre = widget.newButton { defaultFile = "images/boutons/b\_play.png", width = 200, height = 200, left = 1650, top = 80, onRelease = onbtn\_reprendre } btn\_recommencer = widget.newButton { defaultFile = "images/boutons/b\_replay.png", width = 200, height = 200, left = 1650, top = 300, onRelease = onbtn\_recommencer } btn\_home = widget.newButton { defaultFile = "images/boutons/b\_home.png", width = 200, height = 200, left = 150, top = 800, onRelease = onbtn\_home } btn\_map = widget.newButton { defaultFile = "images/boutons/b\_map.png", width = 200, height = 200, left = 400, top = 800, onRelease = onbtn\_map } btn\_score = widget.newButton { defaultFile = "images/boutons/b\_score.png", width = 200, height = 200, left = 1650, top = 820, onRelease = onbtn\_score } end function game:startGame() initGame() end function game:pauseGame() initPause() end return game end return game
The problem is right here !
When I begin to implement the Game: in the first file, I CAN’T USE the storyboard after ! And i really don’t know how I can use the function onbtn_Home or function who used storyboard in the second file.
Someone have a idea ?