A litlle advice

Hello

I have a button that skips in 2 different positions randomly. Now I want that if I click on the button somenthing must happen but if click on another part of the screen should happen something else. this is what i coded at this moment.

local button = display.newImage("button.png") local position = { 123, 23, } funciton skip(event) transition.to(button{time = 0 , x = position[math.random=(1,2)]}) end button:addEventListener("touch" , skip)

Now I don’t know how to proceed

What I would do is have an invisible button that covers the whole screen.  You can make it respond using .isHitTestable:

local wholeScreenBtn = display.newRect(display.contentCenterX, display.contentCenterY, display.contentWidth, display.contentHeight)

wholeScreenBtn.fill = {1, 1, 1}

wholeScreenBtn.isVisible = false

wholeScreenBtn.isHitTestable = true

wholeScreenBtn:addEventListener(“touch”, functionToHandleOtherTouches)

Then draw your other button on top.  Then any touch events that your button intercepts will get handled by that function, any other touches get handled by the other function.

What I would do is have an invisible button that covers the whole screen.  You can make it respond using .isHitTestable:

local wholeScreenBtn = display.newRect(display.contentCenterX, display.contentCenterY, display.contentWidth, display.contentHeight)

wholeScreenBtn.fill = {1, 1, 1}

wholeScreenBtn.isVisible = false

wholeScreenBtn.isHitTestable = true

wholeScreenBtn:addEventListener(“touch”, functionToHandleOtherTouches)

Then draw your other button on top.  Then any touch events that your button intercepts will get handled by that function, any other touches get handled by the other function.