Hey all, I've just started playing with Love and have been reading the forums and tutorials for a while. I don't have any blocking issues but just to ask some questions here on the forums in case I missed a few things on the way.
At the moment I have an update function in my main.lua file that then calls an update function in all the child game objects. Same for draw and even load. I was about to start pushing other events down to all my objects so they can handle input.
Is it possible to automatically resister all my update functions to be called when the love.update event is called?
Hooking into loves events
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- zorg
- Party member
- Posts: 3449
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: Hooking into loves events
there's a gamestate library that gives you that kind of functionality as an option: https://hump.readthedocs.io/en/latest/gamestate.html
Although i'm not sure if i would treat game objects as gamestates... semantically i mean; i'd probably do something like this:
Although i'm not sure if i would treat game objects as gamestates... semantically i mean; i'd probably do something like this:
Code: Select all
function love.update(dt)
yourupdatefunc()
end
local function yourupdatefunc()
-- your game objects being in one table is the assumption:
for i,v in ipairs(gameobjects) do
v:update()
end
end
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Re: Hooking into loves events
Thanks zorg. Thats pretty much what I am doing now.
Who is online
Users browsing this forum: No registered users and 3 guests