Hey guys I have a Problem:
So I want to create a Quiz Game and the Game should check if I already made the Quiz if so it should update a false image to a true image.
Here:
local rimage = display.newImage(localGroup, "images/rightPreview.png")
rimage.x, rimage.y = 50, 90;
rimage.alpha = 0
local wimage = display.newImage(localGroup, "images/wrongPreview.png")
wimage.x, wimage.y = 50, 90;
wimage.alpha = 1
function checkQuizes()
for l = 1, 1, 1 do
if l == i then
if sqls.getInformation("name", 1, "l" .. i) == 1 then
rimage.alpha = 1
wimage.alpha = 0
end
end
end
end
checkQuizes();
And the Database get updated when you finished the Quiz here:
function updateSQL(e)
for i = 1, 10, 1 do
if i == e then
sqls.updateRowInTable(1, "name", 1, "l" .. e, 1)
else
sqls.updateRowInTable(1, "name", 1, "l" .. i, sqls.getInformation("name", 1, "l" .. i) )
end
end
end
function goButton:touch(e)
if e.phase == "ended" then
if defaultField.text == nil then
wimage.alpha = 1;
rimage.alpha = 0;
else
if defaultField.text == correctText then
updateSQL(1)
wimage.alpha = 0;
rimage.alpha = 1;
else
wimage.alpha = 1;
rimage.alpha = 0;
end
end
end
end
SQL:
function updateRowInTable(id, databasename, speicherplatz, l, varL)
local path = system.pathForFile( databasename .. ".db", system.DocumentsDirectory )
local db = sqlite3.open( path )
local tablesetup = [[CREATE TABLE IF NOT EXISTS levels (id INTEGER PRIMARY KEY, l1 INTEGER, l2 INTEGER, l3 INTEGER, l4 INTEGER, l5 INTEGER, l6 INTEGER, l7 INTEGER, l8 INTEGER, l9 INTEGER, l10 INTEGER);]]
db:exec( tablesetup )
local q = [[UPDATE levels SET ']] .. l .. [[' =']] .. varL .. [[' WHERE id=']] .. speicherplatz ..[[';]]
db:exec( q )
end
and
function getInformation(databasename, speicherplatz, informationsname)
local path = system.pathForFile( databasename .. ".db", system.DocumentsDirectory )
local db = sqlite3.open( path )
for row in db:nrows("SELECT " .. informationsname .. " FROM levels WHERE id=" .. speicherplatz) do
for k = 1, 10, 1 do
if informationsname == "l" .. k then
if k == 1 then return row.l1
elseif k == 2 then return row.l2
elseif k == 3 then return row.l3
elseif k == 4 then return row.l4
elseif k == 5 then return row.l5
elseif k == 6 then return row.l6
elseif k == 7 then return row.l7
elseif k == 8 then return row.l8
elseif k == 9 then return row.l9
elseif k == 10 then return row.l10
end
end
end
end
So my Problem is on my Windows 7 Pc it worked, but when I install my Game on my Android Phone ( Sony Xperia U ) it doesnt Update the Image anymore…
Anyone who could help me? [import]uid: 145807 topic_id: 30102 reply_id: 330102[/import]
Any other Idea? [import]uid: 145807 topic_id: 30102 reply_id: 120626[/import]