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

post you code here and we will try to help you

As darkconsoles said, we really need to see your code to work out what's causing the issue ;)

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.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
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

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

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.

I'm new to the programming world but what do the print statements do?

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

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?

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.

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 :)

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

A forum search will reveal there are already existing threads on that topic.

views:1749 update:2011/10/4 8:06:35
corona forums © 2003-2011