The Original question:
I created the love.graphics.print in the love.draw() function, but how can I remove it, without clearing the whole screen?
The answer:
1. Define a boolean in the love.load()
2. When your requirements for the clearing are matched change the "boolean" to false (or whatever)
3. After changing it to false call the love.draw()
4. In the love.draw put your love.graphics.print in an if statement that only gets processed when the "boolean" is "true"
5. ???
6. Profit
How can i remove a "love.graphics.print" ?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
How can i remove a "love.graphics.print" ?
Last edited by Jack5500 on Wed Dec 07, 2011 9:44 pm, edited 2 times in total.
Re: Hwo can i remove a "love.graphics.print" ?
Please post some code and describe the actual problem you're having.
Re: How can i remove a "love.graphics.print" ?
Code: Select all
function love.load()
width = love.graphics.GetWidth()
height = love.graphics.GetHeight()
love.graphics.setFont(18)
player ={
grid_x = 256,
grid_y = 256,
act_x = 200,
act_y = 200,
speed = 10
}
playertext ={
one_x = player.act_x,
one_y = player.act_y
}
WelcomeText ={
width = width/2,
height = height/2
}
end
function love.update(dt)
playertext.one_y = player.act_y - 24
playertext.one_x = player.act_x - 16
player.act_y = player.act_y - ((player.act_y - player.grid_y) * player.speed * dt)
player.act_x = player.act_x - ((player.act_x - player.grid_x) * player.speed * dt)
if player
end
function love.draw()
love.graphics.rectangle("fill",player.act_x,player.act_y,32,32)
love.graphics.print("Player 1", playertext.one_x, playertext.one_y)
love.graphics.print("Start the interaction press any key", WelcomeText.width, WelcomeText.height)
end
function love.keypressed(key)
if key == "up" then
player.grid_y = player.grid_y - 32
elseif key == "down" then
player.grid_y = player.grid_y + 32
elseif key == "left" then
player.grid_x = player.grid_x - 32
elseif key == "right" then
player.grid_x = player.grid_x + 32
end
end
Re: How can i remove a "love.graphics.print" ?
Oh, right.
Well, the screen is cleared before every love.draw anyway, so you just don't call the print() if you don't want to show it on-screen.
Well, the screen is cleared before every love.draw anyway, so you just don't call the print() if you don't want to show it on-screen.
Re: How can i remove a "love.graphics.print" ?
No, I want to remove it after a key is pressed, which I could code in the "function love.keypressed(key)" part. But I would need an actual comamnd to erase that command.
With your suggestion I'd have to make a boolean variable to declare if the text is drawn or not, which isn't the best solution, is it?
With your suggestion I'd have to make a boolean variable to declare if the text is drawn or not, which isn't the best solution, is it?
Re: How can i remove a "love.graphics.print" ?
It is kind of the best solution.
The "real" solution would be to use a Finite State system to manage what part of the game you're in (menu, playing, score screen, et.c.).
There are plenty of libraries for that.
See also the thread in General: FSM - Finite State Machine.
The "real" solution would be to use a Finite State system to manage what part of the game you're in (menu, playing, score screen, et.c.).
There are plenty of libraries for that.
See also the thread in General: FSM - Finite State Machine.
Re: How can i remove a "love.graphics.print" ?
Okay, thanks very much. I've added the solution to my first posts, so people who are itnerested in the solution can easily see it. Thanks again. I'll surely have more concern, good to know that there is a strong community beyond Löve
Who is online
Users browsing this forum: Ahrefs [Bot] and 36 guests