It works fine except I lose control over the previous scene when I close the Game Center window using the "Done" button on the top — alxcyl. Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown.
The Overflow Blog. Podcast Making Agile work for data science. Stack Gives Back We also explore the use of Actions to fire off some activity. We also look at one way to queue a sound effect to play as well as how to deal with your application losing focus. The tutorial currently consists of: Installation, Creating a Project and Hello World This section looks at getting Cocos2d-x setup and running.
Handling Mouse and Touch Events This section covers how to handle mouse and touch events in Cocos2d-x. Handling Keyboard Events Here we look at how to handle keyboard events, both on desktop computers and using the soft keyboard on mobile devices.
Thank you very much! Why is there no mention of calling initGameSharing in your guides? This is excellent work, but severly let down by poor documentation.
Leave a Reply Cancel reply Enter your comment here Fill in your details below or click an icon to log in:. Email required Address never made public.
Name required. You can optionally pass in a block of code that will be called once the user is authenticated. He can be using your app, switch to the Game Center app, log or out from there, and switch back to your app. So your app needs to know whenever the authentication status changes. This imports the GameKit header file, and then creates an object with two booleans — one to keep track of if game center is available on this device, and one to keep track of whether the user is currently authenticated.
It also creates a property so the game can tell if game center is available, a static method to retrieve the singleton instance of this class, and another method to authenticate the local user which will be called when the app starts up. This synthesizes the gameCenterAvailable property, then defines the method to create the singleton instance of this class. By making sure Game Kit is available before using it, this app can still run on iOS 4.
The authenticationChanged callback is very simple at this point — it checks to see whether the change was due to the user being authenticate or un-authenticated, and updates a status flag accordingly.
Finally, add the method to authenticate the local user right after the authenticationChanged method:. This calls the authenticateWithCompletionHandler method mentioned earlier to tell Game Kit to authenticate the user.
OK — GCHelper now contains all of the code necessary to authenticate the user, so you just have to use it! Switch to AppDelegate.
Almost done! The last step is to add the Game Kit framework into your project. Select GameKit. Change the type from Required to Optional, and your screen should look like the following:. There are two ways to find someone to play with via Game Center: search for match programatically, or use the built-in matchmaking user interface.
This is the method that the Cocos2D layer will call to find a match.
0コメント