Hey Corona Buddies.
I have a weird problem.
My Sqlite3 database work in Corona Simulator(1076) and in Xcode(4.6.1)
But when i test it on device, iPhone 5 and iPad the database doesn’t grab the level and score.
[lua]-- Import director class
local localGroup = display.newGroup()
local sqlite3 = require(“sqlite3”)
director = require(“director”)
localGroup:insert(director.directorView)
–Create a constantly looping background sound…
bgSound = audio.loadStream(“sounds/bgSound.mp3”) – FIXED BY JEMMY IRAWAN , I THINK YOU’D BETTER MAKE IT GLOBAL VARIABLE, NOT LOCAL, BECAUSE IT WILL BE CALLED IN ANY SCENES.
audio.reserveChannels(1) --Reserve its channel
audio.play(bgSound, {channel=1, loops=-1}) --Start looping the sound.
–Activate multi-touch so we can press multiple buttons at once.
system.activate(“multitouch”)
–Create some level globals used in the game itself/gameWon/gameOver scenes.
_G.amountofLevels = 15
_G.currentLevel = 1
_G.levelScore = 0
–Create a database table for holding the high scores per level in.
–We only need a small database as we dont need to save much information.
local dbPath = system.pathForFile(“levelScores.db3”, system.DocumentsDirectory)
local db = sqlite3.open( dbPath )
–Current 2 levels. Add more rows to make more levels available. Also remember if
–you add an extra row into this database you need to add an exta level to
–“amountofLevels” above.
local tablesetup = [[
CREATE TABLE scores (id INTEGER PRIMARY KEY, highscore);
INSERT INTO scores VALUES (NULL, ‘0’);
INSERT INTO scores VALUES (NULL, ‘0’);
INSERT INTO scores VALUES (NULL, ‘0’);
INSERT INTO scores VALUES (NULL, ‘0’);
INSERT INTO scores VALUES (NULL, ‘0’);
INSERT INTO scores VALUES (NULL, ‘0’);
INSERT INTO scores VALUES (NULL, ‘0’);
INSERT INTO scores VALUES (NULL, ‘0’);
INSERT INTO scores VALUES (NULL, ‘0’);
INSERT INTO scores VALUES (NULL, ‘0’);
INSERT INTO scores VALUES (NULL, ‘0’);
INSERT INTO scores VALUES (NULL, ‘0’);
INSERT INTO scores VALUES (NULL, ‘0’);
INSERT INTO scores VALUES (NULL, ‘0’);
INSERT INTO scores VALUES (NULL, ‘0’);
]]
db:exec( tablesetup ) --Create it now.s
db:close() --Then close the database
–Now change to the menu.
director:changeScene( “menu” )[/lua]
Any ideas?
Thanks.
Jimmi