0
votes

i'm working on a game, and I have a problem since some hours and I really don't know how to fix it !

I begin my game like always, with a new storyboard and at the begin it's works fine, but, when I tried to implement my class Game to control all the gameplay, I obtain a error :

bg_menulvl.lua :

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 
}

local function onbtn_back()
local Game
Game = game.new("images/backgrounds/bg_rio.jpg")
Game:startGame()
storyboard.removeScene( "bg_menulvl" )
end

game.lua

local function onbtn_map()
storyboard.gotoScene( "bg_menulvl", "fade", 500 )
end

local function onbtn_score()
storyboard.gotoScene( "bg_score", "fade", 500 )
end

function game.new(levelN)

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_map
    }
end

So, to understand this, I begin the game in bg_menulvl.lua and when I click, I create a new Game to implement my logic, but after when I begin my game, I tried when I click in onbtn_map, go create a new storyboard and levae my game instance ...

But i obtain all the time this error : attempt t index field 'contentBound' (a nil value) (In fonction goToScene)

If someone can help me ... Thank you !

1

1 Answers

0
votes

Does using this work?

storyboard.loadScene( "bg_menulvl", "fade", 500 )

Hope it helps.