skscene

SKScene becomes unresponsive while being Idle

混江龙づ霸主 提交于 2019-12-19 11:36:10
问题 Hello I have a SceneKit game. All the game play is in one scene and when the game is over the sprit kit overlay acts as a game over screen and when they hit play again the sprite kit labels disappear and the game resets all in the same scene. My issuing is coming in the game over. If the user hits the replay button within a few seconds then everything goes well. But if the user sits on the game over place for over five seconds then the scene freezes. I am really confused as the app is idle

How to change SKscene size

懵懂的女人 提交于 2019-12-19 11:29:17
问题 every time i run my app in my simulator the view scale always comes out to 768,1024 how do you change this to 1024,768. here is the default size code class GameViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() if let scene = GameScene(fileNamed:"GameScene") { // Configure the view. let skView = self.view as! SKView skView.showsFPS = true skView.showsNodeCount = true /* Sprite Kit applies additional optimizations to improve rendering performance */ skView

Add SKReferenceNode/SKScene to another SKScene in SpriteKit

筅森魡賤 提交于 2019-12-18 05:12:15
问题 I would like to add a SKScene to my main GameScene. SKReferenceNode seems to be a good solution. I have : - GameScene.sks (main scene) - Countdown.sks (scene to add to GameScene) - Countdown.swift (Custom class, how does to init it? SKScene ? SKReferenceNode ? SKNode) I don't know how to add programmatically my countdown using my class Countdown. I tried: let path = Bundle.main.path(forResource: "Countdown", ofType: "sks") let cd = SKReferenceNode (url: NSURL (fileURLWithPath: path!) as URL)

In swift, how to get memory back to normal after an SKScene is removed?

我与影子孤独终老i 提交于 2019-12-18 02:41:53
问题 I created a simple game with SpriteKit, however every time I run the game, the memory usage in simulator increases about 30mb, but never decreases when the game is finished. When I run the game over ten times the simulator gets slower and slower and eventually crashes. In this simple game I have two controllers and a gamescene: MainController calls GameViewController via a button triggered In GameViewController, gamescene is initialised in this way: class GameViewController: UIViewController

How to keep SpriteKit scene paused when app becomes active?

风流意气都作罢 提交于 2019-12-17 21:28:36
问题 Is there anyway to prevent SpriteKit from automatically unpausing a scene when entering foreground/becoming active? I set paused = true and want it to remain so even when the app becomes active again after having been sent to the background. I should add that I'm doing this in swift, though I would not have expected the behaviour to be different in this regard. 回答1: Not sure if it is the same in objective C, but in swift I had to "override" a callback function that SKView calls behind the

How to set bounds to Scene physics body to bounce properly?

那年仲夏 提交于 2019-12-13 18:51:28
问题 I implemented a simple physics to bounce a sprite node , and everything worked except the node is bouncing off the screen for the top and bottom.It is fine for the sides, but it goes off the screen for top and bottom view. Here is the view: As you can see, I the ball is going off the screen at the bottom, where it perefectly touches the other three sides. This is because, I made a change to: self.physicsBody=[SKPhysicsBody bodyWithEdgeLoopFromRect:CGRectMake(self.frame.origin.x, self.frame

Sound for Scene Transition, that doesn't stutter

杀马特。学长 韩版系。学妹 提交于 2019-12-13 15:48:47
问题 In SpriteKit (for those unfamiliar with it) there's a way to load and unload scenes, and a transition (visual) between them. I'm trying to make a sound play between scenes, as they transition... that doesn't stutter. So far, all the ways I've tried either create no sound, or the sound stutters, even using a sound manager, like this: import AVFoundation import SpriteKit open class SoundManager { static let soundStart = SKAction.playSoundFileNamed("ActionBeep_AP1.7", waitForCompletion: true)

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?

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

The best way to implement lives and score count in Sprite Kit (static, IoC, other?)

可紊 提交于 2019-12-13 03:16:37
问题 I have background in Java but havn't been coding in years. Lately I've taken interest to warm my coding skills again and have chosen to create learning apps for my kids in Swift. I've created basic Swift game utilizing the Sprite Kit with gameviewcontroller and multiple scenes. However I run into a basic question which is related to passing basic data such as points and lives counts from scenes to gameviewcontroller. Back in the day, I would have done it by creating a static member that would