Page 1 of 1

I get a wierd error i havent seen anywhere

Posted: Wed Jul 27, 2022 12:30 pm
by Blitzer1001
so this is my code:

function love.load()
love.window.setMode(1920, 1080, {resizable=false, fullscreen=true, vsync=false, minwidth=1920, minheight=1080})
harmony = {}
harmony.sprite = love.image.newImageData("Sprites/Harmony.png")
harmony.bg = love.image.newImageData("Sprites/HarmonyBg.png")
end

function love.update(dt)
if love.keyboard.isDown("escape") then
love.event.quit()
end
end

function love.draw()
love.graphics.draw(harmony.bg, 0, 0)
love.graphics.draw(harmony.sprite, 860, -920)
end

i have been getting this error message:
main.lua:15: bad argument #1 to 'draw' (Drawable expected, got ImageData)

Can somebody help me? i am stuck!

Re: I get a wierd error i havent seen anywhere

Posted: Wed Jul 27, 2022 11:02 pm
by pgimeno
Well, the error code says it all - ImageData is not drawable. Drawable derivatives are (as of this writing): Canvas, Framebuffer, Image, Mesh, ParticleSystem, SpriteBatch, Text, Texture and Video. As you can see, ImageData is none of these.

Try making an image out of the imagedata, or loading the files into Image instances rather than into ImageData instances:

Code: Select all

harmony.spritedata = love.image.newImageData("Sprites/Harmony.png")
harmony.bgdata = love.image.newImageData("Sprites/HarmonyBg.png")

harmony.sprite = love.graphics.newImage(harmony.spritedata)
harmony.bg = love.graphics.newImage(harmony.bgdata)
-or-

Code: Select all

harmony.sprite = love.graphics.newImage("Sprites/Harmony.png")
harmony.bg = love.graphics.newImage("Sprites/HarmonyBg.png")
depending on whether you're going to need the image data later.

Re: I get a wierd error i havent seen anywhere

Posted: Thu Jul 28, 2022 5:00 pm
by Blitzer1001
thanks for solving my problem, pgimeno! it really blocked development!