Search found 29 matches
- Sat Jun 08, 2019 1:40 pm
- Forum: Support and Development
- Topic: [SOLVED] Dynamically create methods for a class.
- Replies: 3
- Views: 3155
Re: Dynamically create methods for a class.
I took down the forEach part. Credits to AuahDark for helping me. All I need was to change a few things around the code. For those wondering, it's now: local callbacks = { "update", "keypressed", "keyreleased", "textedited", "textinput", "mousem...
- Sat Jun 08, 2019 11:15 am
- Forum: Support and Development
- Topic: [SOLVED] Dynamically create methods for a class.
- Replies: 3
- Views: 3155
[SOLVED] Dynamically create methods for a class.
I am trying to hook a number of love handlers to a class. All they have to do is to propagate the call to all of the children. Although there are so many handlers I decided to list them all to a table then attempt to generate them through a for loop. The code shown below is what I described above. l...
- Sun Dec 04, 2016 1:27 am
- Forum: Support and Development
- Topic: Help with OOP
- Replies: 11
- Views: 7375
Re: Help with OOP
I kinda gotten confused already. My goal is to use a table to contain all objects and drawing them all without calling each object individually while still being able to access their functions hence an item manager. -- items.txt heart circle square triangle star -- main.lua items = {} function love....
- Sat Dec 03, 2016 1:40 pm
- Forum: Support and Development
- Topic: Help with OOP
- Replies: 11
- Views: 7375
Help with OOP
Hello, this is related with my current project but I feel this needs a topic of its own as it would get off-topic. I'm fairly new to OOP and don't know much about it. I'm making a system that when an object is created, it adds itself to another table. Some pseudo code to get it: list = {} item = { n...
- Tue Nov 29, 2016 5:08 am
- Forum: Support and Development
- Topic: How to draw all objects on screen?
- Replies: 12
- Views: 11630
Re: How to draw all objects on screen?
Thanks alot for the help! Just a follow up question, since I use cargo to handle my assets, is there anyway to handle something like this? -- inside actor.lua actor = class{ init = function(self, name) self.name = name self.image = assets.actors. <name> .idle end -- <name> = self.name } Since my fil...
- Mon Nov 28, 2016 8:29 pm
- Forum: Support and Development
- Topic: How to draw all objects on screen?
- Replies: 12
- Views: 11630
Re: How to draw all objects on screen?
Thanks for the ideas but I forgot to mention that each object should have a unique name. This is what my main.lua looks like: actors = {} -- actor(name, position, isVisible) Chris = actor(Chris, "center", true) Tristan = actor(Tristan, "left", false) function love.load() table.in...
- Mon Nov 28, 2016 1:49 pm
- Forum: Support and Development
- Topic: How to draw all objects on screen?
- Replies: 12
- Views: 11630
Re: How to draw all objects on screen?
I'll try to make an actor handler. For now I'll use this solution for prototyping.
- Mon Nov 28, 2016 11:53 am
- Forum: Support and Development
- Topic: How to draw all objects on screen?
- Replies: 12
- Views: 11630
Re: How to draw all objects on screen?
Given above works well. Can it be more efficient by calling table.insert inside the object's init function instead of calling table.insert for every actor object? Some psuedocode as it doesn't actually work but you'll get the gist of what I mean: -- inside actor.lua actor = class{ init = function(se...
- Mon Nov 28, 2016 10:27 am
- Forum: Support and Development
- Topic: How to draw all objects on screen?
- Replies: 12
- Views: 11630
How to draw all objects on screen?
I'm currently making a prototype Visual Novel Engine. What I'm looking for is to draw all objects on screen without having to call their draw function one by one. I'm using hump.class to handle my classes and this is what I got so far. function love.draw() actor1:draw() actor2:draw() actor3:draw() e...
- Sun Jul 10, 2016 1:58 pm
- Forum: Support and Development
- Topic: Game behaves differently between 32bit and 64bit systems
- Replies: 15
- Views: 7493
Re: Game behaves differently between 32bit and 64bit systems
As i said before, Edit: One potential mistake i might have found is that in game.lua, you call the entity update like this: ents:update(dt) but in the entities file, the function has only one parameter, dt, but this way, you're passing ents itself as that argument. Fix is to just do ents.update(dt)...