sprite-kit

UImage loads entire SKTextureAtlas instead of just SKTexture

丶灬走出姿态 提交于 2020-04-18 12:49:49
问题 I need texture with 'trueName' to load into my myImageViewOutlet.image. The result I am getting is the entire atlas rendering into it. My code is as follows let myTextureAtlas = SKTextureAtlas.init(named: "myGameTextures") // let texture = myTextureAtlas.textureNamed(trueName) // will render the entire atlas, instead of just the texture by trueName let texture = myTextureAtlas.textureNamed(trueName+”bad name“) // will produce the placeholder image by sprite kit by itself just fine, but it's

SKScene not loaded when add GKComponent to GameScene.sks

我的梦境 提交于 2020-04-17 22:12:03
问题 I am currently creating a 2D game with Swift SpriteKit and GameplayKit. I have a GameScene.sks file and a GameScene.swift file that is of type SKScene. Now I wanted to add a Component of type GKComponent. I created my component and added it to one of my SKSpriteNodes in GameScene.sks However after adding the Component to the SpriteNode in the Scene Editors Inspector the Scene is no longer loaded and the app shows only a grey screen. Is this a known issue in XCode? Is there a way of bypassing

SpriteKit/Metal memory leak with nothing happening

夙愿已清 提交于 2020-03-21 20:29:35
问题 I have a memory leak that I can't seem to trace. Instruments sees it, and reports it as jet_buffer_Metal, but I don't know what that is pointing me to specifically. It happens regularly. I have tried everything. Removing all my nodes, removing physicsBodies, but it still seems to be there. I don't have anything in Update or any other of the game cycle methods. I can post all that code there, but really I only add two nodes, that can only move on touch. I don't touch the screen, and the memory

Spritekit layout lags when device orientation changes

让人想犯罪 __ 提交于 2020-03-06 09:19:13
问题 Ok, this might be a bit hard to explain since I can't include any video to show you what I mean, but I'll give it a shot. I have added a SKShapeNode to a scene and when I rotate the device orientation it follows along nicely as expected, positioning itself in the upper left side of the screen whichever way the device is rotated. But the SKShapeNode "lags" behind, that is, when I rotate to a new orientation, the node remain in the same position for half a second before it is relocated to the

how to set physics properties for a circle so it follows given path

拥有回忆 提交于 2020-02-23 09:31:07
问题 The movement of a physics body circle is too erratic for what I want to achieve. I would like to restrict it so it follows a certain path touching specific points (or a range of points) as shown in the image below. How can I set the physics properties to traverse a similar path? 回答1: how to set physics properties for a circle so it follows given path So essentially you are looking to move a node to a particular point using real-time motion. I have an answer here showing how to do this,

Calculating delta in SpriteKit using Swift

被刻印的时光 ゝ 提交于 2020-02-22 06:08:26
问题 I am attempting to learn swift by refactoring one of my old games and I need to rewrite my update method which calculates a delta time. This code works but is ugly. How would I go about properly rewriting this? import SpriteKit class GameScene: SKScene { var lastUpdateTimeInterval: CFTimeInterval? override func update(currentTime: CFTimeInterval) { var delta: CFTimeInterval? if let luti = lastUpdateTimeInterval { delta = currentTime - luti } else { delta = currentTime } lastUpdateTimeInterval

Calculating delta in SpriteKit using Swift

瘦欲@ 提交于 2020-02-22 06:04:43
问题 I am attempting to learn swift by refactoring one of my old games and I need to rewrite my update method which calculates a delta time. This code works but is ugly. How would I go about properly rewriting this? import SpriteKit class GameScene: SKScene { var lastUpdateTimeInterval: CFTimeInterval? override func update(currentTime: CFTimeInterval) { var delta: CFTimeInterval? if let luti = lastUpdateTimeInterval { delta = currentTime - luti } else { delta = currentTime } lastUpdateTimeInterval

Calculating delta in SpriteKit using Swift

﹥>﹥吖頭↗ 提交于 2020-02-22 06:04:18
问题 I am attempting to learn swift by refactoring one of my old games and I need to rewrite my update method which calculates a delta time. This code works but is ugly. How would I go about properly rewriting this? import SpriteKit class GameScene: SKScene { var lastUpdateTimeInterval: CFTimeInterval? override func update(currentTime: CFTimeInterval) { var delta: CFTimeInterval? if let luti = lastUpdateTimeInterval { delta = currentTime - luti } else { delta = currentTime } lastUpdateTimeInterval

Is it possible to turn on field debug drawing for SpriteKit in Xcode?

醉酒当歌 提交于 2020-02-15 20:20:50
问题 Is it possible to turn on field dubug drawing for SpriteKit in Xcode? I mean something like a picture below (it is from WWDC2014, session 608). 回答1: Add the following to your view controller Swift: skView.showsFields = true ObjC: skView.showsFields = YES; 来源: https://stackoverflow.com/questions/33712852/is-it-possible-to-turn-on-field-debug-drawing-for-spritekit-in-xcode

Is it possible to turn on field debug drawing for SpriteKit in Xcode?

南楼画角 提交于 2020-02-15 20:19:06
问题 Is it possible to turn on field dubug drawing for SpriteKit in Xcode? I mean something like a picture below (it is from WWDC2014, session 608). 回答1: Add the following to your view controller Swift: skView.showsFields = true ObjC: skView.showsFields = YES; 来源: https://stackoverflow.com/questions/33712852/is-it-possible-to-turn-on-field-debug-drawing-for-spritekit-in-xcode