ios7 - Pausing a sprite kit scene -
@property (sk_nonatomic_iosonly, getter = ispaused) bool paused;
i found line of code add project, how pause whole game?
for example:
-(void)touchesbegan:(nsset *)touches withevent:(uievent *)event{ (uitouch *touch in touches) { skspritenode *pause = (skspritenode*)[self childnodewithname:@"pause"]; cgpoint location = [touch locationinnode:self]; // nslog(@"** touch location ** \nx: %f / y: %f", location.x, location.y); if([pause containspoint:location]) { nslog(@"pause game here somehow"); } }
}
as can see, have button set up. when select it, how pause whole scene? , resume when hits resume button.
ok got advice call
self.scene.view.paused = yes;
except here problem, in app delegate
- (void)applicationwillresignactive:(uiapplication *)application{ skview *view = (skview *)self.window.rootviewcontroller.view; view.paused = yes;}
and
- (void)applicationdidbecomeactive:(uiapplication *)application{ skview *view = (skview *)self.window.rootviewcontroller.view; view.paused = no;
i make type skview, when skscene. anyway fix this? suggest make scenes views retyping code?
use skview
's paused
property:
swift:
scene.view?.paused = true
objective c:
self.scene.view.paused = yes;
this stop actions , physics simulation.
Comments
Post a Comment