I am getting the following runtime error when testing my game in the Xcode simulator:
Runtime Error:
ERROR: Could not load provider (Game Center) due to the following reason: module ‘CoronaProvider.gameNetwork.gamecenter’ not found: resource (CoronaProvider.gameNetwork.gamecenter.lu)
does not exist in archive no field
package.preload[CoronaProvider.gameNetword.gamecenter’]
I have created a highscore button thats links to the Game Center leaderboard when clicked also I want the score achieved in the game to link to the Game Center leaderboard
Here are my project files:
build.settings:
– Supported values for orientation:
– portrait, portraitUpsideDown, landscapeLeft, landscapeRight
settings =
{
orientation =
{
default = “landscapeLeft”,
supported = { “landscapeLeft”, “landscapeRight” },
},
android =
{
usesPermissions =
{
“android.permission.INTERNET”,
“android.permission.WRITE_EXTERNAL_STORAGE”,
“android.permission.ACCESS_NETWORK_STATE”,
},
googlePlayGamesAppId = APP_ID
},
iphone =
{
plist =
{
NSAppTransportSecurity =
{
NSAllowsArbitraryLoads = true },
UIAppFonts = {“MadeinChina.ttf”},
UIStatusBarHidden=true,
UIViewControllerBasedStatusBarAppearance = false,
UIApplicationExitsOnSuspend = false,
UIPrerenderedIcon = True,
CFBundleIconFile = “Icon.png”,
CFBundleIconFiles = {
“Icon.png”,
“Icon@2x.png”,
“Icon-60.png”,
“Icon-60@2x.png”,
“Icon-60@3x.png”,
“Icon-72.png”,
“Icon-72@2x.png”,
“Icon-76.png”,
“Icon-76@2x.png”,
“Icon-Small-40.png”,
“Icon-Small-40@2x.png”,
“Icon-Small-40@3x.png”,
“Icon-Small-50.png”,
“Icon-Small-50@2x.png”,
“Icon-Small.png”,
“Icon-Small@2x.png”,
“Icon-Small@3x.png”
},
},
},
plugins =
{
[“plugin.revmob”] =
{
publisherId = “com.coronalabs”,
supportedPlatforms = { iphone=true, android=true }
},
[“plugin.google.play.services”] =
{
publisherId = “com.coronalabs”,
supportedPlatforms = { android=true }
},
[“CoronaProvider.gameNetwork.apple”] =
{
publisherId = “com.coronalabs”,
supportedPlatforms = { iphone=true }
},
[“CoronaProvider.ads.vungle”] =
{
publisherId = “com.vungle”
},
[“plugin.google.play.services”] =
{
publisherId = “com.coronalabs”,
supportedPlatforms = { android=true }
},
},
}
main.lua:
– set up game center and game network
gameNetwork = require “gameNetwork”
loggedIntoGC = false
local function onComplete( event )
if event.action == “clicked” then
local i = event.index
if i == 1 then
system.openURL ( “gamecenter:” )
elseif i == 2 then
end
end
end
– called after the “init” request has completed
local function initCallback( event )
if event.data then
loggedIntoGC = true
else
loggedIntoGC = false
local alert = native.showAlert( “Game Center”, "You are not logged. ", { “Log in”, “Continue” }, onComplete )
end
end
local function gameNetworkLoginCallback( event )
if gameNetwork.request(“isConnected”) then
loggedIntoGC = true
else
loggedIntoGC = false
end
end
local function gpgsInitCallback( event )
gameNetwork.request( “login”, { userInitiated=true, listener=gameNetworkLoginCallback } )
end
– function to listen for system events
local function onSystemEvent( event )
if event.type == “applicationStart” then
if ( system.getInfo(“platformName”) == “Android” ) then
gameNetwork.init( “google”, gpgsInitCallback )
else
gameNetwork.init( “gamecenter”, initCallback )
end
return true
end
end
Runtime:addEventListener( “system”, onSystemEvent )
on the menu screen i have created a high score button that links to the Game Center leaderboard:
local function onHighScoreTouch (event)
if loggedIntoGC then
gameNetwork.show( “leaderboards”)
else
if ( system.getInfo(“platformName”) == “Android” ) then
local alert = native.showAlert( “Google Play Game Services”, "You are not logged. ", { “Log in”, “Continue” }, onCompleteAndroid )
else
local alert = native.showAlert( “Game Center”, "You are not logged. ", { “Log in”, “Continue” }, onComplete )
end
end
return true
end
local function gameNetworkLoginCallback( event )
if gameNetwork.request(“isConnected”) then
loggedIntoGC = true
onReleaseBtnRankingEvent(event)
else
loggedIntoGC = false
end
end
local function onCompleteAndroid( event )
if event.action == “clicked” then
local i = event.index
if i == 1 then
gameNetwork.request( “login”, { userInitiated=true, listener=gameNetworkLoginCallback } )
elseif i == 2 then
end
end
end
in scene_game I have added the following code during the game over function:
if loggedIntoGC then
local leaderBoardID = configValues.LEADERBOARD_ID
if ( system.getInfo(“platformName”) == “Android” ) then
leaderBoardID = configValues.LEADERBOARD_ANDROID_ID
end
gameNetwork.request( “setHighScore”,
{
localPlayerScore = { category=leaderBoardID, value=score },
listener = requestCallback
}
)