Advertisement
Hendrix000007

Untitled

Oct 21st, 2014
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.91 KB | None | 0 0
  1. --[[
  2. I have included the GGScore.lua file from GlitcGames in the rootfolder
  3. and the settings in itunes Connect can be seen here:
  4. http://snag.gy/apb31.jpg
  5.  
  6. All I get is a list indicating the rows but nothing inside :(
  7. --]]
  8. -- MAIN.LUA --------------------------------------------
  9. display.setStatusBar(display.HiddenStatusBar)
  10. local gameNetwork = require "gameNetwork"
  11. local composer = require "composer"
  12. local initCallback = {}
  13. local onSystemEvent = {}
  14.  
  15. function initCallback( event )
  16.     -- "showSignIn" is only available on iOS 6+
  17.     if event.type == "showSignIn" then
  18.     elseif event.data then
  19.         loggedIntoGC = true
  20.     end
  21.  
  22. end
  23.  
  24.  
  25. function onSystemEvent( event )
  26.     if "applicationStart" == event.type then
  27.         loggedIntoGC = false
  28.         gameNetwork.init( "gamecenter", { listener=initCallback } )
  29.         return true
  30.     end
  31. end
  32.  
  33. Runtime:addEventListener( "system", onSystemEvent )
  34.        
  35. composer.gotoScene( "gameCenter", "fade", 400 )
  36. -- END OF MAIN.LUA -----------------------------------------------
  37.  
  38.  
  39. -- GAMECENTER.LUA ------------------------------------------------
  40. local GGScore = require( "GGScore" )
  41. local widget = require( "widget" )
  42. local gameNetwork = require "gameNetwork"
  43.  
  44. local composer = require( "composer" )
  45. local scene = composer.newScene()
  46. local onRowRender = {}
  47. local listOptions, list, number, name, score
  48. local board = GGScore:new( "Adagio Scoretable", true, "adagioLeaderboardID" )
  49. local scores = board:getScores()
  50.  
  51. function onRowRender( event )
  52.     local row = event.target
  53.     local rowGroup = event.view
  54.  
  55.     number = display.newText( "#" .. event.index .. " - ", 12, 0, native.systemFontBold, 18 )
  56.     number.achorX, number.achorY = 0.5, 0.5
  57.     number.x = 15
  58.     number.y = row.height * 0.5
  59.     number:setTextColor( 1 )
  60.  
  61.     name = display.newText( scores[ event.index ].name, 12, 0, native.systemFontBold, 18 )
  62.     name.achorX, name.achorY = 0.5, 0.5
  63.     name.x = number.x + number.contentWidth
  64.     name.y = row.height * 0.5
  65.     name:setTextColor( 1 )
  66.  
  67.     score = display.newText( scores[ event.index ].value, 12, 0, native.systemFontBold, 18 )
  68.     score.achorX, score.achorY = 0.5, 0.5
  69.     score.x = display.contentWidth - score.contentWidth - 20
  70.     score.y = row.height * 0.5
  71.     score:setTextColor( 1, 0.5, 0.6 )
  72.  
  73. sceneGroup:insert( rowGroup )
  74.     rowGroup:insert( number )
  75.     rowGroup:insert( name )
  76.     rowGroup:insert( score )
  77.  
  78. end
  79.  
  80.  
  81. function scene:create( event )
  82.    local sceneGroup = self.view
  83.  
  84.     board:add( nil, 125, nil, true )
  85.  
  86.  
  87.     listOptions =
  88.     {
  89.         top = 0,
  90.         height = 480,
  91.         hideBackground = true,
  92.     }
  93.  
  94.     list = widget.newTableView( listOptions )
  95.     for i = 1, #scores, 1 do
  96.         list:insertRow
  97.         {
  98.             onRender = onRowRender,
  99.             height = 40,
  100.             rowColor = {
  101.                 default = { 255, 255, 255, 0 },
  102.             }
  103.         }
  104.     end
  105.  
  106. end
  107.  
  108. scene:addEventListener( "create", scene )
  109.  
  110. return scene
  111. --END OF GAMECENTER ------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement