Page 1 of 1

how to make a shape disapear?

Posted: Tue Sep 20, 2022 12:13 am
by ColdSweat558
shape example: love.graphics.rectangle(mode, x, y, width, height)
use this to explain to me

Re: how to make a shape disapear?

Posted: Tue Sep 20, 2022 12:29 am
by pgimeno
Every frame, the screen is cleared and you have to redraw everything that you want to be on the screen

If you want to make a shape disappear, don't draw it when you no longer want it to appear.

Here's an example to make a rectangle disappear at the end of a given time (4 seconds). When the timer expires, the 'if' condition is no longer true, and the rectangle is not drawn.

Code: Select all

local disappear_time = 4

function love.update(dt)
  if disappear_time > 0 then
    disappear_time = disappear_time - dt
  end
end

function love.draw()
  if disappear_time > 0 then
    love.graphics.rectangle("fill", 200, 200, 400, 200)
  end
end

Re: how to make a shape disapear?

Posted: Tue Sep 20, 2022 9:20 am
by darkfrei
1. Make a list of objects.
2. Draw all objects from this list
3. Delete some objects from the list.

Re: how to make a shape disapear?

Posted: Tue Sep 20, 2022 9:20 pm
by ColdSweat558
thanks pgimeno