collide

i took out the 'If" and it said “= expected”

@dave1707

Is this what you want.


displayMode(FULLSCREEN)

function setup()
    c1=physics.body(CIRCLE,40)
    c1.x=400
    c1.y=200
    c1.gravityScale=0
    c1.info="c1"
    
    c2=physics.body(CIRCLE,10)
    c2.x=500
    c2.y=1000
    c2.gravityScale=.2
    c2.info="c2"
    
    c3=physics.body(CIRCLE,10)
    c3.x=300
    c3.y=1000
    c3.gravityScale=.2
    c3.info="c3"
        
    x,y=0,0
    sx=WIDTH/2
    sy=HEIGHT/2
end

function draw()
    background(40, 40, 50)
    fill(255)
    sprite("Planet Cute:Character Boy",c1.x,c1.y)
    if x+y>0 then
        c1.x=c1.x+(tx-x)/10
        c1.y=c1.y+(ty-y)/10
        fill(255)
        ellipse(x,y,8)    -- draw circle center
        noFill()
        stroke(255)
        strokeWidth(4)
        ellipse(x,y,200)    -- draw outer circle
    end
    sprite("Planet Cute:Character Cat Girl",c2.x,c2.y)
    if c2.y<0 then
        c2.y=1000
        c2.linearVelocity=vec2(0,0)
    end
    sprite("Planet Cute:Character Boy",c3.x,c3.y)
    if c3.y<0 then
        c3.x=300
        c3.y=1000
        c3.linearVelocity=vec2(0,0)
    end
end

function collide(c)
    if c.state==BEGAN then
        restart()
    end   
end

function touched(t)
    if t.state==BEGAN then    -- starting center point
        x=t.x
        y=t.y
        tx=x
        ty=y
    elseif t.state==MOVING then
        tx=t.x
        ty=t.y
    elseif  t.state==ENDED then    -- done moving
        x,y=0,0
    end
end

i tried that and it ether glitches a bunch or exits out of the hole codea app

@dave1707

OK, make the collide function look like what’s below.


function collide(c)
    if c.state==BEGAN then
            restart()
    end   
end

i dont know why but when i put the collide code into my game it didnt work. it kept doing wierd things @dave1707