Help me!

Help me!!!

How can do appear the text “you win”, when circle is moved into circle1???

code:

local W = display.contentWidth / 2
local H = display.contentHeight / 2

 

local circle = display.newCircle(W, H-130, 50)
circle.strokeWidth =3

 

local circle1 = display.newCircle(W, H+100, 70)
circle1.strokeWidth =3
circle1:setFillColor(0, 0, 0)
circle1:setStrokeColor(255, 255, 255)

 

local function dragMe(event)
local t=event.target
if event.phase==“moved” then
t.x=event.x
t.y=event.y
end
end

You would change your dragMe function to this:

[lua]

local function dragMe(event)

    local t=event.target

    if event.phase==“moved” then

        t.x=event.x

        t.y=event.y

        if t.x == circle1.x and t.y == circle1.y then

        --if both circles x’s and y’s are the same then…

            print(“Circles On Each Other”)

            --create text

            local winText = display.newText(“You Win!”, 0, 0, native.systemFont, 20)

        end

    end

end

[/lua]

I’m not sure what you’re trying to do but you might run into the problem of the circles being difficult to move into because right now they have to be exactly centered on eachother and the text will constantly be spawned if they are moved there over and over. If you need help fixing these just ask. :slight_smile:

and what can i do if the x’s and the y’s are not the same???

You would change your dragMe function to this:

[lua]

local function dragMe(event)

    local t=event.target

    if event.phase==“moved” then

        t.x=event.x

        t.y=event.y

        if t.x == circle1.x and t.y == circle1.y then

        --if both circles x’s and y’s are the same then…

            print(“Circles On Each Other”)

            --create text

            local winText = display.newText(“You Win!”, 0, 0, native.systemFont, 20)

        end

    end

end

[/lua]

I’m not sure what you’re trying to do but you might run into the problem of the circles being difficult to move into because right now they have to be exactly centered on eachother and the text will constantly be spawned if they are moved there over and over. If you need help fixing these just ask. :slight_smile:

and what can i do if the x’s and the y’s are not the same???