I’m not entirely sure which forum to post this in because I’m not entirely sure what the issue is. I could be storyboard but I don’t know…
I wanted to test my app out on my nexus 7 so I built it, and moved it onto the device and ran it.
All of that went fine.
I run the app and it starts up just fine, I get my menu screen with an option for new game.
the new game option screen comes up and I can set my options just fine.
I click on my launch button, which is not a button, but a a newRoundedRect with a touch event listener
-- Launch Button
launch = display.newRoundedRect( 0, 0, 100, 32, 7 )
launch:setReferencePoint(display.TopLeftReferencePoint)
launch.isVisible = true
launch.x = 380
launch.y = 285
launch.id = "Launch"
-- TouchListener
launch:addEventListener("touch", onLaunchTouch)
-- Insert into grid array
mainDisplay:insert(launch)
-- Fill tile with correct color
launch:setFillColor( 157, 173, 249 )
-- Paint a stoke line
launch:setStrokeColor(140, 140, 140)
launch.strokeWidth = 3
-- style text
launch.Text = display.newText( "LAUNCH", 0, 0, native.systemFontBold, 22 )
launch.Text:setReferencePoint(display.CenterReferencePoint)
gamestyle.normal.Text:setTextColor( 255, 255, 255 )
mainDisplay:insert(launch.Text)
launch.Text.x = launch.x + 50
launch.Text.y = launch.y + 16
launch.Text:toFront()
the touch event functions is as follows.
I’m sorry that I’m posting it unabridged but my issue may be in there somewhere and since I’m still in over my head…
-- function to handle Launch Touch
local onLaunchTouch = function ( event )
if event.phase == "began" then
print( "You pressed the Launch Button" )
launch:setStrokeColor( 0, 0, 0 )
-- Load Game Settings Data into an Array
local gameTable = {}
gameTable = loadsave.loadTable("defaultgame.json")
-- If there's a problem
if gameTable == nil then
print( "\nFailed to load gameTable" )
else
print( "\nLoaded gameTable")
end
-- Load map data
local mapTable = {}
mapTable = loadsave.loadTable("defaultmap.json")
-- If there's a problem
if mapTable == nil then
print( "\nFailed to load mapTable" )
else
print( "\nLoaded mapTable")
end
-- Load empire data
local empireTable = {}
empireTable = loadsave.loadTable("defaultempire.json")
-- If there's a problem
if empireTable == nil then
print( "\nFailed to load empireTable" )
else
print( "\nLoaded empireTable")
end
-- Load leader data
local leaderTable = {}
leaderTable = loadsave.loadTable("defaultleader.json")
-- If there's a problem
if leaderTable == nil then
print( "\nFailed to load leaderTable" )
else
print( "\nLoaded leaderTable")
end
-- Assign selected data to gameTable
gameTable[2] = playerCount
gameTable[11] = 1
gameTable[12] = 0
gameTable[13] = length
gameTable[14] = gameType
if style == "Normal" then
for i = 1, playerCount do
empireTable[i][1] = 1500
empireTable[i][2] = 500
empireTable[i][3] = 1000
empireTable[i][4] = 1000
empireTable[i][5] = 250
empireTable[i][6] = 3
end
elseif style == "DeathMatch" then
for i = 1, playerCount do
empireTable[i][1] = 15000
empireTable[i][2] = 5000
empireTable[i][3] = 10000
empireTable[i][4] = 10000
empireTable[i][5] = 2500
empireTable[i][6] = 3
end
end
-- Assign map file to game bases on player choice
-- Save the change
loadsave.saveTable(gameTable, "newGameGame.json")
loadsave.saveTable(mapTable, "newGameMap.json")
loadsave.saveTable(empireTable, "newGameEmpire.json")
loadsave.saveTable(leaderTable, "newGameLeader.json")
-- Clean up the mess
mainDisplay = nil
typeDisplay = nil
playerDisplay = nil
mapDisplay = nil
styleDisplay = nil
timerDisplay = nil
loginDisplay = nil
-- If online then go to game lobby
-- else go to hotseat play and launch the game
storyboard.gotoScene( "overlord", "crossFade", 300 )
end
return true
end
What happens on the device is that it does indeed change the stoke color of “launch” but it doesn’t do anything else. It just sits there.
I installed it onto my phone to see if it would work there, but the behavior is exactly the same. My phone is a Motorola Atrix 2, running ICS
I guess I have a question about the json files I use. For the simulator, I have them located in the documents folder of the sandbox for the project. Did these files get included in the build, or where they suppose to be moved to the location where my main.lua file is located?
It probably isn’t a storyboard issue since I transition from main.lua to newGame.lua with storyboard and that part works…
[import]uid: 170004 topic_id: 35796 reply_id: 335796[/import]