Using the love api in other classes/tables other than main.
Posted: Mon Sep 22, 2014 4:07 am
Hello all. First time posting here. I am pretty new to Love. So far I like it. I did have a question that I believe is a bit noob, but nevertheless I need to figure it out.
So calling the love api from another class other than the main class/table ex.
It returns nil for love. In my former experiences I have applied the following techniques to get around this:
singletons - if the api was limited to the main class I can just make the call through a singleton
dependency injection - Just passing the "object" to the child class can give it access to the api
another way I have seen it done specifically in lua is
mocking function - I seen an example of this in the anim8 library (https://github.com/kikito/anim8)
Is there an easier way to get around this? Or are any of these 3 technices something I may have to apply? I appreciate any help.
Thanks,
Visions
So calling the love api from another class other than the main class/table ex.
Code: Select all
image = love.graphics.newImage('p1.png')
singletons - if the api was limited to the main class I can just make the call through a singleton
dependency injection - Just passing the "object" to the child class can give it access to the api
another way I have seen it done specifically in lua is
mocking function - I seen an example of this in the anim8 library (https://github.com/kikito/anim8)
Is there an easier way to get around this? Or are any of these 3 technices something I may have to apply? I appreciate any help.
Thanks,
Visions