Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

### Re: Delete chunk - love.filesystem.load

Disclaimer: I only recommend releasing and reloading resources like that when it actually takes up a lot of RAM, I don't think 60MB is really that much to keep in memory all the time.

You'll want to use two functions per state, like this:

lvl.lua:

Code: Select all

function enter_lvl()
blue_sun = newAnimation(love.graphics.newImage ("/images/blue_sun.png"), 512, 512, 0.1, 20)
end

function leave_lvl()
blue_sun = nil
end

function draw_sun ()
blue_sun:draw (400, 300)
end
main.lua:

Code: Select all

require("lvl")
[... snip ...]
function love.mousepressed(x, y, button )
if button == "l" then
game_mode = "space"
enter_lvl()
end
end

if game_mode == "space" then
if button == "r" then
leave_lvl()
end
end
end
There are libraries you can use that make using states a bit more structured.

Volgoza
Prole
Posts: 26
Joined: Fri Jul 13, 2012 12:20 pm

### Re: Delete chunk - love.filesystem.load

Robin, it's work. thank you very much!
There are libraries you can use that make using states a bit more structured.
In what sense?

Volgoza
Prole
Posts: 26
Joined: Fri Jul 13, 2012 12:20 pm

### Re: Delete chunk - love.filesystem.load

Code: Select all

Disclaimer: I only recommend releasing and reloading resources like that when it actually takes up a lot of RAM, I don't think 60MB is really that much to keep in memory all the time.
My game takes ~200 RAM and it no more 20% out of all graphic resources... So that, it very need for me.

Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

### Re: Delete chunk - love.filesystem.load

Volgoza wrote:
There are libraries you can use that make using states a bit more structured.
In what sense?
They can do all the bookkeeping you now have to do manually (like calling enter_lvl and leave_lvl) automatically, as well as handle some more advanced features like state stacking, etc. I recommend using such a library for every game that's going to have more than two, three states.

Also, how much RAM does it use? 200MB? That's a lot, but quite doable on modern computers. Anyway, it's always a trade off, and this is your call.