Coding the "width" and "height" of my button to 1280x720, makes my screen become somekind of button

I’m new to Corona, so i have this problem. I have watched tutorials for creating buttons and i learn it quickly, but i have a problem when i code the size of the button with a defaultFile and overFile, when i start to create a button for example:

  local function ButtonEventHandler(event)
        local phase = event.phase

        if event.phase == “ended” then
            print(" button has been pressed")
            storyboard.gotoScene(“scene1”, “slideLeft”, 100)
            return true
        end
   end

local Button1 = widget.newButton( {
        left = 100,
        top = 100,
        width = 1280,
        height = 720,
        defaultFile = “Buttons/image.png”,
        overFile = “Buttons/imageoff.png”,
        onEvent = ButtonEventHandler,
    } );
 

it works fine until, when i click the background(not the button) it proceed to my desire scene, i can’t solve the problem. maybe because of the size of the buttons width and height? cause when i change it to smaller size it works fine. but it’s too small(the image of the button). so i try to make it big making it 1280x720 like the size of the image then wherever i clicked on the  background it’s like it became button. Sorry for bad English. i need help

You don’t want to try to make your button the size of the screen.  I’m not sure of the exact coding on this (maybe someone after me can help with that) but you need to add an event listener that when you “tap” on the screen, it’ll run the scene change.

something like [lua]addEventListener:(“tap”, changeScene)[/lua] where changeScene is the function that does what its name says.

Runtime:addEventListener("tap", changeScene)

is what you were referring to mdbonneaux

^ and don’t forget to remove the listener once you no longer need it.

Have you trimmed the button images? Removing all the transparent pixels around them.

Because if setting the button to 1280x720 makes the touch area as big as your screen, and if we set it to a lower value makes the button too small, chances are that your images have a lot of transparent areas.

You don’t want to try to make your button the size of the screen.  I’m not sure of the exact coding on this (maybe someone after me can help with that) but you need to add an event listener that when you “tap” on the screen, it’ll run the scene change.

something like [lua]addEventListener:(“tap”, changeScene)[/lua] where changeScene is the function that does what its name says.

Runtime:addEventListener("tap", changeScene)

is what you were referring to mdbonneaux

^ and don’t forget to remove the listener once you no longer need it.

Have you trimmed the button images? Removing all the transparent pixels around them.

Because if setting the button to 1280x720 makes the touch area as big as your screen, and if we set it to a lower value makes the button too small, chances are that your images have a lot of transparent areas.