FAQ Database Discussion Community


How do I run a function in my GameScene when a contact occurs in my level1Scene in Swift Spritekit?

swift,skscene
So I have this function in my GameScene and its a button for level 2 and the only way it could appear in my GameScene is when a contact occurs between the HeroCategory and GoldKeyCategory in my level1Scene. How would I call the levelTwoButton function when a contact occurs between...

How to make a view scrollable to view the full scene with sprites with Swift and SpriteKit?

ios,swift,sprite-kit,sprite,skscene
I have a Scene which now fills in the view: scene.size = skView.bounds.size scene.scaleMode = .AspectFill I fill in the scene with sprites from bottom to top and in my up they need to go further up - outside the view. So my scene should have the same width as...

How can I set my view to the whole frame?

ios,swift,sprite-kit,skscene
I am making a game in swift. I was wondering how I could fix the problem where the view of my scene does not match of with the Scene's frame. To be more specific, I want to be able to make an edge physics body around the screen so that...

SKScene bounds and positioning

ios,positioning,skscene
I'm trying my best to use my "responsive" / "adaptive" knowledge to apply it to positioning in my SKScene. However, it would appear there's a problem. As the width / height of the scene aren't accurate. In this example, the view's anchor point is centerpoint i.e 0.5, 0.5. SKLabelNode *label...

iPhone 5s SpriteKit drawing oddities

ios,sprite-kit,skscene,skview
I understand that the iPhone 5s has a pixel resolution of 640 x 1136 and a point resolution of 320 x 568 (for backward compatibility with non-Retina devices). The problem/confusion/oddity seems to come in when I'm working with SpriteKit. Example: I'm drawing a line from bottom-left corner (0, 0) to...

Xcode Scene Editor - How do you display entities list?

ios,xcode,scenekit,skscene
I cannot find a way to display the entities list on xcode as shown in this picture from Apple website:

How to add a sprite from another .swift file?

ios,swift,sprite-kit,skscene,skview
I have a project I've been working on for some time. I am using Sprite-Kit but now want to be able to add a child node from a swift file that is different from the GameScene.swift file. Some of main code from the view controller that loads the GameScene is...

SKScene becomes unresponsive while being idle

swift,sprite-kit,scenekit,skscene
Hello I have a SceneKit game. All the game play is in one scene and when the game is over the sprit kit overlay acts as a game over screen and when they hit play again the sprite kit labels disappear and the game resets all in the same scene....

Updating game score held in SKScene from a SKSpriteNode sublcass in Swift

ios,swift,sprite-kit,skspritenode,skscene
We have a main Game Scene SKScene which holds the HUD logic and score. We also have a subclass of SKSpriteNode for an object. When the object is tapped we handle the touch in the SKSpriteNode subclass. override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) { What we would like to...

Affecting a Child From Another Scene Using Sprite Kit and Swift

ios,swift,sprite-kit,skspritenode,skscene
I'm trying to teach myself Sprite Kit and Swift. What I'm trying to do is access a child node from an ArcheryScene.sks file and affect that child from the ArcheryScene.swift file. For Example: In my ArcheryScene.swift file I have added this line of code: let scene = SKScene(fileNamed: "ArcheryScene"). This...

How to pause SKScene from SKView or ViewController

ios,swift,uiviewcontroller,sprite-kit,skscene
I have the following code to pause game scene: class GameProcessScene: SKScene { ... var onPause: Bool = false { willSet { self.paused = newValue self.view?.paused = newValue } } ... override func touchesBegan(touches: NSSet, withEvent event: UIEvent) { for touch in touches { let location = touch.locationInNode(self) let possiblePauseNode...

How to call method from ViewController in GameScene

ios,swift,uiviewcontroller,sprite-kit,skscene
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 checked the segue name and it is correct. Whenever I call this in my GameScene.swift file...

Popup view goes back to initial SKScene instead of current SKScene

ios,swift,uiview,skscene
I have two SKScenes that are called StartMenu, GameMenu and I have created a popup view (AddSubView) to be added inside GameMenu. My problem is that whenever I call the function that runs the popupview, it goes back to the initial SKScene - StartMenu instead of the current SKScene GameMenu....

SKScene Fails to deallocate memory resulting in bounded memory growth

crash,sprite-kit,dealloc,skscene
I have been struggling with this for days, for some reason my SKScenes are not deallocating correctly, this results in bounded memory growth as each time i exit and enter a scene the memory jumps up. This means after say 10 rounds of the game the App crashes. As far...

dismissing a textview that is added as subview programmatically in scene

ios,objective-c,sprite-kit,uitextview,skscene
as the title suggests i have added a UITextView to my scene and it works fine. the only issue i have is when i use the back button to go back to the main menu the text view remains on the screen. for the life of me i can't figure...