Started few weeks ago learning lua and I'd like to continue working on my small project, so bear with me but I don't have a lot of notions in 2D design/graphics.
I've started taking a look to the Example project Level 1-1 where in player.lua it creates an imagetable with self.playerImages = playdate.graphics.imagetable.new('img/player').
What is driving me crazy is that if I change only ONE pixel in that png it stops working. Imagetable is nil. If I upload a new image doesn't work too.
But today I used that same code in another new project I created, and even if I'm using player-table-16-32.png, imagetable is nil. Same code, just different project.
What notion I'm missing here? Any doc reference? Do I need to set up the tables images I upload in a new project in some way?
Probably it's something really basic as I couldn't find any doc or issues regarding this, but please any kind of clarification are welcome as I'm really close to quit
It sounds like the build process isn’t picking up the image for whatever reason. Does the output from pdc mention anything to do with the image? (If you’re using Nova you can find that in the Reports sidebar.)
Does the resulting .pdx contain the processed image as a .pdt file? In the level 1-1 example it should be located at Level 1-1.pdx/img/player.pdt.
Also, what image editor were you using when you tried editing the image? Maybe it’s saving incompatible pngs for some reason.
Hi Dale,
I'm not using Nova but IntelliJ, with an extension for Lua - so not sure about pdc output.
.pdx contains the processed images, even the image file I used in the imagetable that failed.
To edit files I use ProCreate for iPads.
The weird thing is the problem exists only for images I use in imagetable. Any other files, even the one I created with ProCreate, work correctly if I use them in gfx.image.new("...").
Just making sure I understand, you’re able to build and run Level 1-1 with the original version of the image and it works?
I just tested and I was able to:
import player-table-16-32.png into Procreate
Draw over the image
Share from Procreate as PNG and send the file back to my computer
Replace Source/img/player-table-16-32.png with my edited version
Build and run again from my IDE, and my edited version appeared in the game.
Are you sure the png has the same dimensions after you edit it (112x32)? The only special requirement for image tables that I’m aware of is that the total dimensions should be a multiple of the frame dimensions in the filename (e.g. 112 is a multiple of 16)
local pd <const> = playdate
local gfx <const> = pd.graphics
class('Player').extends(gfx.sprite)
function Player:init()
Player.super.init(self)
self.image = playdate.graphics.imagetable.new('images/player')
self:setImage(image:getImage(1))
self:moveTo(330, 120)
end
And then I call
Player()
in main.lua outside any function.
However, if I use gfx.image.new("images/hellothere") it works showing the entire image.
The error message is: attempt to index a nil value (global 'image')