Bubble Wrapp help

Have to create an app using codea for my CS class, so I’m doing a bubble wrap one!
I’m telling codea using if statements that if a tap is within a certain area, the bubble picture, to display a popped bubble picture and make a popping sound. The popping sound works, but it refuses to display another sprite. Any suggestions or do you have a better idea on how to accomplish this, as mine is very wasteful?
For example:

function draw()
    sprite("Dropbox:bubble",WIDTH/11.3,HEIGHT/1.16,150)
end

function touched(touch)
    if touch.state == BEGAN then
        if touch.x > WIDTH/65 and touch.x < WIDTH/6.2
          and touch.y > HEIGHT/1.31 and touch.y < HEIGHT/1.04 then
            sprite("Dropbox:bubble popped",WIDTH/11.3,HEIGHT/1.16,150)
            sound(SOUND_EXPLODE, 6551) 
        end
        ...
    end
end

@Charliefaber Set a flag in touched. Move the sprite in touched up in draw. If the flag is set, draw the popped sprite else draw the original sprite.

I’m sorry, can you give me an example? I’ve never used a flag before.


function setup()
    t=false
end

function draw() 
    if t then
        sprite("Dropbox:bubble popped",WIDTH/11.3,HEIGHT/1.16,150) 
    else
        sprite("Dropbox:bubble",WIDTH/11.3,HEIGHT/1.16,150)
    end
end

function touched(touch) 
    if touch.state == BEGAN then 
        if touch.x > WIDTH/65 and touch.x < WIDTH/6.2 and 
            touch.y > HEIGHT/1.31 and touch.y < HEIGHT/1.04 then 
            t=true            
            sound(SOUND_EXPLODE, 6551) 
        end
    end 
end

Fantastic way to do it! Thank you so much sir for the quick and helpful reply!

@Charliefaber If you never used a flag, then a flag can be anything you want it to be. In this case, I’m using “true” and “false”. In the “if” statement, “if t” looks for true. If you want “false”, then it would be “if not t”.