Hi,
I have developed my first game in corona simulator. I am wondering why the newtextfile object has different behavoir during the simulation than during device execution.
The code has a newtextfile to indicate the number of players. I want this box to have a default value, so:
NumPlayersField = native.newTextField(display.contentCenterX+100, display.contentCenterY+10, 35, 35 ) NumPlayersField.inputType = "number" --Default value NumPlayersField.text = "4" NumPlayers=tonumber(NumPlayersField.text) composer.setVariable("NumPlayers",NumPlayers)
NumPlayers is the local varible that store this default value (“4”) and the next scene reads this value:
NumPlayers=composer.getVariable("NumPlayers")
During the simulation, the value of this variable is filled with this default value but not during the execution in the device. The game crashes because the next scene has a for loop that depends on this value NumPlayers and this variable is empty.
NOTE: I have also tried this with NumPlayers as global variable instead of local.