Hi there,
As many here I’d prefer apologise first if the question is stupid since I’m working with lua since yesterday, but here it is.
I’ve made a sample project that can be downloaded here : http://www.sendspace.com/file/f4y596
And it’s related to this.
It’s a simple project that save your best score. Click the green button to add score, then relaunch your project and the old score is saved.
Ok so it works BUT…
When I build this project to my iPhone I got a black screen (of course I tried without the score features and it works)…
I would appreciate if someone could help me (and if someone could try it on android)
Here is the main.lua file if you don’t want to dowload the file:
--module(..., package.seeall)
--Json = require("Json")
score = require("Score")
local currentScore =0
scList = score.newList(1)
scList:Load("score.text")
local bestScore=scList:GetPoints(1)
--
-- ////////////////////
--
local showScore=display.newText( "", 300, 300, nil, 60)
showScore:setTextColor( 255,255,255 )
local yourScore=display.newText( "your score", 50, 300, nil, 20)
yourScore:setTextColor( 255,255,255 )
local showBestScore=display.newText( "", 300, 500, nil, 60)
showBestScore:setTextColor( 255,255,255 )
local yourBestScore=display.newText( "best score", 50, 500, nil, 20)
yourBestScore:setTextColor( 255,255,255 )
local instruction=display.newText( "cmd+R to relaunch", 50, 700, nil, 20)
instruction:setTextColor( 255,255,255 )
local buttonScore = display.newImage( "button.png" )
buttonScore.x = 100
buttonScore.y = 100
function buttonScore:tap(event)
currentScore=currentScore+1
if currentScore\>=bestScore then scList:StoreEntry(1,currentScore,best) end
scList:Save("score.text")
bestScore=scList:GetPoints(1)
showScore.text=currentScore
showBestScore.text=bestScore
end
buttonScore:addEventListener("tap", buttonScore)
Thanks in advance,
Reazle
[import]uid: 10562 topic_id: 3168 reply_id: 303168[/import]
