ok, you want to download ice library, you can find it here:
https://github.com/GrahamRanson/Ice
i played with it for the first time and managed to get working high score system, its not pretty, but whatever if it works))
[lua]require( “ice” )
local scores = ice:loadBox( “scores” )
local high = scores:retrieve(“best”)
print(high)
local gameOver = false
local physics = require(“physics”)
physics.start()
physics.setGravity(0,5)
local ballGroup = display.newGroup()
local score = 0
local score_txt =display.newText("Score: ",0,0,nil,30)
score_txt.x = 100; score_txt.y = 50
score_txt:setTextColor(255,0,0)
score_txt.text = "Score: "… score
local function spawn_ball()
if gameOver == false then
local ball = display.newCircle(ballGroup,0,0,30)
ball.x = math.random(50,300)
ball.y = -50
physics.addBody(ball, {radius = 30})
ball.name = “ball”
end
end
timer.performWithDelay(500, spawn_ball, 0)
local basket = display.newRect(0,0,50,70)
basket.x = display.contentWidth/2
basket.y = display.contentHeight - 80
physics.addBody(basket, “static”)
local function drag(event)
if event.phase == “began” then
event.target.isFocus = true
elseif event.phase == “moved” and event.target.isFocus then
event.target.x = event.x
event.target.y = event.y
end
return true
end
basket:addEventListener(“touch”, drag)
local function show_highScore()
gameOver = not gameOver
scores:storeIfHigher( “best”, score )
scores:save()
local highText = display.newText("", 0,0,nil,30)
highText.x = display.contentWidth/2
highText.y = display.contentHeight/2
if score > high then
highText.text = “HighScore: “… scores:retrieve(“best”)
else
highText.text = “NO NEW HIGH SCORE!”
end
end
local function show_text()
local text = display.newText(”+1”, 0,0, nil, 30)
score = score + 1
if score > scores:retrieve(“best”) then
print(“new high score”)
end
score_txt.text = "Score: "… score
text.alpha = 1
text.x = basket.x
text.y = basket.y - 100
transition.to(text, {time=1000,y = text.y - 50, alpha = 1, onComplete = function() display.remove(text) end})
end
local function onCollision(event)
if event.phase == “began” and event.other.name == “ball” then
display.remove(event.other)
show_text()
end
end
basket:addEventListener(“collision”, onCollision)
timer.performWithDelay(20000, show_highScore, 1)
[lua] [import]uid: 16142 topic_id: 19321 reply_id: 74549[/import]