Lua/Löve2D newbie - need help understanding problem with loading graphics
Posted: Sun Aug 26, 2018 1:33 am
Lua code link (It is the only file in the project currently, aside from a config): https://pastebin.com/9xrw1CDf
Hello wonderful people of the Löve2D forum,
I decided it's time to sit down and learn LÖVE2D development for good, so I started up a simple, small project, aided by an online tutorial - just to get the gist of it. I'm new to game development as well.
Anyways, a day in and I'm faced with the following issue:
1. I load a sprite of a bullet in love.load()
2. When I press a key, I make a new bullet object and add it to a global bulletTable{}. This is done in love.update()
When I debugged this, however, I noticed that after the first entry all the other bullet copies had a 'nil' img value. To test out further, I loaded the same image to a different variable and then added it to the table twice, before attempting to spawn a bullet with the first image variable twice as well. Both times the first entry had a valid img value, and the second - a 'nil'.
I do not understand why this happens and browsing the Net has yielded no results. If anyone has the time to explain this I would be very thankful. Cheers!
Hello wonderful people of the Löve2D forum,
I decided it's time to sit down and learn LÖVE2D development for good, so I started up a simple, small project, aided by an online tutorial - just to get the gist of it. I'm new to game development as well.
Anyways, a day in and I'm faced with the following issue:
1. I load a sprite of a bullet in love.load()
2. When I press a key, I make a new bullet object and add it to a global bulletTable{}. This is done in love.update()
When I debugged this, however, I noticed that after the first entry all the other bullet copies had a 'nil' img value. To test out further, I loaded the same image to a different variable and then added it to the table twice, before attempting to spawn a bullet with the first image variable twice as well. Both times the first entry had a valid img value, and the second - a 'nil'.
I do not understand why this happens and browsing the Net has yielded no results. If anyone has the time to explain this I would be very thankful. Cheers!