Can you post your build.settings?
Rob
Can you post your build.settings?
Rob
Here you go rob
settings =
{
orientation =
{
– Supported values for orientation:
– portrait, portraitUpsideDown, landscapeLeft, landscapeRight
default = “landscapeRight”,
supported = { “landscapeRight”, “landscapeLeft”, “portrait” }
},
excludeFiles =
{
– Include only the necessary icon files on each platform
iphone = { “Icon-*dpi.png”, },
android = { “Icon.png”, “Icon-Small-*.png”, “Icon*@2x.png”, },
},
plugins =
{
[“CoronaProvider.gameNetwork.apple”] =
{
publisherId = “com.coronalabs”,
supportedPlatforms = { iphone=true, [“iphone-sim”]=true },
},
},
iphone =
{
plist =
{
UIAppFonts =
{
“balloonFont.ttf”
},
UIStatusBarHidden = false,
UIPrerenderedIcon = true, – set to false for “shine” overlay
–UIApplicationExitsOnSuspend = true, – uncomment to quit app on suspend
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.png”,
“Icon-Small@2x.png”,
“Icon-Small@3x.png”,
“Icon-Small-40.png”,
“Icon-Small-40@2x.png”,
“Icon-Small-50.png”,
“Icon-Small-50@2x.png”,
},
CFBundleIdentifier = “com.scotthinc.bombthrow1”, – Apple’s GameCenter Example (GKTapper)
–[[
– iOS app URL schemes:
CFBundleURLTypes =
{
{
CFBundleURLSchemes =
{
“fbXXXXXXXXX”, – replace XXXXXXXXX with your Facebook appId
}
}
}
–]]
}
},
android =
{
usesPermissions =
{
“android.permission.INTERNET”,
},
},
}
Thank you,
Scott
Are you doing a:
local gameNetwork = require(“gameNetwork”)
near the top of your main.lua?
ROb
I do the require and init in the my “menu.lua”. Does it have to be in main.lua?
You’re calling gameNetwork.init() in code that happens at application start. You would have to have already required gameNetwork before you can call the .init() call.
You also need to required it in any module that calls gameNetwork.
Rob
I do require before use gameNetwork.init.
Here is my menu.lua
local composer = require( "composer" ) local scene = composer.newScene() -- ----------------------------------------------------------------------------------------------------------------- -- All code outside of the listener functions will only be executed ONCE unless "composer.removeScene()" is called. -- ----------------------------------------------------------------------------------------------------------------- -- local forward references should go here -- ------------------------------------------------------------------------------- local CBE = require("CBEffects.Library") local gameNetwork = require("gameNetwork") -- global attributes score = 0 loginGC = false -- "scene:create()" function scene:create() background = display.newImage("images/menu.png") background.x = display.contentCenterX background.y=display.contentCenterY --local nameBox = native.newTextField(300, 300, 125, 50 ) --nameBox.inputType = "default" playButton = display.newImage("images/play.png") playButton.x=display.contentCenterX playButton.y=display.contentCenterY+25 videoPlay = display.newImage("images/videoPlay.png") videoPlay.x = 350 videoPlay.y = 280 cameraButton = display.newImage("images/camera.png") cameraButton.x = 350 cameraButton.y = 200 multiButton =display.newImage("images/multiplayer.png") multiButton.x = 100 multiButton.y = 200 -- functions function initCall( event ) if (event.data) then loginGC = true native.showAlert( "Login In!", "lets get started", {"Ok!"} ) else print( "error" ) end end function appOpen( event ) if (event.type== "applicationStart") then gameNetwork.init("gameCenter", initCall) end end function gotoNextSceneGame( ) composer.removeScene( "menu" ) composer.gotoScene( "levelSelect") end function gotoNextSceneVideo( ) composer.removeScene( "menu" ) composer.gotoScene( "videoTest") end function gotoNextSceneCamera( ) composer.removeScene( "menu" ) composer.gotoScene("camera") end function gotoNextSceneMulti( ) composer.removeScene( "menu" ) composer.gotoScene("multiTest") end --listen playButton:addEventListener("tap" , gotoNextSceneGame ) videoPlay:addEventListener("tap" , gotoNextSceneVideo ) cameraButton:addEventListener("tap" , gotoNextSceneCamera) multiButton:addEventListener( "tap", gotoNextSceneMulti ) Runtime:addEventListener( "system", appOpen ) end -- there is some other stuff but this is the bulk.
thank you,
scott
Well that block of code does not look like a complete scene. But you still need to require it in main.lua where your suspend code exists.
Rob
Thank rob for your help!
that was not all my code.
rob sorry to bother you again but my code is still not working, I put it in my main.lua file (which is below the full thing). Now when ever I run it on my phone it does not work from the main.lua scene and gives me the same error.
-- hide the status bar display.setStatusBar( display.HiddenStatusBar ) -- include the Corona "composer" module local composer = require "composer" gameNetwork = require("gameNetwork") loginGC = false function initCall( event ) if (event.data) then loginGC = true native.showAlert( "Login In!", "lets get started", {"Ok!"} ) else print( "error" ) end end gameNetwork.init("gameCenter", initCall) -- load menu screen composer.gotoScene( "menu" ) return gameNetwork
Edit: I think it is something wrong in my build setting the way i plugin it in or something because even if i remove all my GameNetwork Stuff it gives me the same error.
Your build.settings seem to be fine. What version of Corona SDK are you running?
Rob
Version 2014.2511 (2014.11.18)
Are you posting your entire main.lua?
yes.
Thank you helping me by the way.
edit: Is there a certain way to build for ios if you want gamecenter? I just published the with an adhoc
An AdHoc or Developer build will allow you to use the Sandbox for testing game center.
Than I have no idea what is wrong with my project. Should I file a bug?
No, there is not a Corona SDK bug. There is something wrong in your code. Since I can’t see your complete project, I’m going to post a simple project below for you to try out:
build.settings
settings = { orientation = { default = "portrait", supported = { "portrait", "portraitUpsideDown" } }, android = { usesPermissions = { "android.permission.INTERNET", "android.permission.ACCESS\_NETWORK\_STATE", "android.permission.WRITE\_EXTERNAL\_STORAGE", "com.android.vending.BILLING", "com.android.vending.CHECK\_LICENSE", }, googlePlayGamesAppId = "xxxxxxxxxxxxxxxx", }, plugins = { ["plugin.google.play.services"] = { publisherId = "com.coronalabs", supportedPlatforms = { android=true } }, ["CoronaProvider.gameNetwork.google"] = { publisherId = "com.coronalabs", supportedPlatforms = { android=true }, }, ["CoronaProvider.gameNetwork.apple"] = { publisherId = "com.coronalabs", supportedPlatforms = { iphone=true, ["iphone-sim"]=true }, }, }, iphone = { plist = { CFBundleIconFiles = { "Icon.png", "Icon@2x.png", "Icon@3x.png", "Icon-60.png", "Icon-60@2x.png", "Icon-72.png", "Icon-72@2x.png", "Icon-76.png", "Icon-76@2x.png", "Icon-Small.png", "Icon-Small@2x.png", "Icon-Small@3x.png", "Icon-Small-40.png", "Icon-Small-40@2x.png", "Icon-Small-40@3x.png", "Icon-Small-50.png", "Icon-Small-50@2x.png", }, UIApplicationExitsOnSuspend = false, -- must be false for single sign-on to work } }, excludeFiles = { iphone = { 'Icon-\*dpi.png', 'Icon-ouya.png', 'audio/\*.oog' }, android = { 'Icon.png', 'Icon-6\*.png', 'Icon-7\*.png', 'Icon-Small\*.png', 'Icon@2x.png', 'Default-568h@2x.png', 'audio/\*.m4a' } }, }
main.lua
local composer = require( "composer" ) local widget = require( "widget" ) local gameNetwork = require("gameNetwork") math.randomseed( os.time() ) local function loadLocalPlayerCallback( event ) print("You are ", event.data.alias) end local function gameNetworkLoginCallback( event ) gameNetwork.request( "loadLocalPlayer", { listener=loadLocalPlayerCallback } ) return true end local function gpgsInitCallback( event ) gameNetwork.request( "login", { userInitiated=true, listener=gameNetworkLoginCallback } ) end local function authorize() print("In autuhorize") if ( system.getInfo("platformName") == "Android" ) then print("logging into GPGS") gameNetwork.init( "google", gpgsInitCallback ) else print("logging in to GameCenter") gameNetwork.init( "gamecenter", gameNetworkLoginCallback ) end end authorize() composer.gotoScene( "menu" )
menu.lua
local composer = require( "composer" ) local scene = composer.newScene() local gameNetwork = require("gameNetwork") local widget = require( "widget" ) local function handlePlayButtonEvent( event ) if ( "ended" == event.phase ) then gameNetwork.show( "leaderboards", { leaderboard={ timeScope="Week" }, listener=showLeaders } ) end end -- -- Start the composer event handlers -- function scene:create( event ) local sceneGroup = self.view -- -- setup a page background, really not that important though composer -- crashes out if there isn't a display object in the view. -- local background = display.newRect(0, 0, display.contentWidth, display.contentHeight) background.x = display.contentCenterX background.y = display.contentCenterY sceneGroup:insert(background) -- Create the widget local playButton = widget.newButton({ label = "Show Leaderboard", onEvent = handlePlayButtonEvent }) playButton.x = display.contentCenterX playButton.y = display.contentCenterY sceneGroup:insert( playButton ) end function scene:show( event ) local sceneGroup = self.view if event.phase == "did" then end end function scene:hide( event ) local sceneGroup = self.view if event.phase == "will" then end end function scene:destroy( event ) local sceneGroup = self.view end --------------------------------------------------------------------------------- -- END OF YOUR IMPLEMENTATION --------------------------------------------------------------------------------- scene:addEventListener( "create", scene ) scene:addEventListener( "show", scene ) scene:addEventListener( "hide", scene ) scene:addEventListener( "destroy", scene ) return scene
This code will successfully login to GameCenter and allow you to show leaderboards. Compare your code to this code and see where you are different.
Rob
Ok thanks Rob
edit: I could upload all my whole code there are just some parts that are not important in my opinion and would waste your time and thought it would be rude to just throw all my code at you and say fix it.
Well, more importantly, we can’t debug your code for you.
Rob
I know, thanks for all your help with this problem. I will test this later.
fixed it, my build setting messed up.