I am building a 2 player game. I am using GKTurnBasedMatchmakerViewController to start matches. I would like to ensure that players can only have one game vs the same player.
Currently if a player starts a game with someone they already have I just delete the game. This has 2 issues
The other player gets notifications about the newly deleted game
If the game was created by auto-match then the other user is removed from the auto-match queue.
So I would like to know...
Is there a way to exclude players in the GKTurnBasedMatchmakerViewController
Is there a way to remove a player from a game that allows the game to look for a new auto-match player?
Related
I'm making a simple SpriteKit game with two scenes, and I want the background music to loop unconditionally through both scenes. Right now, I'm using
if soundIsPlaying == false {
runAction(SKAction.repeatActionForever(backgroundMusicEffect), withKey: "backgroundMusic")
soundIsPlaying = true
}
in my menu scene where backgroundMusicEffect is a global variable
let backgroundMusicEffect = SKAction.playSoundFileNamed("content/divertimentoK131.mp3", waitForCompletion: true)
When I play my game, the music never loops. It always stops after one play. If I remove the if-else statement, the music plays over itself every time I reenter the menu.
Is there a better way to play background music? What am I doing wrong?
I believe that the way you are doing it, after the first time looping, every iteration after is "complete" since the sound is finished. You would need to create a new SKAction instance every time if you want to get this to loop.
This of course is a bad idea, since playSoundFileNamed is designed to only play a sound file once with as little over head as possible.
As #Alessandro Omano has commented, use SKAudioNode to get sound playing in a loop. This is my preferred way of doing in, but you limit yourself to >= iOS 9 users.
If you have to support iOS 8 users (At this point I would say why bother) then you need to look into the AVFoundation sections of the libs to get audio going, or use OpenAL.
I'm making a pass-and-play multiplayer game. Both players could have info stored in Game Center that I might need to get, like stats/inventory for their character, but also to update their achievements.
This is how I envision it:
Player 1 (device owner) logs in to Game Center (if not already logged in) so I can download his player data.
Player 2 manually logs in to Game Center so I can download his player data.
I logout player 2 and auto-login player 1 again, since it's his device.
They play the game... and enjoy it immensely!
After the match, I update player 1's data and achievements automatically.
I auto-login player 2 and update his data and achievements.
I logout player 2 and auto-login player 1 again.
Is the auto-login possible for multiple users? Or would I have to ask them to re-login manually?
It's not possible to auto login users in Game Center.
iOS 9 has introduced a Guest Player in Game Center, which allows you to make a pass and play game on the same device.
I am working on adding achievements to an iOS game, but I have a pretty strong hatred of game center, and I don't want to break the player's immersion by displaying achievement pop-ups all the time.
Does Apple allow game center games to not report achievements to the player as they are earned? In the documentation they have a list of requirements but it doesn't seem to include displaying the achievement pop-up when one is earned.
I know there's the option to re-skin the achievement pop-up using a class like this one but I'd like to not show the pop-ups at all if possible.
GKAchievement has a property 'showsCompletionBanner'. Just set it to NO. The documentation says you should then implement some way to display the achievement to the player but so far as I know that could be long after the achievement is earned -- for example when the player launches the Game Center app.
https://developer.apple.com/library/ios/#documentation/GameKit/Reference/GKAchievement_Ref/Reference/Reference.html
I'm writing a turn based game in which a player can be eliminated by another player. When this happens I'd like to notify the player who's been eliminated that they have lost the game. I'm setting the MatchOutcome on the player, but it seems like the notification isn't sent to the player until the match as a whole is over.
Is there a way to do this with the game center APIs, or would I have to implement my own push notifications on top of GameCenters notifications?
How about this solution, given a game between players A, B, C and D and an alphabetical play order:
Player A kills player C. At the end of the turn, play passes to the dead player (player C).
Player C is notified of their turn and discovers that they have been eliminated. The game automatically removes them from the match and passes play to player B (as B should have been next to act after A).
After player B's turn, play passes to player D and the game continues as normal.
I am thinking about making the platformer starter kit distributed by Microsoft XNA studio; into a local platformer game.
I'm trying to figure out how to add another player in the game so that there are two players.
Has anyone done this before or know how to do this?
thanks
You would need to have a second player object that you would track separately from the first player object. Then you would need to respond to controls from the second controller, or a separate set of keyboard input than the first player object.
To get the controls for the second player (using the Xbox 360 controller) you could use:
GamePad.GetState(1); // 1 is the index, so it refers to player 2.
MSDN