Page 1 of 1

Scene Managment Help

Posted: Fri Jan 03, 2025 10:45 pm
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

Re: Scene Managment Help

Posted: Sat Jan 04, 2025 9:58 am
by kov_serg
If first scene is "game" instead "menu" in love.load function then you can see correct screen or still black screen?

Re: Scene Managment Help

Posted: Sun Jan 05, 2025 12:11 am
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

Re: Scene Managment Help

Posted: Sun Jan 05, 2025 7:16 am
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.

Re: Scene Managment Help

Posted: Sun Jan 05, 2025 7:33 am
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