I NEED HELP (pls)

How can i remove an if???

@Killer.Jo - can you give us a little more information?

If your talking about an if construction in the editor you just need to select it to highlight it, adjust with the selection tabs on it, then tap the selected area to get up the options menu (if it’s not already up) and select delete.

How can i remove the if (at the Touch)

Do you Need More Information because I dont know how to explain ist well (and i dont speak ENGLISH)

I can’t see the end of the line but it looks like there may be a close bracket. If so tap just after the close bracket and delete it. Now tap the space just after the if and you should be able to delete it, then edit the line as you need.

I mean how can i remove the if with Code? and can you also Show me the Code?

@Killer.Jo - sorry, I see what you mean now. What do you need to do with this code after you have initiated the condition by touching the screen ?

Try this


--- killer01
viewer.mode = FULLSCREEN
function setup()
    --
    var = "Waiting"
end

function draw()
    -- 
    background(40, 40, 50)
    fill(236, 78, 67)
    font("Arial-BoldMT")
    fontSize(64)
    text(var,WIDTH/2,HEIGHT/2)
    spriteMode(CENTER)
    sprite(asset.builtin.Planet_Cute.Character_Boy,347,420)
end

function touched(t)
    --
    if t.state == BEGAN then
        var = "Taaaaraaaah!!!!"
    end
end


1 Like

OMG THANKS you help me so much

I‘ll ask you if I have more problems

Can you give me another Code where when you click on a position (a Button with sprite) that the if no longer works?

OK, this adds more code to define aspects of the code. Is this what you wanted:


viewer.mode = FULLSCREEN
function setup()
    --
    var = "Waiting"
    pressed = false
    pfill = color(255, 0, 207)
    bsite = vec2(WIDTH/2,200)
end

function draw()
    -- 
    background(40, 40, 50)
    fill(236, 78, 67)
    font("Arial-BoldMT")
    fontSize(64)
    text(var,WIDTH/2,HEIGHT/2)
    spriteMode(CENTER)
    sprite(asset.builtin.Planet_Cute.Character_Boy,347,420)
    fill(pfill)
    ellipseMode(CENTER)
    ellipse(bsite.x,bsite.y,84,84)
end

function touched(t)
    --
    if t.state == BEGAN then
        var = "Taaaaraaaah!!!!"
        if inCircle(t.pos,bsite,42) and pressed == false then
            pressed = true
            pfill = color(236, 231, 67)
        else 
            pressed = false
            pfill = color(255, 0, 207)
        end
    end
end

function inCircle(p, c, r)    
    -- p is the point, c is the center of the circle, and r is the radius
    local dist = math.sqrt((p.x - c.x)^2 + (p.y - c.y)^2)
    if dist < r then return true else return false end
end

You finally answered!
Thaaaaaannnnnks!!!

@killer.jo - where are you based, i’m in the UK. Also there’s a cup match on this afternoon. Replied as soon as I saw your message, sorry if it was a bit slow.

I meant you should make sure that the text „taaaaraaah“ should be not be displayed but a Sprite!!

What about this :slight_smile:


viewer.mode = FULLSCREEN
function setup()
    --
    var = "Waiting"
    pressed = false
    pfill = color(255, 0, 207)
    bsite = vec2(WIDTH/2,200)
end

function draw()
    -- 
    background(40, 40, 50)
    fill(236, 78, 67)
    font("Arial-BoldMT")
    fontSize(64)
    text(var,WIDTH/2,HEIGHT/2)
    spriteMode(CENTER)
    sprite(asset.builtin.Planet_Cute.Character_Boy,347,420)
    if pressed then
        sprite(asset.builtin.Planet_Cute.Character_Horn_Girl,WIDTH/2,700)
    else 
        sprite(asset.builtin.Planet_Cute.Enemy_Bug, WIDTH/2, 700)
    end
    fill(pfill)
    ellipseMode(CENTER)
    ellipse(bsite.x,bsite.y,84,84)
end

function touched(t)
    --
    if t.state == BEGAN then
        if inCircle(t.pos,bsite,42) and pressed == false then
            pressed = true
            pfill = color(236, 231, 67)
        else 
            pressed = false
            pfill = color(255, 0, 207)
        end
    end
end

function inCircle(p, c, r)    
    -- p is the point, c is the center of the circle, and r is the radius
    local dist = math.sqrt((p.x - c.x)^2 + (p.y - c.y)^2)
    if dist < r then return true else return false end
end

Your are the best!!!

How can i make several of these touches?

Bit more info needed - several touches(buttons) or one button multiple times?

More Buttons please
(If it‘s okay Witz you)