Permutated width and height

Explanation For some reason, width and height values are being swapped in my game (as you can see below) that is set to be in landscape orientation. This way, the sprite that should be centered in the screen, is totally off the right position. Code Y

Fast. How can I get the type of node.children?

I have this as my code: for child in viewsArray[i].children { let childNode = child as! SKSpriteNode if childNode.color == UIColor.blackColor() && childNode.alpha == 1 { childNode.alpha = 0.5 } } It gives me this error: Could not cast value of typ

Program crashes when the function is called multiple times

I have a function that moves a SKSpriteNode from one point to another. It works fine when I call it once. But when I call it multiple times, the whole program crashes. func play() { self.moveNode() self.moveNode() } func moveNode() { let player = SKS

How can I get the number of skspritenodes in a scene?

I want to find out what the number of nodes is in a scene. For example, I want to create an if statement so that if the number of nodes in the scene is 0 or any other number, I would call a function. This is what i have done but it only calls the fun

SpriteKit EXC_BAD_ACCESS NSTimer

I have a GameScene which I implement in GameViewController. GameViewController contains back button over game scene. So when I finish my game I have an NSTimer with 2 sec delay. self.timer = [NSTimer scheduledTimerWithTimeInterval:2.0 target:self sel

Bridle the knot to the limits of the screen

override func touchesMoved(touches: NSSet, withEvent event: UIEvent) { for touch: AnyObject in touches { let location = touch.locationInNode(self) let previousLocation = touch.previousLocationInNode(self) var translation = CGPointMake(location.x - pr

Resize a SKShapeNode

How do I resize a SKShapeNode? What I've tried so far: Frame resize box.frame.width = 10 Gives the error Cannot assign to the result of this expression SKAction let actionResize = SKAction.resizeToWidth(10, duration: NSTimeInterval(0.1)) box.runActio

Apply the impulse does not work

I'm using the following code to have a ball be falling and whenever I tap it it should hop back up, hence the apply impulse in my touchesBegan method. However when I run this code the ball begins to fall but when I tap on it, it juste keeps falling.

SpriteKit Floats

Why does SpriteKit use floats for position even though there can't be a decimal point in pixels? I am building a game in SpriteKit and am wondering whether I should make the character position in ints to optimize it but am not sure whether there will

How to create an empty SKSpriteNode in Swift?

How do I create an empty SKSpriteNode in Swift? I need a SKSpriteNode which I can add SKSpriteNode children to. The equivalent of this in Objective-C: SKSpriteNode *textSprite = [SKSpriteNode new]; Let type inference do the work of figuring out the t

Clear SKScene after modal transition

I have been creating a game in sprite kit using swift and have encountered a problem. I have two view controllers, each with one scene and one transitions to the other modally. This all works perfectly first time round, but then when i return to the

Swift and Spritekit will not work on a device running iOS 7.1

I'm getting a really weird warning when I try to run my Swift project on my device, using Xcode 6. The device is running iOS 7.1, and my mac is running Mavericks. I have written a little game in Swift and SpriteKit, and it works in Simulator, but whe

Touch a node in SpriteKit

So I am working on making a tower defense game and have the tile board working and able to place towers... to a degree. When a player clicks a button above the grid, it will toggle on the tower placement and allow the player to place towers on a cell

What is SKNode & Ldquo; origin & rdquo;

Docs for SKPhysicsBody bodyWithCircleOfRadius: says: Creates a circular physics body centered on the owning node's origin. So is origin a node position? Couldnt find it anywere.So is origin a node position? The origin is the point with coordinates (0

The iOS 7.1 Sprite Kit Crash on removeFromParent

I have updated iPad Air to 7.1 and Xcode to 5.1. Xcode wanted to update my project to recommended settings, I agreed. After that my game began crashing in a couple of places when I remove node from parent. That was a surprise for me - there were no c

Draw in color the shape of your SKPhysicsBody

Creating a game with SpriteKit and its actually working out very well. I am using physics and having the ability to see actually where my bodies are because I might have some alpha inside of my sprites will really be helpful. This will also be helpfu

SKSpriteNode, added to / removed from the parent hook

Is there any (best practice) way within the class to hook the events when a SKSpriteNode (or SKNode) is added onto and removed from a parent node?Without the need of Kobold Kit, you can sub-class a SKSpriteNode (or any SKNode for the fact) and extend

How to implement a mouse seal in Sprite Kit?

I have working implementation of drag and drop feature written in Cocos2d + Box2d for iOS. I need to port it to Sprite Kit. The logic is pretty basic: when user touching the screen, find sprite under the finger create mouse joint between found sprite

Crash in the background - Linked Sprite-Kit

As the title says- my Sprite Kit game crashes every now and then in background, always with this error- Exception Type: EXC_BAD_ACCESS (SIGSEGV) Exception Subtype: KERN_INVALID_ADDRESS at 0x00000001 Triggered by Thread: 0 Thread 0 Crashed: 0 libGPUSu