sprite-kit

swift - Increase speed of objects over time

我们两清 提交于 2019-12-13 05:56:40
问题 I'm looking for a way to increase the pace of my game the longer you play it, I would like to achieve this by increasing the frequency of obstacles generated either after a certain time i.e. every 30 seconds or preferably after 10 objects (trees), have been generated so the longer you play the harder it gets. This is my current set up, I use repeatActionForever how could I change this to something like repeatAction10Times with a different delay variable for each loop? //in didMoveToView

Unarchiving .sks file in Swift for iOS 7.1

丶灬走出姿态 提交于 2019-12-13 05:50:50
问题 I have an app which loads nicely from an .sks file in iOS 8 using the following extension: class func unarchiveFromFile(file : NSString) -> SKNode? { if let path = NSBundle.mainBundle().pathForResource(file as String, ofType: "sks") { var sceneData = NSData(contentsOfFile: path, options: .DataReadingMappedIfSafe, error: nil)! var archiver = NSKeyedUnarchiver(forReadingWithData: sceneData) archiver.setClass(self.classForKeyedUnarchiver(), forClassName: "SKScene") let scene = archiver

SpriteKit: EXC_BAD_ACCESS SpriteKit`SKCShapeSprite::getAccumulatedBounds() crash

不问归期 提交于 2019-12-13 05:04:50
问题 After upgrading to iOS8, SpriteKit game crashes with EXC_BAD_ACCESS. It happens for no apparent reason, after playing a bit, at random time. No info from Exception breakpoint and NSZombie detection, so no way to detect the line in the code that causes the error. Checked both on a simulator and a device. The backtrace: * thread #1: tid = 0x13fa2, 0x2b3977f0 SpriteKit`SKCShapeSprite::getAccumulatedBounds() const + 84, queue = 'com.apple.spritekit.renderQueue', stop reason = EXC_BAD_ACCESS (code

Sprite Kit art assets naming convention

不打扰是莪最后的温柔 提交于 2019-12-13 04:57:46
问题 Making my 1st Sprite Kit game & almost finished it. Just getting my images finalized. Problem is, with the addition of iPhone 6 & 6 Plus, I am having issues figuring out how to name my game assets. For instance, one of my several background images is called "1MBack.png". Sometimes people write "Default–568h@2x.png" and I try to figure out if I need the "Default–568h" part in my game asset names. The naming convention I used for my art is as following: << 1x (iPhone 2G, 3G, 3GS) = 1MBack.png >

Instantiate a *game scene* view Swift

戏子无情 提交于 2019-12-13 04:52:32
问题 So, I am trying to instantiate a view controller. The issue is, that the view that I am trying to instantiate is a gameScene view controller (Sprite Kit). Also, the view that I am instituting from is also a gameScene view. If I were instantiating from a normal UIViewController, I would do this: let vc : AnyObject! = self.storyboard!.instantiateViewControllerWithIdentifier("main") self.showViewController(vc as! UIViewController, sender: vc) //the view that I am instantiating's class name is

SKSpriteNode does not have member named ''- how to access a variable declared in my spawn method?

喜夏-厌秋 提交于 2019-12-13 04:52:06
问题 I asked another question before about how to access a global variable in Swift, but realized the global variable did not work for my purposes. Some background: The game is a math/match game. Player's will have an equation, and they have to get the sheep with the matching answer. I have sheep that spawn on screen. Each sheep holds a unique int value (1-12) that is generated within my spawnSheep method: var sheepValue: Int = Int(arc4random_uniform(UInt32(12))+1) Multiple sheep will spawn on

Swift multiple node access

拜拜、爱过 提交于 2019-12-13 04:50:01
问题 Let's say we add the same node around 1000 times like shown in the code below. Is there any way to have access of every single platform? For e.g., if there is a collision between the PlatformCategory and the PlayerCategory , the Platform that had the collision should change its color to green and run a SKAction . Edit: Thanks to Whirlwind, I can get the platform that collides with the player change to green, while all other stay red. Now I need to set the collision properly, which means I

I want to make a soccer ball by IOS SpriteKit

淺唱寂寞╮ 提交于 2019-12-13 04:49:58
问题 I want to make a soccer ball by IOS SpriteKit I was able to create a ball in the code such as the following. However, it does not bounce at all. To make rebound rate, How can I do this? (UITouch *touch in touches) { SKSpriteNode *sprite = [SKSpriteNode spriteNodeWithImageNamed:@"Ball"]; sprite.position = location; const CGFloat radius = 20.0f; SKPhysicsBody *pbody = [SKPhysicsBody bodyWithCircleOfRadius:radius]; sprite.physicsBody = pbody; sprite.size = (CGSize){radius * 2, radius * 2};

Sprite kit, how can i randomly call a method?

百般思念 提交于 2019-12-13 04:49:01
问题 I am programming my game at the moment in sprite kit, I have 8 differnt methods and i have it set up to call a 1 method every 5 seconds, but instead of just being able to call 1 method i want it to randomly select 1 of the 8 methods and call that. Here is my current code: - (void)updateWithTimeSinceLastUpdate:(CFTimeInterval)timeSinceLast { self.lastSpawnTimeInterval += timeSinceLast; if (self.lastSpawnTimeInterval > 5) { self.lastSpawnTimeInterval = 0; [self shootPizza]; } } - (void)update:

Sprites must be cleaned before switch scenes with SpriteKit and Swift?

不想你离开。 提交于 2019-12-13 04:43:35
问题 There are two scenes(scene1, scene2) in my game, both of them have some sprites. scene1 will be presented at first with skView. scene2 will be presented with the same skView when the hero is stronger. In case the hero is weak, scene1 will be presented again. (Here is the question point.) In my case the sprites which were added to the scene1, are added to the scene1 again (I mean they are doubled). I did another test, where i presented the scene1 just twice one after the other. I got the same