A "best score" sample project that work but...

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]

Hi Reazle,

your code works good. So thanks for trying my module. You saying that it works in the Corona simulator, but not on the IPhone? I am using an IPod touch 2nd gen where it works. What model do you have?

Does the XCoder Organizer log files tell you anything about a problem?

Cheers
Michael Hartlef
http://www.whiteskygames.com
http://www.twitter.com/mhartlef [import]uid: 5712 topic_id: 3168 reply_id: 9312[/import]

Hi Michael, thanks for your answer.

I’ve tried on both iphone 3G and 4. The problem is the same.

I got the same Log when I upload an HelloWorld App and this one, but the HelloWorld works, not the TestScore.

Here is the log :

[applescript]Fri Oct 29 11:53:44 unknown mobile_installationd[3007] : 0080b000 install_embedded_profile: Skipping the installation of the embedded profile
Fri Oct 29 11:53:45 unknown mobile_installationd[3007] : entitlement ‘application-identifier’ has value not permitted by a provisioning profile
Fri Oct 29 11:53:46 unknown mobile_installationd[3007] : entitlement ‘application-identifier’ has value not permitted by a provisioning profile
Fri Oct 29 11:53:48 unknown SpringBoard[24] : Reloading and rendering all application icons.
Fri Oct 29 11:53:53 unknown SpringBoard[24] : MultitouchHID(208ad0) uilock state: 1 -> 0
Fri Oct 29 11:53:53 unknown SpringBoard[24] : MultitouchHID(3a06be0) device bootloaded
Fri Oct 29 11:54:17 unknown kernel[0] : launchd[3077] Builtin profile: container (seatbelt)
Fri Oct 29 11:54:17 unknown kernel[0] : launchd[3077] Container: /private/var/mobile/Applications/98AE79C4-CB7B-42BE-8BA6-09EE6C3AFD8F (seatbelt)
Fri Oct 29 11:54:18 unknown com.apple.SpringBoard[24] : CoreAnimation: timed out fence 500
Fri Oct 29 11:54:19 unknown com.apple.SpringBoard[24] : CoreAnimation: timed out fence 500
Fri Oct 29 11:54:30 unknown SpringBoard[24] : MultitouchHID(208ad0) uilock state: 0 -> 1
[/applescript]

It seems that there is a problem with my App Identifier but I didn’t figure how to manage it.
(I’m using a provisoning profile associated with an App Id : com.reazle.coronadev)

Thanks in advance if you can bring me some light on this :slight_smile:

[import]uid: 10562 topic_id: 3168 reply_id: 9371[/import]

Right now I can’t install it on my device as I just setup a new sytem so I have to reinstall xcode. But I will do so in a couple of days. I let you know then. [import]uid: 5712 topic_id: 3168 reply_id: 9391[/import]

Hi Mike,

just to let you know that I’ve tried it on an Android Device and it’s exactly the same problem.

Please let me know if you find something.

Cheers,

Reazle [import]uid: 10562 topic_id: 3168 reply_id: 9590[/import]

Arrgh, again this stupid forum trashed my post. anyway,

here is a working file. http://www.fantomgl.com/files/ScoreTest.zip

[import]uid: 5712 topic_id: 3168 reply_id: 10511[/import]

I have tried to include the score to my code but, I get error message attempt to index an upvalue scList

[code]
io.output():setvbuf(‘no’) – disable output buffering for console in device!

–Json = require(“Json”)
score = require(“score”)

local currentScore =0

local scList=0

local bestScore = 0

– ////////////////////

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( “btnBig.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(“score3.txt”)
bestScore=scList:GetPoints(1)
showScore.text=currentScore
showBestScore.text=bestScore
end

–****************************************************************
local onSystemEvent = function( event )
–****************************************************************
print (“onSystemEvent->”…event.type)
if event.type == “applicationExit” then

elseif event.type == “applicationStart” then
print (“applicationStart”)
scList = score.newList(1)
scList:Load(“score3.txt”)
bestScore=scList:GetPoints(1)
print (“bestscore:”…bestScore)

elseif “applicationSuspend” == event.type then
–tSuspend = system.getTimer()
elseif “applicationResume” == event.type then
– add missing time to tPrevious
–tPrevious = tPrevious + ( system.getTimer() - tSuspend )
end
end

–****************************************************************
local onFrame = function( event )
–****************************************************************
end

buttonScore:addEventListener(“tap”, buttonScore)
Runtime:addEventListener( “system”, onSystemEvent )
Runtime:addEventListener( “enterFrame”, onFrame )
please help [import]uid: 40990 topic_id: 3168 reply_id: 34857[/import]

Hey I’ve possibly found your bug because I’ve just been through the same problems - it could be the fact that when you do:

score = require(“Score”)

your score.lua file is saved with a lower-case ‘s’ so it should be

score = require(“score”)

the simulator doesnt pick-up the syntax error but your iphone will!

let me know if that was the problem! cheers
[import]uid: 13568 topic_id: 3168 reply_id: 40192[/import]