How to make circles disappear and reappear.

Hello! I’m completely new to this and I need some help. I want to make a game where a white circle pops up in a random place and you have to try to touch it before it disappears. I really appreciate for the help! Thank you!

. @Jenny_Se See this program I wrote back in November.

http://twolivesleft.com/Codea/Talk/discussion/1874#Item_12

Thank you so much! That was really helpful! If you don’t mind, can I ask you another question? How did you make the circles disappear and can they disappear faster as well?

In this section of code, I keep subtracting 1 from showLimit. If showLimit <=1, I stop drawing the circle else I draw the circle with the ellipse command. Each time you tap the circle in time, I draw another circle with the size 1 less than the previous one. So as you keep tapping the circles, they get smaller and you have less time to tap them. If you don’t tap a circle in time, the game is over.


    if start then
        if mainLoop==0 then
            limit=limit-1
            xc=math.random(limit,WIDTH-limit)
            yc=math.random(limit,HEIGHT-limit)
            radius=limit
            showLimit=limit 
            mainLoop=100
        else
            mainLoop=mainLoop-1
            if  showLimit<=1 then
                if xc~=-100 then
                    highScore=true
                    start=false
                end
            else
                showLimit=showLimit-1
                stroke(0,255,0)
                strokeWidth(2)
                noFill()
                ellipse(xc,yc,limit*2,limit*2)
                fill(0,255,0)
                strokeWidth(0)
                ellipse(xc,yc,showLimit*2,showLimit*2)    
            end
        end       
    end

Thank you! You were really helpful!!

.@Jenny_Se Here is a simpler version. Maybe this will help more.


displayMode(FULLSCREEN)

function setup()
    hit=0
    missed=0
    createCircle()
end

function draw()
    background(40, 40, 50)
    fontSize(40)
    fill(255)
    if rad>1 then
        ellipse(x,y,rad)  --draw circle
        rad=rad-1
    else
        createCircle()
        missed = missed + 1
    end
    str=string.format("Hit  %d     Missed  %d",hit,missed)
    text(str,WIDTH/2,HEIGHT-50)
    text("Try to hit the circle",WIDTH/2,HEIGHT-100)
end

function touched(t)
    if t.state==BEGAN then
        if (t.y-y)^2/rad^2+(t.x-x)^2/rad^2 <= 1 then  -- circle tapped
            createCircle()
            hit = hit + 1
        end
    end
end

function createCircle()
    rad=70  --size of circle
    x=math.random(25,WIDTH-25)
    y=math.random(25,HEIGHT-25)
end

Oh, I see! Yeah, this was exactly what I was looking for! Thank you so much!!