function love.draw()
function newPaddedImage(filename)
local source = love.image.newImageData(filename)
local w, h = source:getWidth(), source:getHeight()
-- Find closest power-of-two.
local wp = math.pow(2, math.ceil(math.log(w)/math.log(2)))
local hp = math.pow(2, math.ceil(math.log(h)/math.log(2)))
-- Only pad if needed:
if wp ~= w or hp ~= h then
local padded = love.image.newImageData(wp, hp)
padded:paste(source, 0, 0)
return love.graphics.newImage(padded)
end
return love.graphics.newImage(source)
end
newPaddedImage("C:/Documents and Settings/Nanny/Desktop/Beau/JesUnlimited/Header.gif")
end
function love.draw()
function newPaddedImage(filename)
local source = love.image.newImageData(filename)
local w, h = source:getWidth(), source:getHeight()
-- Find closest power-of-two.
local wp = math.pow(2, math.ceil(math.log(w)/math.log(2)))
local hp = math.pow(2, math.ceil(math.log(h)/math.log(2)))
-- Only pad if needed:
if wp ~= w or hp ~= h then
local padded = love.image.newImageData(wp, hp)
padded:paste(source, 0, 0)
return love.graphics.newImage(padded)
end
return love.graphics.newImage(source)
end
newPaddedImage("HEADER.gif")
end
The problem is that the window shows, but the image doesn't.
function newPaddedImage(filename)
local source = love.image.newImageData(filename)
local w, h = source:getWidth(), source:getHeight()
-- Find closest power-of-two.
local wp = math.pow(2, math.ceil(math.log(w)/math.log(2)))
local hp = math.pow(2, math.ceil(math.log(h)/math.log(2)))
-- Only pad if needed:
if wp ~= w or hp ~= h then
local padded = love.image.newImageData(wp, hp)
padded:paste(source, 0, 0)
return love.graphics.newImage(padded)
end
return love.graphics.newImage(source)
end
function love.load()
header = newPaddedImage("HEADER.gif")
end
function love.draw()
love.graphics.draw(header, 0, 0)
end
Do you know Lua? It's pretty vital to know that for LÖVE, and not that hard to learn.
Oh, OK. I'm sorry I assumed you were a rookie in Lua.
Then the thing you probably didn't know is that love.draw() is called every frame, which would create a new closure every frame, and that images are objects you need to keep around and draw yourself, because LÖVE can't know what you want to draw, when you want to draw it, where you want to draw it, etc.
I'm sure you'll find the wiki most useful if you just keep on browsing. If you haven't already, you might want to check out the tutorials.