Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- I have included the GGScore.lua file from GlitcGames in the rootfolder
- and the settings in itunes Connect can be seen here:
- http://snag.gy/apb31.jpg
- All I get is a list indicating the rows but nothing inside :(
- --]]
- -- MAIN.LUA --------------------------------------------
- display.setStatusBar(display.HiddenStatusBar)
- local gameNetwork = require "gameNetwork"
- local composer = require "composer"
- local initCallback = {}
- local onSystemEvent = {}
- function initCallback( event )
- -- "showSignIn" is only available on iOS 6+
- if event.type == "showSignIn" then
- elseif event.data then
- loggedIntoGC = true
- end
- end
- function onSystemEvent( event )
- if "applicationStart" == event.type then
- loggedIntoGC = false
- gameNetwork.init( "gamecenter", { listener=initCallback } )
- return true
- end
- end
- Runtime:addEventListener( "system", onSystemEvent )
- composer.gotoScene( "gameCenter", "fade", 400 )
- -- END OF MAIN.LUA -----------------------------------------------
- -- GAMECENTER.LUA ------------------------------------------------
- local GGScore = require( "GGScore" )
- local widget = require( "widget" )
- local gameNetwork = require "gameNetwork"
- local composer = require( "composer" )
- local scene = composer.newScene()
- local onRowRender = {}
- local listOptions, list, number, name, score
- local board = GGScore:new( "Adagio Scoretable", true, "adagioLeaderboardID" )
- local scores = board:getScores()
- function onRowRender( event )
- local row = event.target
- local rowGroup = event.view
- number = display.newText( "#" .. event.index .. " - ", 12, 0, native.systemFontBold, 18 )
- number.achorX, number.achorY = 0.5, 0.5
- number.x = 15
- number.y = row.height * 0.5
- number:setTextColor( 1 )
- name = display.newText( scores[ event.index ].name, 12, 0, native.systemFontBold, 18 )
- name.achorX, name.achorY = 0.5, 0.5
- name.x = number.x + number.contentWidth
- name.y = row.height * 0.5
- name:setTextColor( 1 )
- score = display.newText( scores[ event.index ].value, 12, 0, native.systemFontBold, 18 )
- score.achorX, score.achorY = 0.5, 0.5
- score.x = display.contentWidth - score.contentWidth - 20
- score.y = row.height * 0.5
- score:setTextColor( 1, 0.5, 0.6 )
- sceneGroup:insert( rowGroup )
- rowGroup:insert( number )
- rowGroup:insert( name )
- rowGroup:insert( score )
- end
- function scene:create( event )
- local sceneGroup = self.view
- board:add( nil, 125, nil, true )
- listOptions =
- {
- top = 0,
- height = 480,
- hideBackground = true,
- }
- list = widget.newTableView( listOptions )
- for i = 1, #scores, 1 do
- list:insertRow
- {
- onRender = onRowRender,
- height = 40,
- rowColor = {
- default = { 255, 255, 255, 0 },
- }
- }
- end
- end
- scene:addEventListener( "create", scene )
- return scene
- --END OF GAMECENTER ------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement