Unable to display text and images at the same time

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
Neox Hopper
Prole
Posts: 8
Joined: Mon Dec 31, 2018 8:20 am

Unable to display text and images at the same time

Post by Neox Hopper »

When I enter this script into my game, it shows the image but it doesn't show the text. Does anyone know how to fix this issue?

Script:

function love.load()

potato = love.graphics.newImage("potato.png")
end

function love.draw()

love.graphics.draw(potato, 250, 250)
end

function love.draw()

love.graphics.print("Here's potato!")
end
User avatar
zorg
Party member
Posts: 3465
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Unable to display text and images at the same time

Post by zorg »

Hi and welcome to the forums;

The issue is that you can only have one love.draw defined, and since you're doing it twice, the second overwrites the first.

This fixes it:

Code: Select all

function love.load()
    potato = love.graphics.newImage("potato.png")
end
function love.draw()
    love.graphics.draw(potato, 250, 250)
    love.graphics.print("Here's potato!")
end
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Neox Hopper
Prole
Posts: 8
Joined: Mon Dec 31, 2018 8:20 am

Re: Unable to display text and images at the same time

Post by Neox Hopper »

Oh now I get it, thank you so much for the info :D
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 3 guests