skscene

How to set view of programatically created view controller to SKView?

谁说胖子不能爱 提交于 2019-12-11 03:09:32
问题 I am developing a game and would like to have one sprite-kit scene have its own view controller (a conclusion I've reached after much debate), and would like to avoid using storyboard (I can accomplish what I want with storyboard, but would like to learn how to do it without storyboard). In my main view controller, after clicking a button, I have the following code MyViewController2 *test = [[MyViewController2 alloc] init]; test.view = [[SKView alloc] init]; [self presentViewController: test

GPUImageView inside SKScene as SKNode material - Playing transparent video on ARKit

a 夏天 提交于 2019-12-11 01:58:15
问题 In Project -A- I used GPUImageView to display Video (recorded on greenscreen) with transparency. Using the GPUImageChromaKeyBlendFilter, and so on. and works Superb. Another project -B- based on ARKIT shows me in the space a plain with VIDEO and it also works fine using SKVideoNode and AVPlayer. Now the question is to combine it all together in one :) So in space I want to display Video but with transparency ... Unfortunately, I can not render a GPUImageView on any SpriteKit element, and then

How to create more SKScene in addition to GameScene

不打扰是莪最后的温柔 提交于 2019-12-10 11:59:35
问题 I tried to create a new subclass of SKScene "MainScene" like the one apple created the GameScene. I want to create more scene in addition to my "GameScene" but its not working. Below is my subclass code. MainScene : import SpriteKit #if !os(iOS) import AppKit #endif class MainScene : SKScene { override func didMoveToView(view: SKView) { backgroundColor = UIColor.blueColor() } } MainSceneViewController : import UIKit import SpriteKit class MainViewController: UIViewController { override func

What is the method unarchiveFromFile in GameViewController for?

半城伤御伤魂 提交于 2019-12-10 09:29:53
问题 When I tried to add different scenes to my game in Swift, I encountered the method unarchiveFromFile. The problem with this method is that it only works with the GameScene class. If you call it from extension SKNode { class func unarchiveFromFile(file : NSString) -> SKNode? { if let path = NSBundle.mainBundle().pathForResource(file, ofType: "sks") { var sceneData = NSData.dataWithContentsOfFile(path, options: .DataReadingMappedIfSafe, error: nil) var archiver = NSKeyedUnarchiver

Swift 3 (SpriteKit): Reseting GameScene doesn't deallocate

谁都会走 提交于 2019-12-10 00:16:27
问题 I have been trying to reset the GameScene by creating a new duplicate of the GameScene, which works. However, the problem is that the scene doesn't deallocate, which is definitely an issue since I profiled my app with Allocations and saw that the memory was 'clogging' and 'piling' up. This is my code for my GameViewController and my GameScene: import UIKit import SpriteKit import GameplayKit var screenSize = CGSize() class GameViewController: UIViewController { override func viewDidLoad() {

Using SpriteKit inside SwiftUI

你说的曾经没有我的故事 提交于 2019-12-09 17:58:58
问题 I am having an issue when creating a SpriteKit scene within SwiftUI . I created this project initially as a SwiftUI project. Here is the code I have so far: ContentView.swift: /// Where the UI content from SwiftUI originates from. struct ContentView : View { var body: some View { // Scene SceneView().edgesIgnoringSafeArea(.all) } } SceneView.swift: /// Creates an SKView to contain the GameScene. This conforms to UIViewRepresentable, and so can be used within SwiftUI. final class SceneView :

Difference between paused property of SKScene and SKView

ぃ、小莉子 提交于 2019-12-09 05:23:01
问题 I am pausing my SKScene using the following code: self.paused = YES; However, according to this answer by Andrey Gordeev, one can also pause a scene using this line: self.view.paused = YES; I would like to understand what difference it would make to call the either (or both) to pause a scene. 回答1: Pausing SKView stops calling update: method for SKScene . Pausing SKScene doesn't do that. I usually pause both SKScene and SKView EDIT: As of iOS9 pausing the scene will pause the update: method.

Turn off touch for whole screen, SpriteKit, how?

故事扮演 提交于 2019-12-08 13:09:10
问题 I'm trying to temporarily disable touch on the entire screen, despite their being many sprites with touchesBegun onscreen. I thought, obviously wrongly, turning off touch for the scene would do it: scene?.isUserInteractionEnabled = false But that didn't work, so I tried this, which also didn't work: view?.scene?.isUserInteractionEnabled = false That also didn't work, so I tried this, also from inside the scene: self.isUserInteractionEnabled = false 回答1: There is no global method to turn off

Texture for sprite not found and sprite not displayed when using SKSpriteNode with a category

旧城冷巷雨未停 提交于 2019-12-08 11:26:10
问题 I started using SKSpriteNode category system for extending the base functionality of the SKSpriteNode, and the sprites added to the .sks scene through the editor are now missing from the scene (not the ones programmatically added to the scene additionaly, in runtime). When I logged some of the sprites on the .sks, I can see their correct location, and scale parameters, but texture is always ['nil'] in the debugging console in XCode. This happens (see below NSLog line) when I for instance log

In app purchase in SKScene not working?

家住魔仙堡 提交于 2019-12-08 08:49:12
问题 I'm creating a SpriteKit game in Swift and I'm trying to implement in app purchases. I followed this question here: in app purchase in SKScene And here is my code: In didMoveToView: // Set IAPS if(SKPaymentQueue.canMakePayments()) { println("IAP is enabled, loading") var productID:NSSet = NSSet(objects: "GameOverSaveSavior") var request: SKProductsRequest = SKProductsRequest(productIdentifiers: productID as Set<NSObject>) request.delegate = self request.start() } else { println("please enable