Xojo Conferences

Platforms to show: All Mac Windows Linux Cross-Platform

/MacFrameworks/GameKit Player
Required plugins for this example: MBS MacBase Plugin, MBS MacFrameworks Plugin, MBS Main Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacFrameworks/GameKit Player
This example is the version from Wed, 13th Aug 2013.
Project "GameKit Player.rbp"
Class App Inherits Application
Const kEditClear = "&Löschen"
Const kFileQuit = "Beenden"
Const kFileQuitShortcut = ""
End Class
Class Window1 Inherits Window
Control Listbox1 Inherits Listbox
ControlInstance Listbox1 Inherits Listbox
End Control
Control BevelButton1 Inherits BevelButton
ControlInstance BevelButton1 Inherits BevelButton
EventHandler Sub Action() window1.Listbox1.AddRow "authenticate local player..." // run authenticate localPlayer = GKLocalPlayerMBS.localPlayer // old code 'localPlayer.authenticate // new code localPlayer.SetAuthenticateHandler if localPlayer.isAuthenticated then // already check else // later end if End EventHandler
End Control
EventHandler Sub Open() // install somewhere globally to get events there gameKit = new MyGameKitMBS End EventHandler
Sub Check() dim localPlayer as GKLocalPlayerMBS = GKLocalPlayerMBS.localPlayer // isAuthenticated will tell if things went well. log "alias: "+localPlayer.alias log "isAuthenticated: "+str(localPlayer.isAuthenticated) log "isFriend: "+str(localPlayer.isFriend) log "isUnderage: "+str(localPlayer.isUnderage) log "playerID: "+localPlayer.playerID End Sub
Sub log(s as string) System.DebugLog s window1.Listbox1.AddRow s End Sub
Property gameKit As MyGameKitMBS
Property localPlayer As GKLocalPlayerMBS
End Class
MenuBar MenuBar1
MenuItem FileMenu = "&Ablage"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Bearbeiten"
MenuItem EditUndo = "&Rückgängig"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "&Ausschneiden"
MenuItem EditCopy = "&Kopieren"
MenuItem EditPaste = "&Einfügen"
MenuItem EditClear = "#App.kEditClear"
MenuItem UntitledMenu0 = "-"
MenuItem EditSelectAll = "&Alles auswählen"
End MenuBar
Class MyGameKitMBS Inherits GameKitMBS
EventHandler Sub authenticateCompleted(localPlayer as GKLocalPlayerMBS, error as NSErrorMBS, tag as variant) // here we get result from authentication // isAuthenticated will tell if things went well. // Also error gives details window1.Check if error<>Nil then log error.localizedDescription end if End EventHandler
EventHandler Sub authenticateHandler(LocalPlayer as GKLocalPlayerMBS, viewController as NSViewControllerMBS, error as NSErrorMBS, tag as integer) if error<>nil then MsgBox error.LocalizedDescription Return end if if viewController<>nil then if DialogController = nil then DialogController = new GKDialogControllerMBS end if call DialogController.presentViewController viewController else if LocalPlayer.isAuthenticated then MsgBox "Authenticated" end if window1.Check end if End EventHandler
Sub log(s as string) System.DebugLog s window1.Listbox1.AddRow s End Sub
Property DialogController As GKDialogControllerMBS
End Class
End Project

Feedback, Comments & Corrections

The items on this page are in the following plugins: MBS MacFrameworks Plugin.

MBS Xojo tutorial videos