Generating the same random number for Game Center Match - ios

I am in the process of creating an iOS multiplayer game and I want each player's screen to look EXACTLY like their opponents. For example, lets say I have 9 squares on the screen each with a number inside of them. I want each square on both screens to have exactly the same number. How can I do this through GameCenter? I understand how to send and receive data from player from player but I need a mechanism that sends the same number to both players in the game without each player generating their own random number.
Any help would be greatly appreciated!

My best answer would be to pull the data from a source online etc.
Have one device as the designated 'randomness' maker, and have that device send that data to the other one to use. Hope that helps

I would suggest using a seeded random value.

Related

How would you go about creating a random spawner for coins within a certain area? It has to re-spawn coins after the player has collected enough too

I have a coin which rotates and changes size so far. I want to be able to set an area (which is not a nice square of course) that they can randomly spawn locations. The thing it has to do is once there are less that 7 coins then it spawns more.
Anyone able to give me some advice? Not sure what is most efficient method.
It sounds like you should be making use of ZonePlus and its getRandomPoint function.
If you want a direct reference, the creator of the module made a playground and its source code is publicly viewable. The playground contains a 'CoinSpawner' (literally what you're looking for).
You can either make use of "Region3" or you can set up multiple possible spawn points and run a math.random function to choose which one.

ARKit Level measuring

I wonder how to create level measuring app with ARKit like iOS 12 Measure app does.
I am searching for the solution or idea from last 1 week. I have seen number of videos and tutorials but I didn't get idea how to do it.
What I think is ARSceneview's pointOfView node which represent the camera can be used to do it like can get eulerAngles and do something but I am not able to figure out.
Please any help or suggestion would be appreciated. I request you to Please Don't close this question.
For getting the value to how level the phone is, I'd recommend using self.sceneView.pointOfView?.orientation (if you only want one of the 3 values from this SCNVector just add .x, .y or .z on the end).
For instance if I hold my phone perfectly upright, the value of self.sceneView.pointOfView?.orientation.x will be approximately 0. Likewise, holding it upside-down will give a value of around 1 or -1.
You can use these values to figure out just how level the phone is on all three axes, and convert them to degrees.
I'd recommend placing the following code in a project, and triggering it via a button, or a loop that constantly runs it, and watch how the values change. Hopefully this helps. (Note that sceneView is replaced by whatever the name of your ARKit SceneView is named.)
print(self.sceneView.pointOfView?.orientation.x)
print(self.sceneView.pointOfView?.orientation.y)
print(self.sceneView.pointOfView?.orientation.z)

Making a simple scoreboard with sprite kit

So I have seen some totorials around that tell how to make a scoreboard using the Game Center API. Don't get me wrong I love the idea of Game Center, but I dont want my users to have to fuddle with logging in and I dont want to use their way of displaying scores because it does not match the style of the game.
Does anyone know of a better way to do this so I can decide how to display the scoreboard? All I want to do is tell the user his numerical rank like "rank: 1054", and then display the top 100 users (each user has their best score up). And then if I could just have an array with a string for their name, and numbers for their score. I am fine using the Game Center API as long as I dont have to use it for displaying it.
Also is their a way I could make like an "int" that is stored on Game Center that keeps track of how many times the play button has been pressed for all users? Thanks much!

How do i increase percentage achievement in Game center?

i am developing a sport application in IOS using Game Center integration. I have already configured all Game Center functions in my app, the only thing that is driving me crazy is the fact that i cannot increase the achievement percentage.
I want to do something like this:
GKAchievement *ach1 = [[GKAchievement alloc] initWithIdentifier:
#"1"];
ach1.percentComplete=ach1.percentComplete+50;
Is there a way to increse the percentage like this? Because i have 2 achievements in Game Center that reward the player for everytime he plays the game. For instance:
Achievement one: Play 5 games
Achievement two: Play 10 games
So my main goal is to get the previous achievement percentage and increase it with a constant.
The fact is ach1.percentComplete always return 0. Is there a way to make it return the previous percentage? Thanks for answering.
Not exactly what you have asked for, but I think you need to go about this a different way.
The number of games the user has played, should be part of some user data structure that is saved on the device.. and then update the percentage complete using that data.
But to expand a bit more on getting the current progress of an achievement, you should check to see if ach1 is null or not before accessing anything off of it. If ach1 is valid, then maybe there is a problem with the writing of current progress.
If you load all achievements and iterate them using GKAchievement loadAchievementsWithCompletionHandler percentComplete will contain the current value. Check the question's code here: GameKit achievement questions
Apple makes it wonky ...

Can iOS Game Center pass strings/objects between players in the game?

Never used Game Center before in my apps. So be nice if the question is naive. I'm not sure if this is the right place to ask either. :)
I'm currently thinking to make my app support Game Center, primarily for the purpose of promoting my app. My app actually is a puzzle like game, think of Crossword puzzles, so it's not a very much multi-player game. However, I think I can make it competitive: one makes puzzle and the other solves it; the second round, the players switch roles. Now, my question is if Game Center supports such format. For example, does Game Center allows user pass a string or other kind of objects to other player? If it does, then I can implement the puzzle (provided by one player) into a string and decode it at other players end.
This sounds like exactly what the turn based game APIs introduced in iOS 5 are for. Check the GsmeKit docs.

Resources