Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Trevor
Prole
Posts: 30
Joined: Thu Mar 31, 2011 4:14 pm

load.load gets "called exactly once at the beginning of the game." How are the game assets loaded afterwards? I've been looking at the code from "Dave Gone Apeshit" and it doesn't call love.load after state changes.

Main

Code: Select all

...
...
...
end


Code: Select all

if menuMode == "main" then
...
if menu.button("NEW GAME", 475, 310) then
state = game
end
...

state is now game if you click "New Game" good so far. But now, since love.load only runs once how is game.load called since love.load will never be called again and state.load is in love.load?

BlackBulletIV
Inner party member
Posts: 1260
Joined: Wed Dec 29, 2010 8:19 pm
Location: Queensland, Australia
Contact:

### Re: I don't understand love.load

Wouldn't the loading for the load function for state be called in love.update or something when a state changes? If you need to load assets after the game starts up, you would most likely to so in the update stage, i.e. when love.update is called.

Anyway, this is just a game's use of love.load. love.load is called exactly once at the start of the game (you can call it again manually of course); that's all.

Trevor
Prole
Posts: 30
Joined: Thu Mar 31, 2011 4:14 pm

### Re: I don't understand love.load

Okay, I thought assets had be loaded in love.load. I didn't realize - despite looking right at the code - that assets can me loaded at any point. Thank you, sometimes it just takes an explanation. This helps a lot. Each time I call love.load the screen disappears for a moment which I really disliked.

BlackBulletIV
Inner party member
Posts: 1260
Joined: Wed Dec 29, 2010 8:19 pm
Location: Queensland, Australia
Contact:

### Re: I don't understand love.load

No worries.

Calling love.load isn't a good thing, unless you want a complete reset (this relies on you doing all start up inside love.load) with some sort of delay. If you want to reset a game without delay, you should probably manually do it, by reseting player positions, removing enemies, or something like that.

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

### Re: I don't understand love.load

love.load usually consists of two parts: loading resources and setting up state (player position, enemies, whatever). You can separate those, put the setting up part in another function and call that when you want to reset the game.