sprite-kit

What is the difference between didMove(to view: SKView) and didMoveToView(view: SKView)?

落花浮王杯 提交于 2019-12-13 16:34:09
问题 As in the title, what is the difference between didMove(to view: SKView) and didMoveToView(view: SKView)? I understand that didMoveToView is the method and that view is of type SKView in the older(?) version. I don't understand the deal with 'to view: SKView' being passed to the didMove method. Are 'to' and 'view' separate variables? Is 'to' part of 'didMove'? What is going on? EDIT: I understand that they both accomplish the same thing - but why is 'to' in the area that parameters normally

In swift, is it possible to create an SKSpriteNode by directly copying it from an array?

℡╲_俬逩灬. 提交于 2019-12-13 15:22:43
问题 I'm having a little bit of trouble with one of my projects in Swift at the moment. I want to know if you can create a brand new sprite node like this: var spriteNode : SKSpriteNode = nodes(3) where nodes is an array of SKSpriteNodes and has an object at index number 3. Previously, I have worked in Java, and I know that if you were to do something like this, it would simply pass a reference the sprite node variable rather than creating a whole new sprite node, but I am not sure if this is what

How can I create a .swift file for my new .sks file?

依然范特西╮ 提交于 2019-12-13 12:50:58
问题 When using Xcode, I've faced the annoying problem, which is Xcode always crashes when I click .SKS files. I have raised questions here, and even in Apple developer forum, as well as searched for the solutions on the Internet... but it is hopeless. Because I am making a game with many scenes, so if I can't use SpriteKit editor to interact with the scenes in an easy way, I want to know how can I interact with my scenes by coding their .swift files. So the question is, for example, when I create

Using custom SKNodes in spritekit scene editor

▼魔方 西西 提交于 2019-12-13 12:06:39
问题 I want to create a level using my custom subclasses of SKNode. I tried adding an SKNode to the scene editor and using the "Custom Class" tab give the class that I want it to be but that did absolutely nothing. The node would still be empty and nothing would show when I run the simulator. Also, to make sure that the class actually works, I added an instance of it to the scene programmatically to see if it shows and it does. How do I add my custom nodes to the scene through the scene editor?

What would be the best approach for outlining or dropshadowing a font?

喜你入骨 提交于 2019-12-13 11:33:13
问题 I'm not finding any support for dropshadow or outline of a font in Sprite Kit. For the dropshadow, I'm guessing I could create a second SKLabelNode and offset it behind the other. Is there some way that I could utilize a SKEffectNode for the outline or dropshadow ? Possibly make the SKLabelNode a child of the SKEffectNode ? update : I was able to get a decent dropshadow using a second SKLabelNode behind the first, that is black and offset. Still interested in other potential options, but that

How can I reset the timer after a certain duration?

空扰寡人 提交于 2019-12-13 10:40:58
问题 I have set a timer in my code below. How can I make the timer reset every time it reaches a given duration say, 7 seconds? class SpriteGroup { var sprites : [Sprite] var isVisible : Bool var startTime: TimeInterval = 0.0 var currentTime: TimeInterval = 0.0 init(sprites : [Sprite], isVisible: Bool, pos: CGPoint) { self.sprites = sprites ... startTime = Date.timeIntervalSinceReferenceDate Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(self.advanceTimer(timer:)),

how can i make a pop up menu in sprite kit swift? [closed]

纵饮孤独 提交于 2019-12-13 10:13:06
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 4 years ago . I'm trying to make a pop up menu for a game, what's the best way to make it? it looks like this: 回答1: I'll give you a high level explanation Just create a new sknode or skspritenode with zPosition of 50 or something so its above everything else, and have child nodes in it for

IOS SpriteKit Colision Detection: Resetting Position of NSMutable array of Objects

醉酒当歌 提交于 2019-12-13 10:03:12
问题 I'm attempting to make a game with objects that bounce between the left and right walls of the screen until they reach the bottom. Currently, my working didBeginContact method looks like this: - (void)didBeginContact:(SKPhysicsContact *)contact { uint32_t collision = (contact.bodyA.categoryBitMask | contact.bodyB.categoryBitMask); if (collision == (crabCategory | leftWallCategory)) { // figure out which crab in the array made the contact... for(HHCrab *object in crabs) { if(([object.name

How do I add and animate infinite number of objects coming from the bottom of the screen in random order in gradually increasing speeds?

牧云@^-^@ 提交于 2019-12-13 09:55:35
问题 I have 3 different sprites. I want to continuously animate these three different sprites entering from the bottom of the screen, going up increasing velocities as the number of objects coming in increases. Also, the three should come in random order. So, I tried the following code to get any of the three sprites to come in any random order but it didn't work as expected: int randomNumber; for (int i = 1; i<500; i++) { randomNumber = arc4random_uniform(3); NSLog(@"Value of random Number %d"

How to animate background of a Sprite-Kit game just like the login screen of Instagram iOS app?

北城以北 提交于 2019-12-13 09:47:58
问题 I am creating a game in Sprite-Kit and would want to animate the background in the similar fashion as Instagram does on its login screen. Basically, I just want to know how to have a background in my game just like the Instagram app has on its login screen, i.e the pink colored screen which gradually changes to violet color and then to red with a very subtle flowing effect from right to left. I know how to animate the gradient but that subtle effect that I'm talking about which gives quite a