Pause Screen Design iOS game - ios

My game has a pause screen which doubles as the main title screen with high scores. It is semi-transparent so the user can see what state the game-round was in. They can see the last message such as "Win" or "Loss". In the case of an interruption or pause they see "Redo". My game already handles interruptions gracefully, saving state and restoring last round so that the user can try again.
Question; when the user closes the app (hits home button) or if the app is interrupted with an incoming phone call during game-play, when the app comes back into the foreground should I show the pause screen or should I take them back to the game? Another way to phrase this question would be, should the home button and the pause button behave virtually the same for game-play interruption? (I presume that if the user were in a sub-screen, non-game-play, they would be taken back to that sub-screen).
Question 2; What does it mean to pause? I believe all sounds should cease but can I get away with keeping some minimal animation going? I do know that if the app were to go into the background that the OpenGL ES 2 animation would have to cease. Do you think users would prefer to have no animations during pause? I question the extent to which battery life should influence the answer.

I think this is a very subjective question. I'll try to give you some input.
I would say the good rule of thumb is: Will it affect your game play if you don't pause the game? For example, if your game is a chess or sudoku game, it wouldn't really matter if you pause the game when the user exit to home screen. However if your game is an action game that each mili second is very important and will decide whether the user will win, then in that case you would need to pause the game.
What does it mean to pause: It depends on your implementation. It can be anything you want. You can even continue the animation in the background if you want. This is all up to you.

Related

Chess - iOS - SpriteKit - Human move is not displayed until computer thinking ends

I am developing an IOS Chess app using SpriteKit in Swift2. While playing the game against computer player, human move is not displayed until computer thinking ends. After computer thinking ends, both (human move and computer move) moves are displayed together.
Expected functionality: Once human plays his/her move, the move must be displayed on screen. Only after displaying the human move, computer thinking must start.
I initially had the call to computer thinking logic inside touchesBegan function. It didn't work as expected. Then I moved the call into touchesEnded function. The issue remained. Now I have placed the call inside update function. The issue still remains.
I couldn't find an answer for this issue. Is there any away to address this?
Thanks,
ArtBajji
If the problem is that the "computer" reacts to quickly after a human move, you could use a dispatch_after block implemented in your touchesEnded.
let delay = 0 //time in seconds
dispatch_after(delay, dispatch_get_main_queue()) {
//computer starts thinking
}

Objective C - Detect if finger is held on screen at app startup

I'd like to perform an action when the user has their finger held on the screen when my app startups.
To give an example: When the App launches and the launch screen is showing up, the user has a finger on the screen as long as the first ViewController appears. When the first ViewController gets into the viewDidAppear() function, I want to detect, that the users finger is on the screen and perform an action, like f.ex. jumping straight into the lastest received email. Basically this is supposed to be a kind of shortcut to an main action.
Is there any method to detect an already laying finger on the screen? To be exactly I'd like to check for the tap in viewDidAppear()
Unless the nature of Time has changed since the last time I checked, your app cannot detect what the user was doing before the app launched. The app, ex hypothesi, was not running at that time. And the mere presence of a finger on the screen during app launch will not generate a touch event that the app can detect.
The system can detect it, however, since is running before your app launches. That is why Apple added force-touch Shortcuts (for appropriate hardware). The only way you can do what you're asking is to rely on that API. Hardware that lacks this feature will simply have to do without this feature.
(After all, this is how Apple makes money: by trying to make users jealous of hardware they don't have, so that they buy new hardware. You would want to rob Apple of its income by reading this feature backwards onto old hardware, even if you could, now would you?)

'Play on' feature is an in-app purchase? SpriteKit/Swift

I'm near the end of developing a game, and long story short, the game will be over when an object crashes into one of the obstacles. I've got that part down and the game runs really well by itself, but there is one more step I am looking to add in.
I would like to add in an in-app purchase of a 'play on' feature, that is, starting where the user's game originally ended so they can continue on. I'm okay with in-app purchases on the whole, but I guess what I want to know is how does one make it possible to 'play on' following the in app purchase? I'm just looking for something basic I can build on.
I'm a Stack newbie, as I've only created an account today (but I've been programming for a little while and this site has helped me so many times), so I'm sorry if there has been a duplicate thread made elsewhere. I did look around for an hour or so before deciding to post (and Google was no help).
As a general stack overflow rule you should always post some of your own code or what code you have played around with.
I am actually also looking to integrate a playOn button in my game. Now I haven't actually found the perfect solution for this yet but hopefully this helps you get on the right track.
Step 1:
How have you programmed your game over scenario?
Are you just pausing the scene, are you pausing nodes or are you removing all children from your scene?
The way I pause my scene is by creating a worldNode and than adding all objects that I need paused to the worldNode.
You can read my two answered questions for more detail
Keeping the game paused after app become active?
Sprite moves two places after being paused and then unpaused
This way when I pause my game I dont actually pause the scene which gives me more flexibility adding pauseMenus etc. Furthermore its seems smoother than pausing the skView.
I also call pause when the player died, which means I could resume the enemies/obstacles from where they left of if I call resume.
So my game over method looks like this
func gameOver() {
pause() // call pause method to pause worldNode etc
//show game over screen including playOn button
}
Step 2:
Now in regards to respawning the player, it depends on how he is positioned, how far he can move etc.
If your player is mostly in the same area than you can probably just respawn you player manually once "PlayOn" is pressed and than resume the game as if it was just paused.
So once your playOn button is pressed you can call a method like so
func playOnPressed() {
// Remove current player
// Doesnt have to be called, you could just change the position
player.removeFromParent()
// Add player manually again to scene or just reposition him
...
// Remove obstacle that killed player
// haven't found a great solution for this yet
// You could make the player not receive damage for 5 seconds to make sure you dont die immediately after playOn is pressed
// Call resume method, maybe with delay if needed
resume()
}
If your player position could be all over the screen, as in my game, I have been playing around with a few things so far.
I created a position property to track the player position
playerPosition = CGPoint!
and than in my scene update method I constantly update this method to the
actual position of the player.
override func update(currentTime: CFTimeInterval) {
if gameOver = false {
playerPosition = player.position
}
}
I than have been playing around with the "playOnPressed" method,
func playOnPressed() {
// Remove current player
//Doesnt have to be called, you could just change the positioon
player.removeFromParent()
// Add player manually again to scene or just reposition him
...
player = SKSpriteNode(...
player.position.x = playerPosition.x - 40 // adjust this so it doesnt spawn where he died but maybe a bit further back
player.position.y = playerPosition.y // adjust if needed
// Remove obstacle that killed player
// haven't found a great solution for this yet
// You could make the player not receive damage for 5 seconds to make sure you dont die immediately after playOn is pressed
// Call resume method, with delay if needed
resume()
}
I hope this helps you playing around with your playOn button, if someone has a better way I would also appreciate it immensely.

Loading state of in-progress game in iOS

One of the iOS games that I really like (Fieldrunners 2) allows user to continue his/her game even after the app is killed mid-level (during game play). When the user launches the app again, it asks whether the user wants to continue the in-progress level.
How are they doing this? WHat is the easiest and smartest way (cocos2d and ios) to reload an in-progress game? It seems to me that there are so many states that need to be saved. Is it as tedious as I think it is?
EDIT:
When I say killed, I double clicked the home button and then I pressed and held on the app's icon and click the x icon.

Trouble toggling the userInteractionEnabled property in iOS

I am developing a tic tac toe game for iOS and I am using a combination of UIButtons and UIImageViews to allow for user interaction and to display the moves made. My problem is that the buttons continue to accept user input before the cpu makes it's move, which breaks my game logic. I have made several attempts to toggle the userInteractionEnabled property, but I have only been able to turn it off. The engine that gets everything started in the game is my buttonPressed method. I also toggle the userInteractionEnabled property within this method and therein lies my problem: How do I re-enable the property after disabling user interaction? Is there a method that is called in between events that I can overwrite?
I have searched the web and I have searched through the developer documentation provided by Apple and I found information on the touchesBegan and touchesEnded methods. However, from what I understand, those methods need to be explicitly called which brings me back to my original problem of not being able to call those functions without the user's interaction.
If anyone can help, I would greatly appreciate it! I have been racking my brain over this for the past couple of weeks and I am just not seeing a solution.
I'd think that for a game like tic-tac-toe, calculating the countermove should be so fast that it can be done immediately in response to the first button press. If you're doing something complicated to calculate the next move, like kicking off a thread, you might want to reconsider that.
Let's say, though, that your game is something like chess or go, where coming up with a countermove might take a bit longer. Your view controller should have a method to make a move for the current player, let's call it -makeMove:. Your -buttonPressed action should call that method to make a move for the user. In response, -makeMove: should update the state of the game, switch the current player to the next player. If the new current player is the computer, it should then disable the controls and start the process of calculating the next move. Let's imagine that's done by invoking some NSOperation, so that coming up with the next move is an asynchronous task. Once the operation has come up with a move, it should again invoke -makeMove: (by calling -performSelectorOnMainThread:), which will again update the game state and the current player. This time, though, it should see that the new current player is not the computer, and so it should re-enable the controls.

Resources