SpriteKit scene/node on top a paused scene - ios7

I'm trying to add a scene/node on top of a paused scene with a transparent background so the active scene view will still be visible.
I pause the scene with scene.view.paused = YES; but that means that everything is paused but the update method.
With Cocos2d one could easily push a new scene on top of an existing one but unfortunately SpriteKit does not have this capability.
Is there a way to pause a scene and add an active scene/node on top of it ?
A solution I've tried :
Creating an additional view controller with the pause-scene content and present it via the active view controller when needed but the background is always black so transparency is not achieved and some other problems occur with the original scene (I'll elaborate on these if needed).

It's all there. You do not have to present a new scene or view.
In a nutshell:
Pause the node where your game content is on that you want to pause. If you do all the processing in the scene class you'll have to refactor it, I'm afraid. The key is having a SKNode that acts as your "game layer" so that you can pause just that particular node. If you receive update: and other regular method calls to the game layer, it should check its self.paused state before doing any processing.
When you have that, pause the game layer node which will pause all the nodes and actions in it.
Now add another "layer" node with whatever UI you need to the scene. That could be your game over or pause layer, and it will be perfectly happy to receive input and run actions while the game layer is paused.

Related

Adding a progress bar(NSProgressIndicator) during level generation in SKScene

I'm creating a game using the sprite-kit framework. I didn't programe so much for OS X or iOS and i think transition between SKScene and views or screens have many differences.
I created a game menu using Sprite-kit and want to put a progress bar showing progress of level generation and other game operations and after that move to another SKScene with the scenario, hero, enemies, etc.
I found that Cocoa has a progress bar class and UI object. I pick an sample from cocoaControls
I know how to create transitions between SkScenes, there is no problem about that, but looking into the cocoa controls sample code i found a xib file which i don't know how to put into two skscenes and how to load it from the Skscene's game menu.

How to forward pointer events

I was able to get this working in iOS but I am having trouble with Win 8. What I need to do is this:
I have a drawing view that is the forward most child of a ScrollViewer. When I enable drawing mode from a button in the app bar, this view becomes active. With one touch, I want the user to be able to perform the current drawing action, but with two touches I want the touches to go to the scroll view instead for scrolling and zooming. I am able to distinguish between 1 and 2 (or more) fingers, but I don't know what to do after that point.
I tried removing the manipulation mode from the drawing view so that it would not block the scroll view, but the touches continued to be swallowed by the drawing view. I also tried calling ReleasePointerCapture but that had no effect either. How can I forward touch events using the WinRT API?
For some more information, I am making use of the PointerPressed, PointerChanged, etc events in the drawing view.

Touch detection without event processing

I am using cocos2d. I would like to be able to detect whether the screen is touched at a particular instant - that is, rather than intercepting an event when it occurs, I want to detect the presence of touch at a particular moment.
The reason is that I am animating sprites and want to determine if the sprite should keep moving - if the screen is still touched. I cannot use ccTouchesEnded because each time an animation starts I set isTouchEnabled to false because I also want the user to be able to tap rapidly on the screen to move the sprite but if they tapped too rapidly, it would mess with the position of the sprite during the animation process - which I have found screws up the positions of my objects in weird ways.
Is this possible?
There does not appear to be any public API to detect touches other than enabling and receiving these events in the main UI run loop.
You can keep handling events, and set the state left by the last touch event in a model object or global variables. Then you can poll your app's own internal state at any time.
Instead of disabling touches, you can just have your touch handler not do inappropriate things if the event time stamp is too close to some animation start time.

How transition between layers in cocos2d?

I have a menu scene hierarchy like so:
Scene
|
Background Layer
| |
Main Menu Settings Menu
I want to transition from the Main Menu to the Settings Menu without moving the Background Layer. There is plenty of documentation on how to transition between scenes, but nothing that I can find between layers. Both the Main Menu and Settings Menu layer are full screen with transparent backgrounds, I just want to slide in between them without moving the background.
Simple problem, but I am totally stumped after searching the web for over an hour.
Have a node which Main Menu is a child of. Add Settings Menu to this node with an offset of +screenWidth or -screenWidth depending on the direction desired. Then create a sequence of a CCMoveTo where you move your node to the other side of the screen (or off screen if going backwards) followed by a CCCallFunc which calls a function to remove the Main Menu layer from the main node. This will work equally well for vertical transitions (just use screenHeight and move the node vertically).

Reverse animation before it is finished

I have a button and when the user touches down and holds a popup appears. However, when the user releases his thumb before the pop animation finishes I'd like the animation to stop where it is and autoreverse to the initial position. How can I accomplish this?
Currently I'm simply using UIViews -animateWithDuration:animations:completion:. Do I have to set the animations explicitly in this case?
I've already tried reading the current state from the presentationLayer properties, but that somehow didn't work.
You can start the second animation using the UIViewAnimationOptionBeginFromCurrentState option. This will stop the first animation if it's still running.