skscene

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

冷暖自知 提交于 2019-11-28 23:38:32
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 { var skView:SKView! var scene:GameScene! override func viewDidLoad() { super.viewDidLoad() scene =

Go back to view controller from SKScene

断了今生、忘了曾经 提交于 2019-11-28 13:05:05
So when you create a project using the SpriteKit template. You have your View controller and your SKScene. From my view controller I start my game with the code given by default and present the scene. In my TCAViewcontroller.m - (IBAction)startGame:(id)sender { NSLog(@"Start Game triggered"); mainPageImage.hidden = 1; // Configure the view. // Configure the view after it has been sized for the correct orientation. SKView *skView = (SKView *)self.view; if (!skView.scene) { skView.showsFPS = YES; skView.showsNodeCount = YES; // Create and configure the scene. TCAMyScene *theScene = [TCAMyScene

Strange EXC_BAD_ACCESS SpriteKit removeSubsprite crash

不打扰是莪最后的温柔 提交于 2019-11-28 09:44:50
问题 I am new to SpriteKit and just built my first game. Everything was working great until iOS 7.1. Now, after a few times of advancing to a new level and presenting a new Scene , it crashes. I don't think I am presenting it in an incorrect way: ZSSMyScene *nextLevel = [[ZSSMyScene alloc] initWithSize:self.size level:self.level score:score]; [self.view presentScene:nextLevel]; I get a EXC_BAD_ACCESS error, and it looks like it is happening on removeSubsprite , but I can't find anywhere in my code

How to dismiss SKScene?

谁说我不能喝 提交于 2019-11-28 08:26:30
When Im finished with my SKScene is there a way to dismiss the SKScene from within my SKScene class? If not back in my Viewcontroller where I present my SKScene [skView presentScene:theScene]; is there a way to restart the scene or remove in from my SKView? The SKScene Class Reference and SKView Class Reference are no help. Update: The following code removes my scene from my SKView [yourSKView presentScene:nil]; but when Im back in my view controller the scene is still running in the background. I can always pause it when the game is over and I'm sent back to my view controller(menu) but I'm

How to stop a audio SKAction?

痞子三分冷 提交于 2019-11-28 01:51:06
Goal: I want to present a new scene: [self.scene.view presentScene:level2 transition:reveal]; and end the current background music in order to start the new background music (the new background music from level 2). TheProblem: Upon presenting the new scene the background music of the 1. scene (level1) keeps playing and DOES not stop even when leaving the miniGame since the whole game consists of few mini games. The music played is an SKAction: @implementation WBMAnimalMiniGameLvL1 -(id)initWithSize:(CGSize)size { if (self = [super initWithSize:size]) { /* Setup your scene here */ self

in app purchase in SKScene

我的梦境 提交于 2019-11-27 22:28:14
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. First, put this in your game scene line and make sure you have the framework 'StoreKit' imported class GameScene: SKScene, SKPaymentTransactionObserver, SKProductsRequestDelegate { Next, your going to want to put these lines in your didmovetoview. Keep in

Pausing a sprite kit scene

喜你入骨 提交于 2019-11-27 20:06:33
@property (SK_NONATOMIC_IOSONLY, getter = isPaused) BOOL paused; I found this line of code that I could add into my project, how would I pause my whole game? For example: -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{ for (UITouch *touch in touches) { SKSpriteNode *pause = (SKSpriteNode*)[self childNodeWithName:@"pause"]; CGPoint location = [touch locationInNode:self]; // NSLog(@"** TOUCH LOCATION ** \nx: %f / y: %f", location.x, location.y); if([pause containsPoint:location]) { NSLog(@"PAUSE GAME HERE SOMEHOW"); } } } As you can see, I have the button set up. When i select

Swift 3 (SpriteKit): Reseting the GameScene after the game ends

a 夏天 提交于 2019-11-27 16:54:29
问题 I am wanting to 'reset' and 'restart' the GameScene so it is as if the GameScene was first called. I have looked at different methods for doing this, but each time I get a warning that I'm trying to add a node to a parent which already has a parent. However, in my code I delete all my existing nodes so I'm really confused as to how to reset the GameScene. This is how I do it now (this code is called when I want to restart the GameScene from scratch and it is called within the GameScene class)

How to call method from ViewController in GameScene

时光总嘲笑我的痴心妄想 提交于 2019-11-27 07:55:11
I have a method that has a custom segue in my viewController that looks like this: func gameOver() { performSegueWithIdentifier("GameOver", sender: nil) } I call the method like so in GameScene.swift: GameViewController().gameOver() I double checked the segue name and it is correct. Whenever I call this in my GameScene.swift file I get the SIGABRT message and I don't know why. I tried calling the function with only a println() message and it worked. Any advice on why this is occurring and how I can successfully call the method in the GameScene.swift file would be greatly appreciated. Thanks! P

Go back to view controller from SKScene

泄露秘密 提交于 2019-11-27 07:37:46
问题 So when you create a project using the SpriteKit template. You have your View controller and your SKScene. From my view controller I start my game with the code given by default and present the scene. In my TCAViewcontroller.m - (IBAction)startGame:(id)sender { NSLog(@"Start Game triggered"); mainPageImage.hidden = 1; // Configure the view. // Configure the view after it has been sized for the correct orientation. SKView *skView = (SKView *)self.view; if (!skView.scene) { skView.showsFPS =