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
config.lua file:
[code]
application =
{
content =
{
width = 320,
height = 480,
scale = “letterbox”,
fps = 60,
antialias = false,
xalign = “center”,
yalign = “center”,
}
}
[/code] [import]uid: 53445 topic_id: 11089 reply_id: 311089[/import]