Page 1 of 1

Won't display text and image

Posted: Fri Jul 01, 2022 2:26 am
by Incognita177
I've been trying to get this to work for so long, and I almost did but for some reason every time I run it only the picture shows up and not the text. When I put the code for the image in a comment, the text shows up, but when I un-comment the image code the text disappears and only the image shows. here's my code:

function love.draw()
love.graphics.print("Welcome to the game!", 0, 0)
end

local dog = love.graphics.newImage('dog.png')

function love.load()
love.graphics.setDefaultFilter('nearest', 'nearest')
end

function love.draw()
love.graphics.draw(dog, 300, 400)
end

Re: Won't display text and image

Posted: Fri Jul 01, 2022 3:14 am
by ReFreezed
You can't have two love.draw functions. The latter replaces the previous one. Put all your rendering code in the same function.

Re: Won't display text and image

Posted: Fri Jul 01, 2022 11:32 am
by GVovkiv
As ReFrezzed mentioned, put your drawable in single love.draw function.
Like here:

Code: Select all

local dog = love.graphics.newImage('dog.png')

function love.load()
    love.graphics.setDefaultFilter('nearest', 'nearest')
end

function love.draw()
    love.graphics.draw(dog, 300, 400)
    love.graphics.print("Welcome to the game!", 0, 0)
end

Re: Won't display text and image

Posted: Fri Jul 01, 2022 1:55 pm
by Incognita177
Thank you so much! The text and picture are both displaying now!