sknode

SpriteKit: find all descendants of SKNode of certain class?

房东的猫 提交于 2020-12-08 08:09:55
问题 This question shows how to find all children of a SKNode that belong to a certain class, but what if we want all descendants (e.g., grandchildren) that belong to a certain class? Is there a native way to do this in SpriteKit, or is the only option to create a recursive form of the solution from the aforementioned question? The SKNode documentation highlights a search function that lets you find descendants with a certain name, but is there a way to filter descendants by class and not be name?

SpriteKit: find all descendants of SKNode of certain class?

瘦欲@ 提交于 2020-12-08 08:09:06
问题 This question shows how to find all children of a SKNode that belong to a certain class, but what if we want all descendants (e.g., grandchildren) that belong to a certain class? Is there a native way to do this in SpriteKit, or is the only option to create a recursive form of the solution from the aforementioned question? The SKNode documentation highlights a search function that lets you find descendants with a certain name, but is there a way to filter descendants by class and not be name?

SpriteKit: find all descendants of SKNode of certain class?

懵懂的女人 提交于 2020-12-08 08:06:15
问题 This question shows how to find all children of a SKNode that belong to a certain class, but what if we want all descendants (e.g., grandchildren) that belong to a certain class? Is there a native way to do this in SpriteKit, or is the only option to create a recursive form of the solution from the aforementioned question? The SKNode documentation highlights a search function that lets you find descendants with a certain name, but is there a way to filter descendants by class and not be name?

SpriteKit: find all descendants of SKNode of certain class?

瘦欲@ 提交于 2020-12-08 08:05:48
问题 This question shows how to find all children of a SKNode that belong to a certain class, but what if we want all descendants (e.g., grandchildren) that belong to a certain class? Is there a native way to do this in SpriteKit, or is the only option to create a recursive form of the solution from the aforementioned question? The SKNode documentation highlights a search function that lets you find descendants with a certain name, but is there a way to filter descendants by class and not be name?

SpriteKit: find all descendants of SKNode of certain class?

被刻印的时光 ゝ 提交于 2020-12-08 08:05:08
问题 This question shows how to find all children of a SKNode that belong to a certain class, but what if we want all descendants (e.g., grandchildren) that belong to a certain class? Is there a native way to do this in SpriteKit, or is the only option to create a recursive form of the solution from the aforementioned question? The SKNode documentation highlights a search function that lets you find descendants with a certain name, but is there a way to filter descendants by class and not be name?

How do I size sprites in a universal sprite kit game

泪湿孤枕 提交于 2020-01-14 05:16:08
问题 I'm relatively new to swift programming. I have made an app where I didn't use SpriteKit and I would size most views by scaling down the images to a multiple of the screens width and height. Not sure if this is the best tactic, but it worked and I was able to build an app that looked good on all devices. With spritekit and the scene.sks files, I don't have the option of auto-layouts to size my sprites like I did before. There isn't a lot of content about universal apps online, so I'm

Adding, Removing, and Caching SKNodes

岁酱吖の 提交于 2020-01-05 04:42:12
问题 Background info: I'm creating a SpriteKit 2D platform-style game with multiple "floors". When the user enters a "portal" he is transported to another floor (either one up or one down). If the user dies at a different floor from where the most recent spawnpoint is, he is transported back to the floor with the spawnpoint. Problem: After upgrading to iOS8, this scenario causes the game to crash with an EXC_BAD_ACCESS exception/ error. Even after going through multiple tutorials on how to debug

ObjectIdentifier needed for Swift equality?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-31 04:00:13
问题 We have multiple instances of a custom Swift class, which inherits from SKSpriteNode, and were able to execute the following code (grossly simplified for this question) correctly: let instance1 = CustomClass() let instance2 = CustomClass() let instance3 = CustomClass() let instance4 = CustomClass() let array1 = [instance1, instance2] let array2 = [instance3, instance4] func check(testInstance: CustomClass) -> Bool { return array1.filter({ $0 == testInstance }).count > 0 } check(testInstance:

Swift + SpriteKit - Button is clickable even when not visible [duplicate]

余生颓废 提交于 2019-12-24 14:45:52
问题 This question already has answers here : SKLabelNode will disappear but is still clickable (2 answers) Closed 3 years ago . I seem to be having problems with one of the Nodes on my scene. I have a button: func createAttackButton() { attackButton.zPosition = 1 attackButton.anchorPoint = CGPointZero attackButton.position = CGPointMake(20, 20) attackButton.size = CGSize(width: 150, height: 40) addChild(attackButton) } This function is called when contact is made with the enemy. To run a function

Is the order of SKNode.nodesAtPoint guaranteed?

旧时模样 提交于 2019-12-24 05:04:30
问题 SKNode has a method nodesAtPoint which returns an array of children nodes that intersect given point. Is the order of the elements in such array deterministic (e.g. by drawing order)? I could not find an answer in documentation, so probably the answer is "no", but I would like to verify. 回答1: Nope, Sprite Kit does not take into account z-position when traversing the node-tree (definitely for performance reasons). You can easily see this by adding a few nodes to a scene in-order and then