Menu
  • HOME
  • TAGS

How to detect collision between SKSpriteNode and SKView SpriteKit

ios,sprite-kit,collision,skspritenode,skview

SKView doesn't have physicsBody property, so it cannot collide. You can, however, manually check if SKView's frame intersects with SKSpriteNode's frame: - (void)update:(CFTimeInterval)currentTime { if (CGRectIntersectsRect(skView.frame, node.frame) { .... } } ...

How to add a sprite from another .swift file?

ios,swift,sprite-kit,skscene,skview

I had 2 things wrong in my code. The first is visible in my question: I should have declared "theScene" using "var" and not "let" The second problem was in my gamescene, I needed to put "theScene = self" Apple DTS helped me solve this problem....

UIScrollViewDelegate functions not called

ios,swift,sprite-kit,uiscrollviewdelegate,skview

Your UIScrollViewDelegate function implementations do not match the declarations in the documentation. Specifically, you're missing the UIScrollView parameter. For example, this: func scrollViewDidScroll() { println("entering scrollViewDidScroll function") adjustContent() } should be: func scrollViewDidScroll(scrollView: UIScrollView) { println("entering scrollViewDidScroll function") adjustContent() } ...

Lag / Delay on ModalViewController dismiss after loading an xib view over SKView

objective-c,sprite-kit,modalviewcontroller,skview

It is caused by autolayout constraints on the xib view. To arrive to that conclusion, I created a simple view with a subview and added it to SKView. The problem I reported above happened only when I used auto layout constraints to place the subview. I don't know why this...

Difference between paused property of SKScene and SKView

ios,objective-c,sprite-kit,skscene,skview

Pausing SKView stops calling update: method for SKScene. Pausing SKScene doesn't do that. I usually pause both SKScene and SKView...

How to take screen shot programmatically (Swift, SpriteKit)

swift,sprite-kit,uigraphicscontext,skview

I think this question could be merged with this one Screenshotting on Iphone in swift only has a white background which seems the same EDIT: I think I found a solution. First read this post: How Do I Take a Screen Shot of a UIView? I create an Extensions.swift file...

SKView Flashing Gray before Scene

ios,sprite-kit,skscene,skview

I solved this issue by creating another scene that is simply black. Instead of setting the scene I want to move away from to nil, I simply substitute in the black scene. A scene with nothing on it (blank SKView) has a gray color which is the cause of my...

How to lower a UIView element in a SpriteKit scene

objective-c,uiview,uiimageview,sprite-kit,skview

Here's a SpriteKit-friendly way to draw random lines on a background image. The basic steps are Create a blank image Convert the image to an SKTexture Create a sprite with the texture Draw a random line on the image Update the sprite's texture with the image Wait for 0.1 seconds...

iPhone 5s SpriteKit drawing oddities

ios,sprite-kit,skscene,skview

Anyways here is how I got good results: Just open up a new project and try this: In your GameViewContrller instead of using viewDidLoad use viewWillLayoutSubviews. EDIT: Here is a good explanation by Rob Mayoff about methods like viewDidLoad and viewWillLayoutSubviews. - (void)viewWillLayoutSubviews { [super viewWillLayoutSubviews]; // Configure the view....