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:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
--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)

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

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 :

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

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.

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

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

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

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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
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

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

views:1824 update:2011/9/29 19:21:19
corona forums © 2003-2011