sprite-kit

SpriteKit: performance hit while preloading SKTextureAtlas

隐身守侯 提交于 2019-12-06 22:38:13
问题 I'm experiencing a performance hit when preloading SKTextureAtlas : let textureAtlas = SKTextureAtlas(named: atlasName) textureAtlas.preload(completionHandler: { ... }) By performance hit, I mean FPS dropping to ~50 for a short amounts of time. I tested it with Time Profiler in Instruments and verified that this work is indeed being done on a worker thread, like stated in documentation. The image bellow shows a Time Profiler capture of the spike, caused by preloading atlas. As you can see,

iOS10 - can't render Sprite Kit scene within SceneKit with openGL

拥有回忆 提交于 2019-12-06 22:32:26
问题 Since I've updated to iOS 10, I'm not able anymore to render a Sprite Kit scene to a Scene Node while using openGL for rendering. Things work fine with Metal. The error logs: "Failed to create IOSurface image (texture)" I used to be able to do something like: class ViewController: UIViewController { @IBOutlet weak var scnView: SCNView! override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. scnView.showsStatistics = true

iOS - Different images based on device OR scaling the same image?

跟風遠走 提交于 2019-12-06 22:26:02
问题 It seems that developers always create different image assets for different devices and load them based on the device. But are there any drawbacks to just creating images for the largest resolution device (iPad) and then scaling that image down for iPhone 6, 5, etc? I use SpriteKit, so I would just create SKSpriteNodes of different sizes and apply the same texture to them and scale it to fit the node. I know that performance can be something to consider (loading large images for older devices

spritekit didBeginContact three object not worked

空扰寡人 提交于 2019-12-06 21:50:45
I am tring to [didBeginContact] by three nodes. I wrote under code. But not work correctly. when white rectangle fole without hitting black or white rectangle, println("black"), and println("blue") work... whien white rectangle hit black rectangle, println("blue") work... import SpriteKit class GameScene: SKScene, SKPhysicsContactDelegate { let blackCategory: UInt32 = 0x1 << 0 let whiteCategory: UInt32 = 0x1 << 1 let blueCategory: UInt32 = 0x1 << 2 override func didMoveToView(view: SKView) { self.physicsWorld.contactDelegate = self self.size = view.bounds.size self.physicsBody = SKPhysicsBody

SpriteKit SKScene missing touchesEnded

不羁岁月 提交于 2019-12-06 21:33:41
问题 I've noticed that touchesEnded don't always get delivered to an SKScene on multi touch. Depending on speed of removing fingers etc, I would permanently miss some of the touchesEnded. touchesCancelled is implemented and I added a custom UIView and put over the left side of the screen - no problems. I made a custom SKView and captured events - again no problem. It's obvious that SKScene doesn't get all the touchesEnded the SKView it's embedded in, but why? (BTW, I'm running the SKScene

iOS app runs on device but not in the simulator

旧城冷巷雨未停 提交于 2019-12-06 20:07:28
I have the following problem. I'm working on a Spritekit game at the moment. The game runs completely smooth on a iPhone5. When I want to run the app in the simulator, the compiler tells me: fatal error: malformed or corrupted AST file: 'Unable to load module "/Users/macvideo/Library/Developer/Xcode/DerivedData/ModuleCache/3TAGE798UH20R/Darwin.pcm": module file not found' note: after modifying system headers, please delete the module cache at '/Users/macvideo/Library/Developer/Xcode/DerivedData/ModuleCache/3TAGE798UH20R' But when I want to run it with the 64bit simulator it works, the

Multi-line label in swift 2 sprite-kit?

蹲街弑〆低调 提交于 2019-12-06 18:44:52
问题 I need to be able to make a multi-line label in swift 2 sprite-kit for a game. The text needs to wrap around rather than go off of the screen. Bellow is what I have but I do not know what to do import Foundation import UIKit import SpriteKit class JDQuotes: SKLabelNode { var number = 0 init(num: Int) { super.init() if num == 1 { text = "\"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. laborum.\"" } } required init?

Subclassing SKShapeNode with Swift

北城余情 提交于 2019-12-06 18:24:30
问题 I'm trying to subclass SKShapeNode with Swift. So far I've got something like this: import UIKit import SpriteKit class STGridNode: SKShapeNode { init() { super.init() self.name = "STGridNode" self.fillColor = UIColor(red: 0.11, green: 0.82, blue: 0.69, alpha: 1) } } In my code I want so do something along the lines of: let s = STGridNode(rectOfSize: CGSize(width: 100, height: 100)) So my question is - how do I implement rectOfSize in the initialiser for STGridNode ? I've tried: init

Why won't my SKSpriteNodes appear in the scene?

萝らか妹 提交于 2019-12-06 17:33:32
I am trying to add a couple of nodes to the scene. When I run the app I just have the default gray background. Neither of the nodes appear in the scene. Here is what I have: class GameScene: SKScene { override func didMoveToView(view: SKView) { /* Setup your scene here */ let jumper = SKSpriteNode(imageNamed:"Jumper") jumper.xScale = 0.25 jumper.yScale = 0.25 jumper.position = CGPointMake(50, 300) self.addChild(jumper) let blob = SKSpriteNode(imageNamed:"Blob") blob.position = CGPointMake(160, 30) blob.xScale = 0.5 blob.yScale = 0.25 self.addChild(blob) } I have checked the image titles and

How can I slow down a SKSpriteNode that is running SKAction followPath for a slow motion effect using Sprite Kit?

前提是你 提交于 2019-12-06 17:19:45
问题 I basically want the action to be running and then in the middle of the action create a slow motion effect and then later bring it out of slow motion. Does anyone have any good feedback of how this might be done? I've thought about creating the action manually and using an update method, but I feel like that might be overkill. I was hoping for a simpler solution. The other thought I have is to stop the action and then start it again at a slower duration, but I don't think it will stay on the