skscene

Detecting shakes in sprite kit

感情迁移 提交于 2020-01-06 14:56:30
问题 I have a problem with detecting a shake. It's a skscene in the Sprit Kit and I defined the motion detector like this: - (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event{ } -(void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event { NSLog(@"test?"); } Where is my mistake? Do I have to implement it like I had to do it with the UIGestureRecognizer? Thanks in advance (and sorry for my bad english) Julian 回答1: Apparently, you can't detect shake events from a SKScene

How to switch SKScenes in SpriteKit with Swift properly?

安稳与你 提交于 2020-01-03 17:21:09
问题 I am developing a game with 3 different SKScenes(scene1, scene2, scene3). In GameViewController i initialize all of them like this: class GameViewController: UIViewController { var hero = Hero() var skView: SKView! var scene1: SKScene! var scene2: SKScene! var scene3: SKScene! override func viewDidLoad() { super.viewDidLoad() // init scenes scene1 = SKScene(size: view.bounds.size, hero: hero) scene2 = SKScene(size: view.bounds.size, hero: hero) scene3 = SKScene(size: view.bounds.size, hero:

Why can't I add a SKScene to another SKScene?

℡╲_俬逩灬. 提交于 2020-01-02 07:13:36
问题 I'm trying to make this SKScene appear in the middle of the scene at the end of the game, so that the previous scene is still visible in the background (similar to that of the ending of flappy bird). This is an image of how I want it to appear: So far this is the code I've made: in the game scene: -(void)dieFrom:(SKNode*)killingDebris { _touched = YES; if (_touched == YES) { beatLevel = YES; NSLog(@"touched"); [self runAction:[SKAction sequence:@[ [SKAction runBlock:^{ [_goodSquare

Overlay SKScene is not showing

 ̄綄美尐妖づ 提交于 2020-01-02 05:33:12
问题 I'm trying to overlay an SKScene over a SCNScene. When I run my app on the simulator and an iPhone6+, the overlayScene(SKScene) is shown as intended, but when I tried running it on the iPhone5 (tried 2 different devices) the overlayScene does not appear. Does anyone have an idea why? Both device run on iOS 9.2.1. I have only tested the app on those two models. Here's my code inside the GameViewController.Swift //Configure the view sceneView = self.view as? SCNView //Configure the scene

How to get all actions name on Xcode action editor in sks file “SpriteKit action”

流过昼夜 提交于 2020-01-01 15:38:33
问题 I've a SpriteKit action file with some actions inside. To use one action, I use: let action = SKAction(named: "Shake") Instead is possible to use directly the name inside MyActions.sks file? Something like: let actions = SKScene(fileNamed: "MyActions.sks")` let shakeAction = actions.listOfAction.Shake //this is my guess If I print the scene file: let actions = SKScene(fileNamed: "MyActions.sks") print(actions) the output is: Optional({ "_info" = { "_previewScenePath" = "PippiPompiere

How to get all actions name on Xcode action editor in sks file “SpriteKit action”

独自空忆成欢 提交于 2020-01-01 15:37:14
问题 I've a SpriteKit action file with some actions inside. To use one action, I use: let action = SKAction(named: "Shake") Instead is possible to use directly the name inside MyActions.sks file? Something like: let actions = SKScene(fileNamed: "MyActions.sks")` let shakeAction = actions.listOfAction.Shake //this is my guess If I print the scene file: let actions = SKScene(fileNamed: "MyActions.sks") print(actions) the output is: Optional({ "_info" = { "_previewScenePath" = "PippiPompiere

iPhone 5s SpriteKit drawing oddities

别说谁变了你拦得住时间么 提交于 2019-12-31 04:45:26
问题 I understand that the iPhone 5s has a pixel resolution of 640 x 1136 and a point resolution of 320 x 568 (for backward compatibility with non-Retina devices). The problem/confusion/oddity seems to come in when I'm working with SpriteKit. Example: I'm drawing a line from bottom-left corner (0, 0) to top-right corner (width, height). The result was that the line was drawn almost halfway. And indeed when i print out the screen size, it should 320 x 568. So i decided to draw from (0, 0) to (width

How to reference the current Viewcontroller from a Sprite Kit Scene

纵然是瞬间 提交于 2019-12-30 03:21:25
问题 I'm having a hard time finding the answer to this question I assume is not that hard. How can I reference methods and properties defined on a viewcontroller from a SKScene ? And building on that: How can you reference the ViewController from a SKScene that was loaded from within another SKScene? 回答1: A better option than my "back reference" answer is to use a protocol to explicitly define the methods that a SKScene subclass expects the UIViewController subclass to implement. Here are the

in app purchase in SKScene

此生再无相见时 提交于 2019-12-28 06:13:47
问题 Is it possible to implement an in-app purchase within the SKScene ? If so, how? I'm trying to use a SKSpriteNode as a 'buy' button with no luck. I'm not sure whether the code needs to go in the SKScene or the view controller. I've looked at loads of tutorials, but they all seem to be aimed at single view applications rather than in SpriteKit. 回答1: First, put this in your game scene line and make sure you have the framework 'StoreKit' imported class GameScene: SKScene,

in app purchase in SKScene

ぃ、小莉子 提交于 2019-12-28 06:13:05
问题 Is it possible to implement an in-app purchase within the SKScene ? If so, how? I'm trying to use a SKSpriteNode as a 'buy' button with no luck. I'm not sure whether the code needs to go in the SKScene or the view controller. I've looked at loads of tutorials, but they all seem to be aimed at single view applications rather than in SpriteKit. 回答1: First, put this in your game scene line and make sure you have the framework 'StoreKit' imported class GameScene: SKScene,