sprite-kit

create SKScene subclasses programmatically, without size info?

落花浮王杯 提交于 2020-06-22 12:05:22
问题 I'm trying to learn how to make a GameManager type class, and making individual classes for each of my GameScenes... probably the wrong thing to do, but for the sake of this question, please accept this as the way to do things. My GameManager looks like this, having a reference to each of the scenes, that's static: import SpriteKit class GM { static let scene2 = SecondScene() static let scene3 = ThirdScene() static let home = SKScene(fileNamed: "GameScene") } How do I create a SKScene

SpriteKit - Sequencing multiple SKActions running on multiple SKNodes

天大地大妈咪最大 提交于 2020-05-31 04:44:47
问题 I understand quite well the SKAction API but I cannot achieve to have good code when running sequential code on multiple nodes. Here is a sample code (simplified) : import SpriteKit class GameScene: SKScene { weak var node1: SKNode! weak var node2: SKNode! override func didMove(to view: SKView) { super.didMove(to: view) cacheUI() runSampleSequence() } private func cacheUI() { // Fetch nodes from associated SKS file node1 = self.childNode(withName: "node1")! node2 = self.childNode(withName:

Issues with SKScene on iPad simulator not filling screen in Xcode 11 beta 7

大兔子大兔子 提交于 2020-05-30 07:05:44
问题 In Xcode 11 beta 7, I am having issues with my SKScene , my GameScene does not fill the entire screen of the iPad simulator. This is true for all iPad simulators. On my physical iPad the Game Scene is as intended, but I worry this may not be true of all iPad's. On all iPhone simulators and on my iPhone, the Game Scene is also displayed as intended. I have two SKScenes , one is the Main Menu screen which fills the entire screen, but my Game Scene does not, when I load the Game Scene it is

Plot nodes along a UIBezierPath in spritekit

安稳与你 提交于 2020-05-30 06:55:48
问题 i'm currently developing a game in spritekit which has a game level map. I'm using an UIBezierPath for the pathway i want the level nodes to follow, the only problem I have is trying to plot them along the path and was wondering how I go about adding them to the scene so they get added to the path way and each one is individually spaced 50 apart from the last one that was plotted before it. currently I have this: My Code let path = UIBezierPath() path.move(to: CGPoint(x: -200, y: 0)) path

Plot nodes along a UIBezierPath in spritekit

北慕城南 提交于 2020-05-30 06:55:30
问题 i'm currently developing a game in spritekit which has a game level map. I'm using an UIBezierPath for the pathway i want the level nodes to follow, the only problem I have is trying to plot them along the path and was wondering how I go about adding them to the scene so they get added to the path way and each one is individually spaced 50 apart from the last one that was plotted before it. currently I have this: My Code let path = UIBezierPath() path.move(to: CGPoint(x: -200, y: 0)) path

Drawing dashed line in Sprite Kit using SKShapeNode

萝らか妹 提交于 2020-05-27 05:02:31
问题 I fount this solution but I can't make it into swift code This what I try var pattern[2]:CGFloat; this var dashed: CGPathRef = CGPathCreateCopyByDashingPath(CGPathCreateCopyByDashingPath(path, transform, phase, lengths, count); var myShapeNode: SKShapeNode!; var CGPathCreateCopyByDashingPath:CGPathRef; 回答1: This is how you can draw a dashed line in swift. You can change the parameters as you want. let bezierPath = UIBezierPath() let startPoint = CGPointMake(0, 250) let endPoint = CGPointMake

PhysicsBody: Could not create physics body

混江龙づ霸主 提交于 2020-05-24 05:31:28
问题 I have an entire working game that has been up on the App Store, but since iOS 13 it simply does not work. I've installed the game onto my device via Xcode and I'm getting a lot of errors coming up saying: PhysicsBody: Could not create physics body. I've been creating my SKSpriteNodes like this: let bird = SKSpriteNode(texture: SKTextureAtlas(named:"player").textureNamed("bird0001")) bird.physicsBody = SKPhysicsBody(texture: bird.texture!, size: bird.size) Based on some research, this is

How to create travelling wave in SpriteKit

丶灬走出姿态 提交于 2020-05-16 04:09:19
问题 How can I create a visual effect of traveling wave like this in Swift SpriteKit? I am using an extension to the SKAction that performs the oscillatory movement in the node, but I still do not know how to create the trail. I though in creating copies but it did not worked. extension SKAction { static func oscillation(scene: SKScene, amplitude a: CGFloat, timePeriod t: CGFloat, midPoint: CGPoint) -> SKAction { let action = SKAction.customAction(withDuration: Double(t)) { node, currentTime in

Add dynamically SKLabelNode to MKTVIew

岁酱吖の 提交于 2020-04-30 07:13:29
问题 I am working on metal view that shows the heart rate graph. between every peak of this graph, I need to add a label. In this process, chart moving from right to left I have an array that dynamically shows the x coordinate of this label for example when one value should show in the screen, this array contain only element and if there are more, it contain more element, this array is named coordinates I use a for loop to get every element for coordinate in coordinates { } I also have another

UImage loads entire SKTextureAtlas instead of just SKTexture

こ雲淡風輕ζ 提交于 2020-04-18 12:50:08
问题 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