Button Press Issue

My game is working fine for the most part but do have a question about buttons. Sometimes when I press it button nothing happens. Then other times I have to push it a few times. Is there anything that I can do different in the coding to issue when the button is tapped it always activates? I am using director and I also have a few global variables but nothing else special in the coding. Just curious if I’m being a little too picky or if there is really something wrong. Other than that everything is working perfectly.

Michelle [import]uid: 72372 topic_id: 13781 reply_id: 313781[/import]

post you code here and we will try to help you [import]uid: 16142 topic_id: 13781 reply_id: 50606[/import]

As darkconsoles said, we really need to see your code to work out what’s causing the issue :wink: [import]uid: 52491 topic_id: 13781 reply_id: 50714[/import]

Okay I didn’t post code because I wasn’t sure what to post. It doesn’t happen every time but it could happen on any screen when it does happen. this is the coding from one screen. I just thought that using some things like global variables or something could cause it.

[lua]module(…, package.seeall)

function new()
local localGroup = display.newGroup()
–> This is how we start every single file or “screen” in our folder, except for main.lua
– and director.lua
–> director.lua is NEVER modified, while only one line in main.lua changes, described in that file


local ui = require(“ui”)

local screen5 = display.newImage (“screen5.png”)
localGroup:insert(screen5)
–> This sets Screen5

local house = display.newImage (“house.png”)
house.x = 45
house.y = 50
house.xScale = .5
house.yScale = .5
localGroup:insert(house)
–>This places the House

local function touchedHouse (event)
if (“ended” == event.phase) then
director:changeScene (“titlescreen”)
media.playEventSound( “click_x.caf” )
end
end

house:addEventListener (“touch”, touchedHouse)

local brain = display.newImage (“brain.png”)
brain.x = 165
brain.y = 390
brain.xScale = .4
brain.yScale = .4
localGroup:insert(brain)
–>This places the brain

local hiphop = display.newImage (“hiphop.png”)
hiphop.x = 80
hiphop.y = 385
hiphop.xScale = .4
hiphop.yScale = .4
localGroup:insert(hiphop)
–>This places Hiphop

local function touchedbrain (event)
if (“ended” == event.phase) then
director:changeScene (“screen6”)
media.playEventSound( “click_x.caf” )
_G.numberOne = numberFieldOne.text

end
end

brain:addEventListener (“touch”, touchedbrain)

local backbutton = display.newImage (“backbutton.png”)
backbutton.x = 270
backbutton.y = 50
backbutton.xScale = .4
backbutton.yScale = .4
localGroup:insert(backbutton)

local function touchedBackbutton (event)
if (“ended” == event.phase) then
director:changeScene (“screen4a”)
media.playEventSound( “click_x.caf” )
end
end

backbutton:addEventListener (“touch”, touchedBackbutton)
–>This places the backbutton

–>MUST return a display.newGroup()


–> This is how we end every file except for director and main, as mentioned in my first comment

return localGroup[/lua] [import]uid: 72372 topic_id: 13781 reply_id: 50721[/import]

seems fine to me
_G.numberOne = numberFieldOne.text – maybe this is problem part, try to change it somehow
and put print statements in all parts that seems not good for you, it can help a lot [import]uid: 16142 topic_id: 13781 reply_id: 50726[/import]

I have a Galaxy Tab and had problems with buttons. The problem was that I had to touch about 15
Pixel above the button to make them work, but this problem was fixed several builds back.

Probably not your problem, but make sure you have the latest build.

[import]uid: 53445 topic_id: 13781 reply_id: 50728[/import]

I’m new to the programming world but what do the print statements do? [import]uid: 72372 topic_id: 13781 reply_id: 50729[/import]

print() statements used to determine whenever there’s a problem in your code(just for debugging purposes)
you can simply put some print(“your text”) after every line in function and if function is not stumbling with something you will get your print message in Terminal window
in print you can put functions, variables to see if they are changed after some event e.t.c
try it [import]uid: 16142 topic_id: 13781 reply_id: 50731[/import]

I second trying what darkconsoles suggests, using print() to see where the code might be breaking.

I’m also curious, are any errors at all being shown in the terminal window at any point? [import]uid: 52491 topic_id: 13781 reply_id: 50875[/import]

I have the same issue as described with Galaxy tab but I am testing with nook color. Every button works perfectly in the simulator but on the device, I have to tap the top edge of the button for it to register. I wish I could figure this out. I am really impressed with Corona except this one issue holding me back from becoming a subscriber and moving forward. [import]uid: 85127 topic_id: 13781 reply_id: 54450[/import]

Hey sorheim,

The NOOK is not yet supported. Sorry. Once it is if it has bugs, they’ll be squashed but until then you may want to test on a device we support. (Any Android with ARMv7 + and 2.2 + or iOS devices.)

Peach :slight_smile: [import]uid: 52491 topic_id: 13781 reply_id: 54518[/import]

Why NOOK is not yet supported?

The CPU use the ARMv7 instruction set and Android is 2.2

http://en.wikipedia.org/wiki/Texas_Instruments_OMAP#OMAP_3
Regards
Marco
[import]uid: 7518 topic_id: 13781 reply_id: 55943[/import]

A forum search will reveal there are already existing threads on that topic. [import]uid: 52491 topic_id: 13781 reply_id: 56000[/import]