I've got a Game Center leaderboard in my game that I display using my own GUI using data retrieved from the GKLeaderboard loadScoresWithCompletionHandler method.
I report new scores using the GKScore reportScoresWithCompletionHandler method. My issue is that when I report a new high score for the local player, when I open up my leaderboard GUI (which forces loadScoresWithCompletionHandler to be called), the player score isn't updated - it's displaying the old one he just beat.
But if I close(not kill) the game and then reopen it and open up the GUI again, hey-presto, the new score is shown.
This tells me that there must be some form of internal caching going on in GameKit that gets reset when the app resumes. I do know that upon the app resuming, GC calls my authenticationHandler to let me know that it has re-authenticated the player so maybe something in that method wipes whatever internal cache is set?
This is the first game I've worked on where I am displaying Game Center data using a custom UI and not the native GC view controller which I've never had this problem with. Has anyone had similar experience with this and could tell me why GKLeaderboard loadScoresWithCompletionHandler gives me old data?
I was having the same issue and it gave me sleepless night especially seeing no answer related to it on stackoverflow and other forums.
Then, i found somewhere that they were reporting new score whenever the level gets completes. And I changed the button from submit leaderboard to show leaderboard, it resolved the issue. I am using GC view controller. and i was only calling showleaderboard as it was a non-custom leaderboard.
Related
I have created a spriteKit game and have a problem with performance issues.
Problem:
FPS gets stuck at 40.0
How and when does it happen
1. I have a pause function in my game by just using view!.scene?.paused = true Sometimes when I hit the home button, launch another app, then go back to the game the FPS gets 'stuck' at 40 and doesnt climb back up to 60.0. (Sometimes it does)
2. I have a 'sharing' Facebook and Twitter icon where when you tap on it you can post/share/tweet something on your account. This icon can be seen in the pause menu. After posting or returning back to the game FPS gets stuck at 40 FPS (And again, sometimes it does climb back up to 60. Sometimes it does not)
3. To clarify, this doesnt happen mid-game. This only happens if I minimize the app, launch the Facebook/Twitter icons, during reminder pop-ups.
Temporary fix
There is a temporary fix to this, which is to minimize the app and then launching it again. However, I wouldnt want my users to experience this at all. If possible Id like to eliminate this problem altogether.
What I have tried so far to fix this
1.Ive tried running this on instruments (time Profiler) but nothing really caught my eye. Thought I have to say I am quite new with instruments.
2. There is a similar question here but for him disabling UIKit items fixed it for him, and I dont have any of that.
3. I initially thought it was a SKShapeNode issue so I changed my sprites to SKSpriteNode. No help here either.
4. I have tried without the USB cable attached to the phone and tried running it using the Run button on XCode. No difference.
5. Ive tried rebooting device and laptop. Didnt help.
6. Tried this on multiple devices. Same issue.
Stats?
Game typically starts out at 20 nodes and 5 draws and can go up to 60 nodes 6 draws but it will actually still run smooth as long as I dont initiate any of the triggering methods mentioned above.
I have spent alot of time trying to find a solution for this. Changing codes and streamlining it. Googling it. I really need help on this one. I would really appreciate some help.
Update for comment #1
For you first inquiry
1) I have a SKSpriteNode as the pause button during gameplay for the user to pause the game if he wants to.
2) I have func applicationWillResignActive(application: UIApplication) {} in my AppDelegate.swift file that triggers a GameScene.swift function that changes a flag from true to false so that I know when the user goes out and come back in again. And I have my update block searching for that flag. If it is true, display the pause menu. However, this 40FPS issue happened before I added this whole pause/unpause thing. (The 40 FPS issue is what made me create the pause menu for this) (I know too in the latest ver. of swift that it will auto-pause when the app is minimized and unpause when I bring it back up.)
I'm using Game Center to create a real time match and I am working on a restart button. When the game ends it takes you to another screen that shows you everyone's score and on that screen there is a restart button. If someone presses it their name will turn green and if they leave the game then their name will turn red. Once everyone has either hit restart or left the game then the game will restart by presenting the game scene again.
The thing is though, they're all doing this at slightly different times and sometimes one of the devices will send a signal to the other devices before those other devices have made it to the game scene and so the message isn't being interpreted and is just lost. So my question is, is there any way to make sure that all the players go the the next scene at exactly the same time?
You can have a synchronization step after the scenes have loaded. You will never be guaranteed everyone loads at the same time/rate.
So,
1-signal everyone to load,
2-everyone works on loading,
3-don't show the scene or render anything relevant yet,
4-wait for everyone to send a ready signal (some people may have to
send the ready signal repeatedly to work around boundary loading
issues),
5- everyone gets a ready signal,
6- users can now display the scene,
7- do one last check by sending another 'ready signal' to everyone
(again some may have to broadcast multiple times),
8- with the last signal received from everyone confirmed, the game can begin.
This redundancy is to make sure the users are able to broadcast appropriately before and after showing the scene. Of course, There is a LOT of implicit error checking and timeout checking during this process, if there is a stray user unable to broadcast, then they may just need to be considered for booting off the match after a given amount of time so the other players can still play.
Also this is my best whack at syncing things as much as possible to where you can try and make sure signals are not lost. Do a synchronization procedure, then start sending relevant signals.
You CAN NOT guarantee exact timings of next screens for different users, you can just get them as close as possible.
The important part is NOT the screen display but rather making sure all users are in the correct STATE to receive the next set of data broadcasted by the others.
Different internet speeds and different device speeds will always hinder perfect visual synchronization.
I am developing a simple 2D sprite kit game for IOS. I added a leaderboard and some demo accounts to test it out and it all worked fine.
Yesterday, i decided it was time to release version 1.0 of the app and before i submitted the app for review i deleted the existing leaderboard just to make sure no fake scores from my demo accounts remain.
I then submitted the app for review and later when i tried to add a new leaderboard, the process works normally until i reach the point where i press save (to make the leaderboard active) but the button is greyed out no matter what i do. i read the documentation and searched online for similar cases and tried all of the following:
Made sure game center is enabled
chose single leaderboard
made sure the leaderbard reference name is correct
made sure the leaderboard Id is correct
Chose a score format
made sure to write the score range in numbers
create a localization language
however, the save button remains grey and i can not add a leaderboard. i tried today as well, the original leaderboard was deleted and stil the same issue. now when i try to play my game (on my test device) when i reach the end and the score should be submitted, the game crashes (since there is no leaderboard and my code submits the score at this point)
If my game is accepted and goes online it wouldn't be a good thing to have it crashing from version 1.0. I do not know what is causing this and what i can do to solve it, would appreciate any help.
Thank you
I am making a multiplayer feature to a game I made.
Everything is working, except when I am in matchmaking and both players are connected, if one person hits the "Cancel" button the other device gets no notice of the canceling.
On the other device it the words change to say "Disconnected" however none of the delegate methods are called.
How can I handle this?
You should implement the GKMatchmakerViewControllerDelegate protocol.
Unfortunately, there is not a method (that I know of, or could find with almost 3 months of looking into it) that is called when one person disconnects in matchmaking after they have begun to connect.
Therefore, the way I got around this is once the GameViewController is presented it waits one second and then calls a method to check to see if it is connected to someone else.
To do this I have it so once the game begins each player sends the other player a random number (used to determine non-related settings later on - such as who gets to go first). When it calls the method to check to see if it is connected it just checks to see if the random number has been assigned. If so, then it begins the game as normal, if not, it ends the game and pops back to the menu.
I am trying to completely reload a gamepage in monogame - simply by touching a sprite on the page. I cannot find any solution for this.
In Android, I can call finish for the gameactivity, and then recreate a new one. How can I do that in monogame?
I am using WP8.0 SDK, monogame with XNA 4 framework.
I'm not familiar with Android development, or specifically what you mean by "gamepage", but typically this type of thing is handled with "states" in game development. You can have a playing state, paused state, Main Menu state, etc, and you just pass the game object to each state class and have it override the update/draw methods with its own information.
So, in your case, you would be in the playing state of the game, and if the sprite is touched, you might want to go back to the main title, you can pass the game object to the Title Screen State. The Title SCreen can have a call to LoadContent() which will reload all assets (effectively restarting the game completely).
Not sure if that helps. =X