1) Is it possible to control when to load/unload resources in my game?
e.g. load game sprites when player enters the game state from the menu screen.
2) Is there an event callback when all resources have loaded?
e.g. Lets say I have a variable called "img" in my Actor class, and I want to set that value to a loaded image after all resources are loaded.
"img" is then used in the draw function.
-- Actor Class --
-- Call Initialize when resources have loaded (Is this possible???)
function Actor:initialize()
img = love_ball -- set the "img" variable to the loaded image
end
-- Draw Function
function Actor:draw()
love.graphics.draw(img,self.x,self.y)
end
Remember, img is here a global variable. If you want some sort of object oriented approach, you will want to use self.img. (The self is implicit, for example: actor1:draw() is really Actor.draw(actor1))
EDIT: as for your questions, for that you place them in the function load():
Unless you have a ridiculously large amount of images, I doubt you'd need to worry about unloading them. However, I guess it's good to have load screens when you switch between levels for a good base framework.