I’m not sure you know what I mean. What I meant was that when you tap on Press and it displays 12345, in the sand box the number is stored. So when I change the number to let’s say 54321 the number does not change unless I erase the data in the sandbox. So I was wondering If i could erase the data in the sandbox using some code so every time the score can update it self. Let’s say i have a game and the score is constantly changing, i need the sandbox to erase itself so that i can add the new score. Because at the moment it is just storing the number 12345 and I can’t change the number, because it is stored in the sandbox. Do you know what I can do to fix this? That is why i brought of the myData:clear(), but it does not work so what can I do?
Besides the point I recently have made a timer counting up, but the score is not the number the counter is at once I tap on Press and go to the Ice2.lua, it is the number the score starts at which is 0. What I did is make a make a counter timer, i set it at 0 increasing by one each second. The problem is that when I tap on Press and go to Ice.lua it does not show the current number, it shows 0. I want it to show the current number it is once I tap on Press. Do you know what I mean? Let’s say the timer has gone up to 8 and I tap on press, the score that it shows me is O, the starting number not the current number.
What I did differently was I made the timer, and once you tap on press it brings you to ice2.lua. On Ice2.lua it is suppose to display the current score, but it shows 0. I added text so now it is not using terminal.
Thanks a lot for your help, I really appreciate it. I’m sorry for all this, i’m really a newbie.
[code]
– main.lua
require(“ice”)
myData = nil
– load previously saved data
– EDIT: if no data has been saved, it will create the myData.ice where data will be saved
myData = ice:loadBox( “myData” )
–Ice.lua :
module(…, package.seeall)
function new()
local iceGroup = display.newGroup();
– try and retrieve the fixed score
local setScore = myData:retrieve( “mySetScore” )
if (setScore == nil) then
setScore = 0-- this is the fixed score you want to use
myData:store( “mySetScore”, setScore )
end
myData:save() – this will save the data to device
local scoreText = display.newText( "Score: " … setScore, 20, 0,nil, 20)
scoreText:setTextColor(255,255,255)
local function getScore() – increments score value every time it is called
setScore = setScore + 1
scoreText.text = "Score: " … setScore
end
timer.performWithDelay(1000, getScore, 0)
Press = display.newText( “Press”, 0, 0, “Helvetica”, 30 )
Press.x = 100
Press.y = 100
iceGroup:insert(Press);
function ther4(event)
director:changeScene( “Ice2”, “fade” )
end
Press:addEventListener(“tap”, ther4);
return iceGroup;
end
Ice2.lua:
–Ice2.lua:
module(…, package.seeall)
function new()
local ice2Group = display.newGroup();
local setScore = myData:retrieve( “mySetScore” )
local scoreText = display.newText( "Score: " … setScore, 20, 0,nil, 20)
scoreText:setTextColor(255,255,255)
return ice2Group;
end [import]uid: 23689 topic_id: 18792 reply_id: 73894[/import]