With the code below, I’m having several problems with touches on the device.
Works o.k on the simulator.
First, there is a slight delay when I touch a button.
Second, I have to touch about 15 pixels above the buttons before they work.
Also, does Multi-touch work with Android devices. I tried PONG by h5apps.com and
multi-touch doesn’t work correctly.
I’m testing on a Galaxy Tab(screen res: 1024x600) O.S. 2.2 and I’m using the
latest Corona build: 2011.536
menu.lua file:
-- MAIN MENU SCREEN --
function screen()
-- Create menu
local menuGroup = display.newGroup()
-- Display menu screen
local menuBG = display.newImageRect("menu.png", 480, 320)
menuBG.x = 480 \* 0.5; menuBG.y = 320 \* 0.5
menuGroup:insert(menuBG)
-- New game button
newGameBTN = display.newImageRect("newgameBtn.png", 270, 36)
newGameBTN.x = 312; newGameBTN.y = 193
newGameBTN.name = "newGameBTN"
menuGroup:insert(newGameBTN)
-- Settings button
settingsBTN = display.newImageRect("settingsBtn.png", 270, 36)
settingsBTN.x = 312; settingsBTN.y = 247
settingsBTN.name = "settingsBTN"
menuGroup:insert(settingsBTN)
-- Statistics button
statisticsBTN = display.newImageRect("statisticsBtn.png", 270, 36)
statisticsBTN.x = 312; statisticsBTN.y = 291
statisticsBTN.name = "statisticsBTN"
menuGroup:insert(statisticsBTN)
local function init(event)
-- NEW GAME --
if (event.target.name == "newGameBTN") then
-- Button click sound
audio.play(menuClickSnd)
-- Remove button listeners
newGameBTN:removeEventListener("tap", init)
settingsBTN:removeEventListener("tap", init)
statisticsBTN:removeEventListener("tap", init)
-- Unload main menu screen
display.remove(menuGroup); menuGroup = nil
-- Create game field for new game
maingame.screen()
-- SETTINGS --
elseif(event.target.name == "settingsBTN") then
-- Button click sound
audio.play(menuClickSnd)
-- Disable button event listeners
newGameBTN.isVisible = false
settingsBTN.isVisible = false
statisticsBTN.isVisible = false
-- Load settings screen
settings.screen()
-- STATISTICS --
elseif(event.target.name == "statisticsBTN") then
-- Button click sound
audio.play(menuClickSnd)
-- Disable button event listeners
newGameBTN.isVisible = false
settingsBTN.isVisible = false
statisticsBTN.isVisible = false
-- Load statistics screen
statistics.screen()
end
end
-- Menu button listeners
newGameBTN:addEventListener("tap", init)
settingsBTN:addEventListener("tap", init)
statisticsBTN:addEventListener("tap", init)
return menuGroup
end
@millerszone,
I tried building an old build for my pre-ARMv7 Android 2.2 and had a similar issue where the touches took likfe forever as if it froze and they were a bit off synch from the position of the button, I thought it had something to do with that small little Android device of 320x240
but if you are having issues with A Galaxy Tab, then it is something else, no tmy device alone.
If I run the code above on a Galaxy Tab for the first time ,
it looks like the screen drops down about 20 pixels, that’s why I have
to click about 20 pixels above the buttons. If I close the app with the home
button and run the app again, the screen is where it suppose to be and all buttons work.
If I exit the app with the Task Manager and run the app again,
the screen drops 20 pixels and the buttons are misaligned to the touch.
So it looks like it only happens the very first time you run the app.
Can someone else verify with a TAB?
EDIT: I un-installed app, then re-installed, now I have to click about 20 pixels above
buttons to make them work even though the screen is aligned.
So inconsistent results.
Could it because I’m using 480x320 screen? I’ll have to try 1024x600 images.
The problem seems to be when using landscape mode on a Galaxy Tab.
I downloaded 3 Corona SDK games from the Android Marketplace, 3
each of landscape and portrait modes.
The 3 landscape games had the same problems as described above. Gap (about 15 pixels)at the
top of the screen and you have to touch above the buttons before they work.
The 3 portrait mode games worked perfect, screen did not have a gap and all the buttons worked to the touch.
Hi Millerszone,
I have the problem with games in Portrait mode.
Try BlastMonkey for example. The gap is there and it means that touch events are shifted cca 20px up so sometimes is hard to tap level buttons.
Could you send me names of those Corona SDK games that work on your Galaxy Tab without the gap ?
Probably they use some “special” trick that we don’t know about…
Then it looks like the problem is in older firmware version 2.2 on my Galaxy Tab.
So probably I can’t do anything with that except upgrading the firmware.
It’s great to hear that our game Orbital Defender works on your G-Tab!
Thanks for helping with the testing!
Dusan http://addictivezone.com
[import]uid: 5411 topic_id: 11089 reply_id: 42535[/import]
I did a little more testing.
If you run a “landscape app” in portrait position, then there will be no gap
and and all buttons work.
[import]uid: 53445 topic_id: 11089 reply_id: 42537[/import]
FWIW we currently have open issues specifically with Galaxy Tab and positioning. Unfortunately we don’t know what the prognosis is. [import]uid: 6787 topic_id: 11089 reply_id: 43956[/import]
I’m also having this problem with a Samsung Galaxy S2 that I’ve recently bought. I’m doing a game and the “touch coordinates” of my objects are shifted 20px up.
Is there anything we could do to solve this issue? [import]uid: 46216 topic_id: 11089 reply_id: 44677[/import]