skspritenode

How to rotate an SKSpriteNode around the node's Y-axis?

限于喜欢 提交于 2019-11-30 03:56:00
I'm trying to rotate an SKSpriteNode node around it's Y-axis. I know there's the zRotation property and that will rotate the node clockwise or counter-clockwise; however, I'd like to rotate the node around it's own Y axis (like a dancing ballerina for instance), and I can't seem to find any functionality to do so. What is the best recommended way of doing this? Typically if I am wanting to rotate something like you seem to be describing, and want it to look good, I will do it via sprite frames depicting different degrees of rotation. You can indeed fake it a little by tweening your xScale

How to cut random holes in SKSpriteNodes

穿精又带淫゛_ 提交于 2019-11-30 01:15:05
问题 Aside from the fact that the question asked here : Draw a hole in a rectangle with SpriteKit? has not satisfactorily been answered in its own right, the most significant difference between the two is that this question requires an absence of workarounds and specifically asks about reversing the functionality of SKCropNodes. The primary concerns in this question cannot be addressed by the type of hacky ways the above question could be answered due to the randomness of the holes, the number of

Spawning a Spritekit node at a random time

帅比萌擦擦* 提交于 2019-11-29 15:31:12
问题 I'm making a game where I have a node that is spawning and falling from the top of the screen. However I want to make the nodes spawn at random time intervals between a period of 3 seconds. So one spawns in 1 second, the next in 2.4 seconds, the next in 1.7 seconds, and so forth forever. I am struggling with what the code should be for this. Code I currently have for spawning node: let wait = SKAction.waitForDuration(3, withRange: 2) let spawn = SKAction.runBlock { addTears() } let sequence =

SKLightNode cast shadow issue

…衆ロ難τιáo~ 提交于 2019-11-29 07:08:33
I have been unsuccessful in getting a SKSpriteNode to cast a shadow AND also be made to disappear when going into a shadow from the same light source. I am able to do one of the two but not both. According to the docs: If the sprite is inside a shadow cast by a light and the sprite has a lower z position than the light, the shadow affects how the sprite is lit. All of which I have done. My SKLightNode has a zPosition of 100 and all other nodes have lower zPositions. I have tried any and all combinations of settings for lightingBitMask, shadowCastBitMask and shadowedBitMask but nothing has

Subclassing SKNodes created with SpriteKit .sks scene file

↘锁芯ラ 提交于 2019-11-29 06:02:05
(this is for XCode 6 and iOS 8 beta 4) Love the new SceneKit editor. I'm successfully loading the scene from .sks file into a custom SKScene class. However, objects inside it are instantiated as default classes (SKNode, SKSpriteNode, etc), and i'm not sure how to bind them to be instantiated as custom subclasses instead. Currently, I'm getting around that by creating custom classes and linking to sprite nodes as a property, and that works ok I wrote a little helper delegate to deal with this: https://github.com/ice3-software/node-archive-delegate . It uses the NSKeyedUnarchiverDelegate to

Rotate an object in its direction of motion

谁说胖子不能爱 提交于 2019-11-29 05:21:10
Is there a relatively simple way to rotate SKSpriteNode so that it is always facing the direction it is moving? My class Gamescene has a system of objects with their relative physicsbodies that apply impulses on each other when they collide. This makes it relatively difficult to keep track of exactly what direction an object is moving in. Some of the objects are also not regularly shaped, which makes things a bit more chaotic. I have tried using trigonometry (e.g. arctangent), but it only works as intended in very special circumstances. Might there be a way to find out the angle of an

How to rotate an SKSpriteNode around the node's Y-axis?

北慕城南 提交于 2019-11-29 01:33:15
问题 I'm trying to rotate an SKSpriteNode node around it's Y-axis. I know there's the zRotation property and that will rotate the node clockwise or counter-clockwise; however, I'd like to rotate the node around it's own Y axis (like a dancing ballerina for instance), and I can't seem to find any functionality to do so. What is the best recommended way of doing this? 回答1: Typically if I am wanting to rotate something like you seem to be describing, and want it to look good, I will do it via sprite

Swift & SpriteKit - How to present alert view in GameScene

随声附和 提交于 2019-11-28 14:17:09
I need help presenting an alert view in the game scene. Im currently struggling to do so as GameScene.Swift isnt a standard ViewController. If it helps I need to do so as I need the user to input a value which is used as a coordinate for the ball Sprite Kit Node in my game. The input is only a standard integer so that isnt an issue. Any other idea of how I can do this which isnt through an alert view is also welcome. override func viewWillLayoutSubviews() { super.viewWillLayoutSubviews() let view = self.view as! SKView if view.scene == nil { view.showsFPS = false view.showsNodeCount = false

Swift - Must call a designated initializer of the superclass SKSpriteNode error

江枫思渺然 提交于 2019-11-28 06:09:15
This code worked on first XCode 6 Beta, but on latest Beta it's not working and gives such errors Must call a designated initializer of the superclass SKSpriteNode : import SpriteKit class Creature: SKSpriteNode { var isAlive:Bool = false { didSet { self.hidden = !isAlive } } var livingNeighbours:Int = 0 init() { // throws: must call a designated initializer of the superclass SKSpriteNode super.init(imageNamed:"bubble") self.hidden = true } init(texture: SKTexture!) { // throws: must call a designated initializer of the superclass SKSpriteNode super.init(texture: texture) } init(texture:

SKLightNode cast shadow issue

谁说胖子不能爱 提交于 2019-11-28 00:36:17
问题 I have been unsuccessful in getting a SKSpriteNode to cast a shadow AND also be made to disappear when going into a shadow from the same light source. I am able to do one of the two but not both. According to the docs: If the sprite is inside a shadow cast by a light and the sprite has a lower z position than the light, the shadow affects how the sprite is lit. All of which I have done. My SKLightNode has a zPosition of 100 and all other nodes have lower zPositions. I have tried any and all