skscene

Adding UITextView to a scene in SpriteKit

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-08 08:36:40
问题 I trying to create a game, and following Apple's advice I am using multiple scenes. You could consider the game to be a text heavy point and click adventure. Therein lies the problem. Lots of text, having done a bit of a search, it seems the recommend way, or rather the current only way to do this is with a UITextView thus: [self.view addSubview: textView]; This is all well and good if you only have one SKScene , as that is the scene being displayed by the current view/SKView. My problem is,

Force change interface orientation between scenes

旧巷老猫 提交于 2019-12-08 07:46:43
问题 How can I force the game to switch from portrait (Scene 1) to landscape mode (HomeScene) in between scenes? I have two scenes, Scene1 (which is portrait) and HomeScene (which is designed to be landscape) I am calling this line from Scene 1. -(void)gotoHome { //Would like to change interface orientation here. HomeScene *scene = [HomeScene sceneWithSize:self.size]; [self.view presentScene:scene]; } Problem is, both the scenes are being rendered on the same view. How can I tell a viewController

How to loop music with SKAction?

淺唱寂寞╮ 提交于 2019-12-07 13:33:19
问题 I want to loop my background music with an SKAction but the music stops after one row when I switch to an other scene. Is there a way to start the loop and keep playing it over different scenes? Right now the code is placed in the init method of MyScene - is that the correct place? Maybe didFinishLaunchingWithOptions? Here is what I've tried: if (delegate.musicOn == YES && delegate.musicIsPlaying == NO) { SKAction *playMusic = [SKAction playSoundFileNamed:@"loop.wav" waitForCompletion:YES];

Loading an SKNode from a .sks scene file in Swift

天涯浪子 提交于 2019-12-07 05:19:22
问题 I want to use multiple .sks files to store some complex SKNode hierarchies such as game menus. I have a background with moving objects I'd like to keep throughout the game, so presenting different SKScenes doesn't achieve what I want. I am restricted to one scene, but I'd still like to separate out my code from artwork as much as possible, and trying to squeeze everything into one .sks file gets crowded quick! So I'd like to have multiple .sks files, each one storing a different menu:

Create Button in SpriteKit: Swift

心已入冬 提交于 2019-12-07 00:37:04
问题 I want to create a button in SpriteKit or in an SKScene that sends the view to another view controller. I tried using the "performSegue with identifier ", however apparently an SKScene doesn't support this. How would I create a button that sends the view to another view with SpriteKit ? This is the code that I've tried using to perform this action. The line with "HomeButton.prepareForSegueWithIdentifier()" is just an example. It won't actually let me add the "prepareForSegue" part, it doesn't

Change SKScene using presentScene()

…衆ロ難τιáo~ 提交于 2019-12-06 12:54:29
In my SpriteKit Game i'm using: self.scene!.removeFromParent() let skView = self.view! as SKView skView.ignoresSiblingOrder = true var scene: PlayScene! scene = PlayScene(size: skView.bounds.size) scene.scaleMode = .AspectFill skView.presentScene(scene, transition: SKTransition.fadeWithColor(SKColor(red: 25.0/255.0, green: 55.0/255.0, blue: 12.0/255.0, alpha: 1), duration: 1.0)) to move from one scene to another. But how can I go back to the original scene? Using the same principle of code always led to a major crash.. Whirlwind I made an example where global structure is used to track the

How to loop music with SKAction?

≯℡__Kan透↙ 提交于 2019-12-05 22:37:30
I want to loop my background music with an SKAction but the music stops after one row when I switch to an other scene. Is there a way to start the loop and keep playing it over different scenes? Right now the code is placed in the init method of MyScene - is that the correct place? Maybe didFinishLaunchingWithOptions? Here is what I've tried: if (delegate.musicOn == YES && delegate.musicIsPlaying == NO) { SKAction *playMusic = [SKAction playSoundFileNamed:@"loop.wav" waitForCompletion:YES]; SKAction *loopMusic = [SKAction repeatActionForever:playMusic]; [self runAction:loopMusic]; delegate

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

荒凉一梦 提交于 2019-12-05 22:21:58
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 removeFromParent]; }], [SKAction runBlock:^{ level2Achieved = [[NSUserDefaults standardUserDefaults]

After Closing SKScene, Memory Remains High

泪湿孤枕 提交于 2019-12-05 18:20:55
问题 I use a dispatch_once NSObject to create data pointers. So all game asset pointers are made when the main viewcontroller appears. In order to play a game, the user taps a UIButton corresponding to a particular level on a UIViewController . Let me call it LevelSelectionController. When the game is over, the user will tap a label ( SKLabel ). And all actions and nodes will be removed. [self removeAllActions]; [self removeAllChildren]; [self removeFromParent]; Moreover, an SKScene subclass for a

iOS7 SKScene how to make a sprite bounce off the edge of the screen?

烂漫一生 提交于 2019-12-05 18:01:28
I'm building a game with balls bouncing within the iPad's screen. Similar to a Pong game. I see that SKScene's SKPhysicsWorld has gravity property, and also controls how objects collide with each other. Is there some way I can automatically detect if a sprite's edge has collided with the screen's edge, so it can bounce off that? Or do I need to write my own collision code? You don't need to write much code to make the ball bounce off the edge of the screen. the physics environment can handle all of the above, you just need to instantiate the sprites in the correct way. First, you will have to