Hi all!
I have been creating a game, and have run into a problem.
I have created separate scenes, that are separate from each other. I want it so that, when something is clicked in one scene, it loads another scene.
The folder structure is as so:
menu -
/textures/
/sounds/
/main.lua
intro-1 -
/textures/
/main.lua
I want it so that when a button is clicked in the menu program, it runs the intro-1 program, but can't seem to get it to run another file from the program.
Any suggestions? I need help!
If you need clarification on anything, I can provide it.
Thanks
Outlaw11A
Running another main.lua from inside a game
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: Running another main.lua from inside a game
What you are looking for, is called game state. Have a variable "state" of type string where you save, which scene you are in. In love.update and love.draw you first check which state you are in and run the corresponding function
Example:
And the same in love.draw.
Example:
Code: Select all
function love.load()
state = 'intro'
end
Code: Select all
function love.update(dt)
if state = 'intro' then
intro.update(dt)
elseif state = 'firstScene' then
scene1.update(dt)
elseif state = 'gameover' then
gameoverscreen.update(dt)
end
end
Check out my blog on gamedev
Re: Running another main.lua from inside a game
micha wrote:What you are looking for, is called game state. Have a variable "state" of type string where you save, which scene you are in. In love.update and love.draw you first check which state you are in and run the corresponding function
Example:Code: Select all
function love.load() state = 'intro' end
And the same in love.draw.Code: Select all
function love.update(dt) if state = 'intro' then intro.update(dt) elseif state = 'firstScene' then scene1.update(dt) elseif state = 'gameover' then gameoverscreen.update(dt) end end
Thats sounds like exactly what I am looking for. Will give this a go!
Who is online
Users browsing this forum: No registered users and 6 guests