17

Everything was going so well until I upgraded to xCode 7 and iOS 9....

My current project is a 2D platform game, ever since the upgrade I've fallen fowl of the sprite kit bug/errors that many of us seem to be facing.

My issue is that all sprites appear randomly in terms of their zPosition position each time the game runs on either simulator or device. I've been scouring stack for an answer without luck, so far I've tried.

  • Moving all images to .xcassets Like described here
  • Changing the iOS Development Target to iOS 9.0 under Build Settings
  • Changing all images in code to include their extension i.e. "background.png"

I still have the same problem where the images layer themselves apparently randomly, can anyone recommend a fix or some other possible solutions I may have missed?

Thank you.

Community
  • 1
  • 1
Rich Townsend
  • 571
  • 1
  • 5
  • 21
  • 1
    Just curious, do you use ignoresSiblingsOrder = true and have you set all zPositions for your nodes explicitly? – Whirlwind Sep 19 '15 at 10:23
  • 4
    I'm having a ton of issues with Sprite Kit and XCode 7 too. Changed zPositions, animations running too fast, and changed touch detection. Touches of hidden sprite nodes are not getting detected anymore. Setting alpha to 0.0 does not work either. You have to set it to something like 0.001 to make it work again. – Tobias Lott Sep 19 '15 at 11:00
  • I'm experiencing the same issues with images disappearing. In addition, I had implemented nice parallax scene transitions by not pausing the outgoing scene. This also seems broken now; both incoming and outgoing scenes are paused for me during a scene transition. – empee Sep 23 '15 at 06:42
  • This update has been disastrous for my live game. Performance has also taken a massive hit, apparently down to changes in SKCropNodes. And all Apple ever respond with is 'Please create a bug report'. – Smikey Sep 23 '15 at 13:39
  • @TobiasLott Sprite Kit touch/nodes detection no longer recognizes a node with 0 alpha, but a better solution is to set it to 1 alpha, with color UIColor.clearColor(). – Naftali Beder Sep 30 '15 at 18:20

4 Answers4

15

SpriteKit in iOS 9 GM is VERY broken. I don't know what they did at Apple, but a couple of people should be fired. Take a look at all the complaints here : https://forums.developer.apple.com

My issue, for one, is that when I load an SKSpriteNode through the imageNamed init function, sometimes the sprites appear, sometimes they don't. I am using device-specific images, and sometimes the SAME line of code will load Rock@2x~ipad.png which will appear because it's my device-specific image, sometimes it will load Rock.png, which won't appear because I haven't included universal images.

I have reported this bug to Apple and they haven't fixed it yet. They're asking me for test scenarios, I have explained them 3 times in different manners and I'm getting short on explanations here.

All I can do at this point is tell you to report these bugs ASAP to Apple, and cross your fingers someone intelligent will read your bug report and do something with it.

PsykX
  • 151
  • 6
  • 4
    I had this problem, I fixed it by adding zPosition = -1 to the first background layer and used zPosition again on EVERY OTHER SPRITE to sort out the correct order of sprites, really annoying but solved the problem. Hope this helps. – Rich Townsend Sep 20 '15 at 05:39
  • 1
    It's amazingly broken. Honestly I don't know how it got released in this way. – Jamona Mican Sep 20 '15 at 10:46
  • @PsykX if Apple wants a reproducible example, I was following this tutorial here: http://bigspritegames.com/isometric-tile-based-game-part-1/#comment-3976 and if you download the finished example: http://bigspritegames.com/?wpdmdl=372 (might need to a quick Swift 2 conversion using Xcode 7) you'll see 4 of the wall sprite not rendering. I myself followed the tutorial using Objective C and the results were the same, although it was working well (all tiles rendering correctly) before I started the "iso_3d_" tile part. – Zhang Nov 24 '15 at 10:47
  • @RichTownsend thank you for posting about `zPosition`. That helped solve some of my issues. – Aaron Lelevier Jun 05 '16 at 23:32
8

As @tobias-lott mentioned in his comment I've had to bow include zPosition to every Sprite rather then letting the code order the sprites.

Rich Townsend
  • 571
  • 1
  • 5
  • 21
5

I had the same issue with random zPositions, then I noticed the following in GameViewController.swift:

/* Sprite Kit applies additional optimizations to improve rendering performance */
skView.ignoresSiblingOrder = true

Changing ignoresSiblingOrder to false fixed the problem for me.

Tim Perkins
  • 2,339
  • 3
  • 20
  • 13
-3

The best way for you is that you download the Xcode 7 and rebuild your app and deal with the building problem.

with the launch of iOS 9 Some deprecated API were removed from iOS 9,which make app crashed.!

I think the same is happening at your side also.

You can find all the latest change here: https://developer.apple.com/library/ios/releasenotes/General/iOS90APIDiffs/index.html

Build you app with xcode 7 and swift 2.0.

Suraj Sonawane
  • 2,044
  • 1
  • 14
  • 24
  • 4
    "Build your app with swift 2.0"....Well, imagine you built a really nice game with lots of features. All in Objective C, which is still highly valid and supported by Apple. To having to rewrite every bit of code to Swift in order to get it working on iOS 9 does not seem the best solution to me. – empee Sep 23 '15 at 06:38