skaction

SKAction playSoundFileNamed from Singleton

流过昼夜 提交于 2019-12-01 11:02:59
I have several levels all using the same sound effects. Instead of having the same code in every level, I consolidated all of the sounds into a singleton class. However, having it in a singleton no sound is played when I run the method from other classes. I have no errors or warnings. When I have the same code in each class I have no problems playing the sound. Question: Does SKAction playSoundFileNamed not work when called from a singleton or is my code missing something? My singleton header file... -(void)soundSwordWhoosh; My singleton methods file... @implementation Animations{ SKAction

SKAction playSoundFileNamed stops background music

情到浓时终转凉″ 提交于 2019-12-01 08:20:29
I want my SpriteKit game not to interrupt background music that user listens (Music.app or radio app). Everything goes fine until execution reaches this line: sSharedShootSoundAction = [SKAction playSoundFileNamed:@"plane_shoot.aiff" waitForCompletion:NO]; After this line background music stops. How to avoid this? I have also encountered this problem myself. FYI my solutions are in swift so just translate this to Objective C if you are still using that. For me my solution included two parts. First, I had to initialize my SoundAction SKAction within my didMoveToView function in my scene file.

SKAction playSoundFileNamed from Singleton

≯℡__Kan透↙ 提交于 2019-12-01 08:10:34
问题 I have several levels all using the same sound effects. Instead of having the same code in every level, I consolidated all of the sounds into a singleton class. However, having it in a singleton no sound is played when I run the method from other classes. I have no errors or warnings. When I have the same code in each class I have no problems playing the sound. Question: Does SKAction playSoundFileNamed not work when called from a singleton or is my code missing something? My singleton header

Play Sound in Swift SpriteKit project?

大兔子大兔子 提交于 2019-12-01 07:36:17
When I run this code. runAction(SKAction.playSoundFileNamed("Click.mp3", waitForCompletion: false)) My app was Crashed: Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Resource Click.mp3 cannot be found in the main bundle' Mr. Developer verify that the file exists in the project. instantiates the variables in the file first and then make a method for breeding. if the file exists in the project you should do the following: var sound = SKAction.playSoundFileNamed("sound.mp3", waitForCompletion: false) ... override func didMoveToView(view: SKView) { playSound

SKAction playSoundFileNamed stops background music

混江龙づ霸主 提交于 2019-12-01 07:10:37
问题 I want my SpriteKit game not to interrupt background music that user listens (Music.app or radio app). Everything goes fine until execution reaches this line: sSharedShootSoundAction = [SKAction playSoundFileNamed:@"plane_shoot.aiff" waitForCompletion:NO]; After this line background music stops. How to avoid this? 回答1: I have also encountered this problem myself. FYI my solutions are in swift so just translate this to Objective C if you are still using that. For me my solution included two

Spritekit crashes when entering background

自闭症网瘾萝莉.ら 提交于 2019-12-01 03:43:21
Allright guys, I've been developing an app in which I have a NSMutableDictionary with an SKAction object in it. The SKAction is for playing a sound. This all works well, except ... the app crashes upon entering background with the following stack trace: * thread #1: tid = 0x187d7, 0x3461b932 libGPUSupportMercury.dylib`gpus_ReturnNotPermittedKillClient + 10, queue = 'com.apple.spritekit.renderQueue, stop reason = EXC_BAD_ACCESS (code=1, address=0x1) frame #0: 0x3461b932 libGPUSupportMercury.dylib`gpus_ReturnNotPermittedKillClient + 10 frame #1: 0x3461c3d0 libGPUSupportMercury.dylib

SKAction playSoundFileNamed doesn't work after receiving two consecutive phone calls

蹲街弑〆低调 提交于 2019-11-30 18:06:47
I am trying to figure out why playSoundFileNamed doesn't work after receiving two consecutive phone calls. Actually it works only after the first phone call is received. Reproducing steps are: Start a game Wait for a phone call and go to background Phone call is finished (declined or interrupted by caller) Returning to foreground After this, playing the sound from touchesBegan still works. When I repeat the steps from above (first step is skipped), mechanism from touchesBegan stops working. Not sure why is this happening...Here is the code which can produce described behaviour: @interface

SKAction playSoundFileNamed doesn't work after receiving two consecutive phone calls

柔情痞子 提交于 2019-11-30 16:50:14
问题 I am trying to figure out why playSoundFileNamed doesn't work after receiving two consecutive phone calls. Actually it works only after the first phone call is received. Reproducing steps are: Start a game Wait for a phone call and go to background Phone call is finished (declined or interrupted by caller) Returning to foreground After this, playing the sound from touchesBegan still works. When I repeat the steps from above (first step is skipped), mechanism from touchesBegan stops working.

Animate Path Drawing in SpriteKit

淺唱寂寞╮ 提交于 2019-11-30 14:13:26
I'm attempting to animate the drawing of a stroke on a path using SpriteKit . I have implemented a working solution using SKActions and a separate implementation using CABasicAnimations . The SKAction solution is not very elegant; it creates and strokes a new path on each iteration of an SKAction.repeatAction(action:count:) call with each new path slightly more complete than the previous. func start() { var i:Double = 1.0 let spinAction:SKAction = SKAction.repeatAction(SKAction.sequence([ SKAction.runBlock({ self.drawCirclePercent(i * 0.01) if (++i > 100.0) { i = 1.0 } }), SKAction

Run two SKActions at once

本秂侑毒 提交于 2019-11-30 13:10:03
问题 I'm using a sequence to run a list of SKActions. What I want to do however, is run an SKAction, then run two at once, then run one in sequence. Here is my code: SKNode *ballNode = [self childNodeWithName:@"ball"]; if (ballNode != Nil){ ballNode.name = nil; SKAction *delay = [SKAction waitForDuration:3]; SKAction *scale = [SKAction scaleTo:0 duration:1]; SKAction *fadeOut = [SKAction fadeOutWithDuration:1]; SKAction *remove = [SKAction removeFromParent]; //put actions in sequence SKAction