Tag: 雪碧套件

SKAudioNode崩溃:AVAudioPlayerNode.mm:333:开始:所需条件为false:_engine-> IsRunning()

我有一个简单的SKAudioNode: let backgroundSound = SKAudioNode(fileNamed: "backgroundSound.mp3") 我使用backgroundSound.runAction(SKAction.play())和backgroundSound.runAction(SKAction.stop())来停止。 一切正常,直到应用程序进入后台模式,我会恢复超过3分钟。 如果我进入后台模式,并在10 – 20秒后恢复,audio不会崩溃。 所有崩溃日志: 2016-05-29 23:26:43.612 PippiPompiere[1070:199471] 23:26:43.611 ERROR: [0x3a7cf000] AVAudioPlayerNode.mm:333: Start: required condition is false: _engine->IsRunning() 2016-05-29 23:26:43.616 PippiPompiere[1070:199471] *** Terminating app due to uncaught exception 'com.apple.coreaudio.avfaudio', reason: 'required condition is false: _engine->IsRunning()' *** First throw call stack: (0x23ba5b8b 0x23362dff 0x23ba5a61 0x29499ea9 0x294e3739 0x294e2819 0x2fe98ee7 0x2ff16b43 […]

使用导航控制器的开始屏幕ios

我已经到了需要使用sprite套件制作我的游戏的开始屏幕。 我不能让它显示任何我已阅读和观看的代码和教程。 我想使用导航控制器/视图控制器在开始屏幕上开始,并将其链接到我的应用程序,但我不知道如何将我的游戏代码链接到视图控制器。 使用导航控制器,我将如何将其作为@IBAction声明拖到我的游戏代码中? 谢谢。 用当前代码编辑: ViewController.m: @implementation ViewController – (void)viewDidLoad { [super viewDidLoad]; SKView * skView = (SKView *)self.view; skView.showsFPS = YES; skView.showsNodeCount = YES; SKScene * scene = [MyScene sceneWithSize:skView.bounds.size]; scene.scaleMode = SKSceneScaleModeAspectFill; scene.viewController = self; [skView presentScene:scene]; } MyScene.h: @interface MyScene : SKScene <SKPhysicsContactDelegate> @property (strong, nonatomic) UIViewController *viewController; @end

使用视图控制器进行场景游戏

碰撞检测后,我需要为我的应用程序做一个结束屏幕。 用一个button回到主菜单/游戏到最后屏幕的最简单的方法是什么? 我可以使用ViewController吗? 我已经阅读了很多教程,video以及这里的所有post: 这是我目前的代码(不是所有的只是一些重要的事情): @implementation MyScene static const int squirrelHitCategory = 1; static const int nutHitCategory = 2; – (instancetype)initWithSize:(CGSize)size { if (self = [super initWithSize:size]) { self.physicsWorld.contactDelegate = self; _squirrelSprite = [SKSpriteNode spriteNodeWithImageNamed:@"squirrel"]; _squirrelSprite.position = _firstPosition; _atFirstPosition = YES; _squirrelSprite.physicsBody = [SKPhysicsBody bodyWithCircleOfRadius:10]; _squirrelSprite.physicsBody.categoryBitMask = squirrelHitCategory; _squirrelSprite.physicsBody.contactTestBitMask = nutHitCategory; _squirrelSprite.physicsBody.collisionBitMask = nutHitCategory; _squirrelSprite.physicsBody.affectedByGravity […]

控制精灵套件中的最大速度

我试图在我的游戏中控制angular色的最大速度。 当我移动他时,我使用这个: -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [touches anyObject]; CGPoint positionInScene = [touch locationInNode:self]; SKSpriteNode *touchedNode = (SKSpriteNode *)[self nodeAtPoint:positionInScene]; CGPoint posicionHero = [self childNodeWithName:@"hero"].position; SKSpriteNode *touchHero = (SKSpriteNode *)[self nodeAtPoint:posicionHero]; if((touchedNode !=touchHero) //jump forward && (positionInScene.x > [self childNodeWithName:@"Hero"].position.x) && (positionInScene.y > [self childNodeWithName:@"Hero"].position.y) ) { [[self childNodeWithName:@"Hero"].physicsBody applyImpulse:CGVectorMake(5,0)]; [[self childNodeWithName:@"Hero"].physicsBody […]

在目标C中,当呈现一个新的场景时,你如何去除旧的场景?

我是Objective-C的新手,所以我可能会用错误的方法来呈现这个场景,但是现在当我呈现我的新场景时,可以通过它看到旧的场景。 – (void)buttonClicked:(UIButton*)button { NSLog(@"Button %ld clicked.", (long int)[button tag]); WarScene *battle = [[WarScene alloc] initWithSize: CGSizeMake(1024,768)]; SKTransition *reveal = [SKTransition revealWithDirection:SKTransitionDirectionDown duration:1.0]; SKView * skView = (SKView *)self.view; [skView presentScene:battle transition:reveal]; } 有没有什么,我必须先写currentScene方法之前,去除当前的场景? 对不起,如果这是一个非常基本的问题,我已经search了一些例子,但似乎没有任何额外的代码,我错过了这意味着我可能提出的场景错误的第一位。

当主页button被按下时暂停Sprite Kit场景

我想知道如何当我按下主页button时暂停我的精灵套件场景。 我在这里find了几个答案,并尝试与这样的通知中心。 当我的场景加载时: [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidEnterBackground) name:UIApplicationDidEnterBackgroundNotification object:nil]; 然后,如果进入后台,则调用该方法: – (void) applicationDidEnterBackground{ NSLog(@"Enter to background"); self.scene.view.paused =YES; } 这里的问题是,我得到的NSLog消息,所以applicationDidEnterBackground方法被正确调用。 但问题是,当我返回到应用程序我的应用程序不处于“暂停”模式。 所以我的暂停语句(self.scene.view.paused = YES;)不被调用? 如果我把确切的声明放在代码的其他地方,或者如果我用这个语句暂停button暂停工作就好了。 问题是什么? 为什么这不会与通知中心?

iOS 9 Spritekit双击不适用于iPhone 6S

现在我一直在构build一个SpriteKit游戏。 它是一个纸牌游戏,允许双击特定行为的卡片精灵。 现在,我们在iOS 9中,双击在iPhone 6上完全不起作用。 在iOS8,所有设备上都可以正常工作。 在我的SKScene ,我使用touchesBegan方法来检测水龙头: -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [touches anyObject]; CGPoint touchLocation = [touch locationInNode:self]; if(touch.tapCount==2) { NSLog(@"double-tap, but not for iPhone 6s"); } } 有没有什么新的iOS9或6s专门(3D触摸?),需要现在执行SpriteKit游戏? 我想要注意的是,这在iPhone 6s模拟器工作正常,但它不在实际的设备上。 此外, touch.tapCount会报告touch.tapCount等水龙头,但完全跳过第二个水龙头。

如何正确使用Swift在SpriteKit中切换SKScenes?

我正在开发一个有3个不同的SKScenes(scene1,scene2,scene3)的游戏。 在GameViewController中,我像这样初始化它们: 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: hero) scene1.scaleMode = .AspectFill scene2.scaleMode = .AspectFill scene3.scaleMode […]

如何创build自定义SKA?

你好,我想要做的就是创build一个类似于wheelRight.physicsBody.velocity = CGVectorMake(0, 1000); 到一个物理对象。

bodyWithEdgeLoopF​​romRect不能在横向工作

我只是试图在景观中设置一个基本场景,引力,并在一个边缘循环的场景。 我设置了场景的物理体和mainCharacter精灵物理体,这里是我的代码: -(id)initWithSize:(CGSize)size { if (self = [super initWithSize:size]) { self.backgroundColor = [SKColor redColor]; [self setPhysicsBody:[SKPhysicsBody bodyWithEdgeLoopFromRect:[self frame]]]; } return self; } -(void)setupMain { if (!self.mainCharacter) { self.mainCharacter = [[SKSpriteNode alloc] initWithImageNamed:@"spriteDefault"]; [self.mainCharacter setPosition:CGPointMake(CGRectGetMidX([self frame]), CGRectGetMidY([self frame]))]; [self addChild:self.mainCharacter]; self.mainCharacter.physicsBody = [SKPhysicsBody bodyWithRectangleOfSize:self.mainCharacter.frame.size]; self.mainCharacter.physicsBody.dynamic = YES; self.mainCharacter.physicsBody.affectedByGravity = YES; self.mainCharacter.physicsBody.mass = 0.02; } } 所以,在肖像模式下,一切都很完美,但是在风景中,事情变得非常棘手。 […]