How do I remove drawn images & printed text?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
-
- Citizen
- Posts: 59
- Joined: Sat Mar 07, 2015 11:53 pm
How do I remove drawn images & printed text?
Without removing the file? (for images only)
What I'm trying to do is when a certain position is clicked, it changes backgrounds.
What I'm trying to do is when a certain position is clicked, it changes backgrounds.
-
- Citizen
- Posts: 59
- Joined: Sat Mar 07, 2015 11:53 pm
Re: How do I remove drawn images & printed text?
is it image = nil?
Re: How do I remove drawn images & printed text?
you stop drawing something by not drawing it anymore. That's all there is to it.RBXcpmoderator12345 wrote:Without removing the file? (for images only)
What I'm trying to do is when a certain position is clicked, it changes backgrounds.
Re: How do I remove drawn images & printed text?
Something like this:
Then have something in love.update that sets imageClicked to true on click.
Code: Select all
-- in love.draw
if imageClicked then
-- Draw one thing
else
-- Draw another thing
end
GitHub | MLib - Math and shape intersections library | Walt - Animation library | Brady - Camera library with parallax scrolling | Vim-love-docs - Help files and syntax coloring for Vim
- TheOddByte
- Prole
- Posts: 35
- Joined: Sun Dec 15, 2013 7:15 pm
Re: How do I remove drawn images & printed text?
Or he could use love.mousepresseddavisdude wrote: Then have something in love.update that sets imageClicked to true on click.
But as I see this it's easiest as suggested by davisdude, now if you have multiple images and want to change an image depending on where you clicked or something it's better to use a table where you contain all of them.
Code: Select all
local index = 1
local images = {
love.graphics.newImage( "foo.png" );
love.graphics.newImage( "bar.png" );
}
function love.draw()
love.graphics.draw( images[index], 1, 1 )
end
function love.mousepressed( x, y, button )
// Some code here
end
What's the object-oriented way to get wealthy? Inheritance.
-
- Citizen
- Posts: 59
- Joined: Sat Mar 07, 2015 11:53 pm
Re: How do I remove drawn images & printed text?
my updated code:
Ignore the names of the images I'm trying to load, the characters are based on people from another site and they requested to be named that way
Code: Select all
function wait(time) -- so I do less typing and i feel familiar with it
love.timer.sleep(time)
end
function updateGameMode()
gameMode = "playing"
end
function love.load() -- LOAD ALL THE IMAGES AND SOUNDS
Master_Illumina = love.graphics.newImage("Master Illumina (illuminabreaks).png")
fanzo = love.graphics.newImage("fanzo (guestslovepizza).png")
narbthenoob = love.graphics.newImage("narbthenoob (luckyleo1231).png")
newbag = love.graphics.newImage("newbag (damanius).png")
wires = love.graphics.newImage("wires.exe (vengancevinny).png")
mask = love.graphics.newImage("mask (lolhatz).png")
wizgo = love.graphics.newImage("wizgo (creepywriter).png")
character = love.graphics.newImage("gfx/character.png")
ghost = love.graphics.newImage("ghost.mp4 (successfulfundude).png")
plush1 = love.graphics.newImage("plushie (blockopsmaster).png")
plush2 = love.graphics.newImage("plushie2(Robloxia38).png")
theme = love.audio.newSource("werenotalone(spookysoundtrack.com).mp3")
scream = love.audio.newSource("scaryscream(soundbible.com).mp3")
gameMode = "nothing yet"
kaito4life = love.graphics.newImage("Kaito4life(collestgirl).png")
end
backgrounds = {
love.graphics.newImage("background.png");
love.graphics.newImage("titlescreen.png");
}
function love.draw()
love.graphics.draw(backgrounds[index], 1, 1)
end
function love.keypressed(key)
if key == "q" then
love.graphics.draw(backgrounds[2])
else
wait(10000000000000000000000000000000000000000000000000000000000000000)
print("Why are you waiting this long!!?!?!?!?")
end
end
-
- Citizen
- Posts: 59
- Joined: Sat Mar 07, 2015 11:53 pm
Re: How do I remove drawn images & printed text?
You can't draw anything outside of love.draw()
Code can look like this:
Code can look like this:
Code: Select all
curr = 1
function love.draw()
love.graphics.draw(backgrounds[curr])
end
function love.keypressed(key)
if key == "q" then
curr = 2
else
-
- Citizen
- Posts: 59
- Joined: Sat Mar 07, 2015 11:53 pm
Re: How do I remove drawn images & printed text?
can i have a function in a if statement in a function then?
like this:
like this:
Code: Select all
function love.keypressed(key)
if key == "q" then
function love.draw()
love.graphics.draw(image)
end
end
end
Re: How do I remove drawn images & printed text?
Yes, you can. But why do you want to put love.draw() inside keyboard event?
Who is online
Users browsing this forum: Google [Bot] and 3 guests