skspritenode

How do you move an IOS SKSprite at a consistent speed

隐身守侯 提交于 2019-11-27 15:05:49
问题 Playing around with SKSprites in the IOS SpriteKit, and I basically want to have a sprite randomly move a certain direction for a certain distance, then pick a new random direction and distance.. Simple enough, create a method that generates the random numbers then creates the animation and in the completion block of the animation have it callback the same routine. THis does work, but it also keeps the animation from moving at the same velocity since the animations are all based on duration..

Swift & SpriteKit - How to present alert view in GameScene

蹲街弑〆低调 提交于 2019-11-27 08:24:14
问题 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

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

╄→尐↘猪︶ㄣ 提交于 2019-11-27 01:13:20
问题 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

How do I detect which SKSpriteNode has been touched

青春壹個敷衍的年華 提交于 2019-11-26 23:03:31
I find a similar question , but I am trying to detect and identify which Sprite the user touch, and I don't know how to do that. This is my variable: var sprites: [[SKSpriteNode]] = [[SKSpriteNode(imageNamed: "a"), SKSpriteNode(imageNamed: "b")], [SKSpriteNode(imageNamed: "c"),SKSpriteNode(imageNamed: "d")]] The idea is identify the spriteNode and then replace it for other sprite or change the color, but I don´t know how to do it with this matrix of spriteNodes, I guess the first step it´s identify the sprite. What you are trying to do (even if I don't see a reason for this) can be

How do I detect if an SKSpriteNode has been touched

烂漫一生 提交于 2019-11-26 17:29:35
I am trying to detect if my sprite node has been touched and I have no idea where to start. let Pineapple = SKSpriteNode(imageNamed: "Pineappleimg") Pineapple.userInteractionEnabled = true Pineapple.position = CGPoint(x: CGRectGetMidX(self.frame) - 200, y: CGRectGetMidY(self.frame)); self.addChild(Pineapple) rakeshbs First set the name property of the SKSpriteNode to a string. pineapple.name = "pineapple" pineapple.userInteractionEnabled = false then in touchesBegan function in the Scene override func touchesBegan(touches: NSSet, withEvent event: UIEvent) { let touch:UITouch = touches

How do I detect which SKSpriteNode has been touched

那年仲夏 提交于 2019-11-26 08:30:47
问题 I find a similar question, but I am trying to detect and identify which Sprite the user touch, and I don\'t know how to do that. This is my variable: var sprites: [[SKSpriteNode]] = [[SKSpriteNode(imageNamed: \"a\"), SKSpriteNode(imageNamed: \"b\")], [SKSpriteNode(imageNamed: \"c\"),SKSpriteNode(imageNamed: \"d\")]] The idea is identify the spriteNode and then replace it for other sprite or change the color, but I don´t know how to do it with this matrix of spriteNodes, I guess the first step

How do I detect if an SKSpriteNode has been touched

六月ゝ 毕业季﹏ 提交于 2019-11-26 05:26:51
问题 I am trying to detect if my sprite node has been touched and I have no idea where to start. let Pineapple = SKSpriteNode(imageNamed: \"Pineappleimg\") Pineapple.userInteractionEnabled = true Pineapple.position = CGPoint(x: CGRectGetMidX(self.frame) - 200, y: CGRectGetMidY(self.frame)); self.addChild(Pineapple) 回答1: First set the name property of the SKSpriteNode to a string. pineapple.name = "pineapple" pineapple.userInteractionEnabled = false then in touchesBegan function in the Scene