iOS9 Sprite Kit issues

我的未来我决定 提交于 2019-12-06 17:12:30

问题


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.


回答1:


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.




回答2:


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.




回答3:


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.




回答4:


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.



来源:https://stackoverflow.com/questions/32665866/ios9-sprite-kit-issues

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!