hi iam making game by gpgs leaderboard…
how to implement highscore to leaderboard???
[lua]-- local composer = require( “composer” )
local scene = composer.newScene()
local widget = require “widget”
local mydata = require( “mydata” )
local score = require( “score” )
local globalData = require( “globalData” )
local json = require( “json” )
local gpgs = require( “plugin.gpgs” )
centerX = display.contentCenterX
centerY = display.contentCenterY
screenX = display.screenOriginX
screenY = display.screenOriginY
screenWidth = display.contentWidth
screenHeight = display.contentHeight
screenLeft = screenX
screenRight = screenX + screenWidth
screenTop = screenY
screenBottom = screenY + screenHeight
display.contentWidth = screenWidth
display.contentHeight = screenHeight
– background
audio.stop ( sndMusic )
local sndTl = audio.loadSound (“Powerup3.wav”)
local sndTp = audio.loadSound (“changepage.wav”)
local sndSr = audio.loadSound (“siren.mp3”)
local function submitScoreListener( event )
– Google Play Games Services score submission
if ( globalData.gpgs ) then
if not event.isError then
local isBest = nil
if ( event.scores[“daily”].isNewBest ) then
isBest = “a daily”
elseif ( event.scores[“weekly”].isNewBest ) then
isBest = “a weekly”
elseif ( event.scores[“all time”].isNewBest ) then
isBest = “an all time”
end
if isBest then
– Congratulate player on a high score
local message = “You set " … isBest … " high score!”
native.showAlert( “Congratulations”, message, { “OK” } )
else
– Encourage the player to do better
native.showAlert( “Sorry…”, “Better luck next time!”, { “OK” } )
end
end
end
end
local function submitScore( score )
if ( globalData.gpgs ) then
– Submit a score to Google Play Games Services
globalData.gpgs.leaderboards.submit(
{
leaderboardId = “CgkI8J_r9sMYEAIQBg”,
score = tonumber(score),
listener = submitScoreListener
})
elseif ( globalData.gameCenter ) then
– Submit a score to Apple Game Center
globalData.gameCenter.request( “setHighScore”,
{
localPlayerScore = {
category = “com.yourdomain.yourgame.leaderboard”,
value = score
},
listener = submitScoreListener
})
end
end
function restartGame()
submitScore( score)
saveScore()
composer.gotoScene(“start”)
end
[/lua]
how to set… leaderboard save our highscore only…?
n how to implement leaderboard? ty