Questions tagged [skscene]

An SKScene object represents a scene of content in Sprite Kit. A scene is the root node in a tree of Sprite Kit nodes (SKNode). These nodes provide content that the scene animates and renders for display. To display a scene, you present it from an SKView object. SKScene is Apple technology for use on iOS 7.0 and later.

An SKScene object represents a scene of content in Sprite Kit. A scene is the root node in a tree of Sprite Kit nodes (SKNode). These nodes provide content that the scene animates and renders for display. To display a scene, you present it from an SKView object.

A scene calculates the contents of a new frame by processing the following actions in order:

  • The scene calls its update: method.
  • The scene executes actions on its children.
  • The scene calls its didEvaluateActions method.
  • The scene executes any physics simulations on physics bodies in the scene.
  • The scene calls its didSimulatePhysics method.

Click Here for Apple's Documentation Reference for SKScene.

653 questions
27
votes
3 answers

Pausing a sprite kit scene

@property (SK_NONATOMIC_IOSONLY, getter = isPaused) BOOL paused; I found this line of code that I could add into my project, how would I pause my whole game? For example: -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{ for (UITouch…
temp
  • 639
  • 1
  • 8
  • 22
20
votes
4 answers

Using SpriteKit inside SwiftUI

I am having an issue when creating a SpriteKit scene within SwiftUI. I created this project initially as a SwiftUI project. Here is the code I have so far: ContentView.swift: /// Where the UI content from SwiftUI originates from. struct ContentView…
George
  • 25,988
  • 10
  • 79
  • 133
16
votes
7 answers

How to dismiss SKScene?

When Im finished with my SKScene is there a way to dismiss the SKScene from within my SKScene class? If not back in my Viewcontroller where I present my SKScene [skView presentScene:theScene]; is there a way to restart the scene or remove in from…
4GetFullOf
  • 1,738
  • 4
  • 22
  • 47
14
votes
2 answers

SpriteKit- How to zoom-in and zoom-out of an SKScene?

If I'm making a game in SpriteKit that has a large "world", and I need the user to have the option of zooming in and out of the SKScene, how would I go about this? Or, to make things simpler, in the didMoveToView function, how can I present more of…
Austin
  • 421
  • 4
  • 13
13
votes
3 answers

Create Button in SpriteKit: Swift

I want to create a button in SpriteKit or in an SKScene that sends the view to another view controller. I tried using the "performSegue with identifier ", however apparently an SKScene doesn't support this. How would I create a button that sends…
Nick Griffith
  • 492
  • 1
  • 6
  • 15
13
votes
2 answers

How to stop a audio SKAction?

Goal: I want to present a new scene: [self.scene.view presentScene:level2 transition:reveal]; and end the current background music in order to start the new background music (the new background music from level 2). TheProblem: Upon presenting…
MB_iOSDeveloper
  • 4,178
  • 4
  • 24
  • 36
12
votes
2 answers

In swift, how to get memory back to normal after an SKScene is removed?

I created a simple game with SpriteKit, however every time I run the game, the memory usage in simulator increases about 30mb, but never decreases when the game is finished. When I run the game over ten times the simulator gets slower and slower and…
Fan Zhang
  • 240
  • 3
  • 9
12
votes
1 answer

UIAlertView warning when dismissing

I'm creating an alert in the following manner: let alert = UIAlertView(title: "Network Unavailable", message: "Oh noes!", delegate: nil, cancelButtonTitle: "OK") alert.show() Works fine. …
Pinxaton
  • 437
  • 4
  • 13
11
votes
2 answers

Difference between paused property of SKScene and SKView

I am pausing my SKScene using the following code: self.paused = YES; However, according to this answer by Andrey Gordeev, one can also pause a scene using this line: self.view.paused = YES; I would like to understand what difference it would make…
ZeMoon
  • 20,054
  • 5
  • 57
  • 98
11
votes
5 answers

How to reference the current Viewcontroller from a Sprite Kit Scene

I'm having a hard time finding the answer to this question I assume is not that hard. How can I reference methods and properties defined on a viewcontroller from a SKScene ? And building on that: How can you reference the ViewController from a…
stvn
  • 1,148
  • 1
  • 8
  • 24
9
votes
2 answers

ARKit: pausing session does not stop the scene to be called

I'm using ARKit with SpriteKit. My AR feature is not a core feature in my app, users may optionally navigate to a viewController with an ARSKView where I configure and set an SKScene in the ARsession. I pause the session when the user navigates…
AppsDev
  • 12,319
  • 23
  • 93
  • 186
9
votes
4 answers

How to call method from ViewController in GameScene

I have a method that has a custom segue in my viewController that looks like this: func gameOver() { performSegueWithIdentifier("GameOver", sender: nil) } I call the method like so in GameScene.swift: GameViewController().gameOver() I double…
Jonathan H.
  • 939
  • 1
  • 7
  • 21
9
votes
2 answers

After Closing SKScene, Memory Remains High

I use a dispatch_once NSObject to create data pointers. So all game asset pointers are made when the main viewcontroller appears. In order to play a game, the user taps a UIButton corresponding to a particular level on a UIViewController. Let me…
El Tomato
  • 6,479
  • 6
  • 46
  • 75
8
votes
2 answers

SKRenderer -- the mystery class

Here I was getting all hyped about pulling off-screen Metal textures out of SpriteKit after watching the session 609 video from WWDC2017. This was over a year ago! And yet there are absolutely no overview docs on SKRenderer and there is no sample…
zzyzy
  • 973
  • 6
  • 21
8
votes
1 answer

create SKScene subclasses programmatically, without size info?

I'm trying to learn how to make a GameManager type class, and making individual classes for each of my GameScenes... probably the wrong thing to do, but for the sake of this question, please accept this as the way to do things. My GameManager looks…
Confused
  • 6,048
  • 6
  • 34
  • 75
1
2 3
43 44