Scene Managment Help

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
PARADOX
Prole
Posts: 3
Joined: Fri Jan 03, 2025 10:32 pm

Scene Managment Help

Post by PARADOX »

EDIT: I fixed it! I had to use love.graphics.reset() in my game.load() function to get rid of the previous scene's graphics

Hello! this is my first post on these forums,

My issue is I have made a game and a menu, and I'm trying to use StackingSceneMgr (SSM https://gitlab.com/V3X3D/love-libs/-/tr ... type=heads) to start in the Menu and then switch to the Game when I hit the start button.

Both my scenes work when I set them to be the first scene, but I cannot figure out how to switch scenes from one to the other.

Here's the code on my main.lua:

Code: Select all

SSM = require "lib.StackingSceneMgr".newManager()
SSM.setPath("scenes/")


function love.load()
    SSM.add("menu")
end

function love.update(dt)
    SSM.update(dt)
end

function love.draw()
    SSM.draw()
end 

and the code in my start button in the menu.lua:

Code: Select all


"Start Game",
        function ()
            print("starting game!")
            SSM.removeAll()
            SSM.purge("menu")
            SSM.add("game")
        end))
The menu and buttons load correctly, but when I click the button "start game" the menu disappears and I only have a black screen.

my game loads correctly if I add the game scene first, so I'm not sure what's going wrong.

Any help is greatly appreciated! Let me know if posting more of my code would help trouble shooting
Last edited by PARADOX on Sun Jan 05, 2025 7:35 am, edited 3 times in total.
kov_serg
Prole
Posts: 12
Joined: Wed Dec 18, 2024 4:38 pm

Re: Scene Managment Help

Post by kov_serg »

If first scene is "game" instead "menu" in love.load function then you can see correct screen or still black screen?
PARADOX
Prole
Posts: 3
Joined: Fri Jan 03, 2025 10:32 pm

Re: Scene Managment Help

Post by PARADOX »

kov_serg wrote: Sat Jan 04, 2025 9:58 am If first scene is "game" instead "menu" in love.load function then you can see correct screen or still black screen?
If the first scene is game, then it opens directly to the game, and it works perfectly
kov_serg
Prole
Posts: 12
Joined: Wed Dec 18, 2024 4:38 pm

Re: Scene Managment Help

Post by kov_serg »

Try to add following code

Code: Select all

function love.draw()
  love.graphics.push "all"
  SSM.draw()
  love.graphics.pop()
end
Without code is hard to answer your question.
Problem may be in SetColor{0,0,0} or in main scene load function or in global variables or something else.
But in any case logging the frist thing wil help you most.
PARADOX
Prole
Posts: 3
Joined: Fri Jan 03, 2025 10:32 pm

Re: Scene Managment Help

Post by PARADOX »

Thank you for your help! I figured out a similar solution earlier today, I added "love.graphics.reset()" into the main scene load function, it seems like the game was loading, just under a black screen XD
Post Reply

Who is online

Users browsing this forum: Bing [Bot], MrFariator, Semrush [Bot] and 12 guests