skaction

Skaction.playsoundfilenamed crashes when repeat - sprite kit

こ雲淡風輕ζ 提交于 2019-11-29 10:32:16
I have a problem with sprite kit SKAction.playSoundFileNamed. In practice, after some time it is played correctly , the app crashes saying it will not load . The file is included in the bundle import the project file exists and everything is properly set. The only problem , after some time I play, I will crash saying it can not find the file , or at least can not be loaded . My question is , is there a way to recharge every time the sound SKAction.playSoundFileNamed ? EDIT - SOLVED //init var sound = SKAction.playSoundFileNamed("sound.mp3", waitForCompletion: false) var sound2 = SKAction

SKAction Completion Handlers; usage in Swift

大城市里の小女人 提交于 2019-11-29 06:14:26
I'm new to Swift and SpriteKit. A lot of the samples of SpriteKit Actions are in Objective C, which I can't map to, nor get working, in Swift. If running an SKAction, and upon SKAction completion wanting to do something else, how do I get this right, in Swift? spaceMan.runAction(spaceManDeathAnimation, completion: { println("red box has faded out") }) Any ideas will be greatly appreciated. Edit: for i in 0...29 { textures.append(SKTexture(imageNamed: "spaceManDeath_\(i)")) } spaceManDeathAnimation = SKAction.repeatActionForever(SKAction.animateWithTextures(textures, timePerFrame: 0.15625)) You

SpriteKit SKTexture.preloadTextures high memory usage Swift

狂风中的少年 提交于 2019-11-28 13:09:56
问题 I have a SKTextureAtlas with about 90 PNG Images. Every Image has a resolution of 2000 x 70 pixel and has a size of ~1 KB. Now I put this images from the Atlas into an array like this: var dropBarAtlas = SKTextureAtlas(named: "DropBar") for i in 0..<dropBarAtlas.textureNames.count{ var textuteName = NSString(format: "DropBar%i", i) var texture = dropBarAtlas.textureNamed(textuteName) dropFrames.addObject(texture) } Then I preload the array with the textures in didMoveToView: SKTexture

How to interrupt a SpriteKit sequence of actions and resume as if there was no interruption

泪湿孤枕 提交于 2019-11-28 07:57:49
问题 I would like to interrupt the sequence below for 2 seconds and resume to where it would have been if it wasn't interrupted in the first place. For example, from the code below, if I were interrupt the sequence for 2 seconds by making the sprite visible from 1.5 - 3.5 seconds into the sequence (meaning that 1 second the hideInterval action plus the showSprite action, and 0.5 seconds of the showInterval action would be missed) the interruption would end at 2.5 seconds remaining for the

Skaction.playsoundfilenamed crashes when repeat - sprite kit

让人想犯罪 __ 提交于 2019-11-28 03:47:56
问题 I have a problem with sprite kit SKAction.playSoundFileNamed. In practice, after some time it is played correctly , the app crashes saying it will not load . The file is included in the bundle import the project file exists and everything is properly set. The only problem , after some time I play, I will crash saying it can not find the file , or at least can not be loaded . My question is , is there a way to recharge every time the sound SKAction.playSoundFileNamed ? EDIT - SOLVED //init var

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

Rotate sprite by touch with a limited rotation speed

£可爱£侵袭症+ 提交于 2019-11-27 21:40:16
I'm trying to make my spriteNode rotate over finger touch. So far I can do it, but what I want is that my node have a "rotation speed". So I calculate the length of the angle then set a different timing to rotate with it (if the arc is long, it will take time...). Here's my code : override func touchesMoved(touches: NSSet, withEvent event: UIEvent) { _isTouched = true for touch in touches { let location:CGVector = touch.locationInNode(self) - miner.position miner.weaponRotation = location.angle() - CGFloat(M_PI_2) } } var wantedRotation: CGFloat { get { return _wantedRotation } set(rotation) {

How do you move an IOS SKSprite at a consistent speed

隐身守侯 提交于 2019-11-27 15:05:49
问题 Playing around with SKSprites in the IOS SpriteKit, and I basically want to have a sprite randomly move a certain direction for a certain distance, then pick a new random direction and distance.. Simple enough, create a method that generates the random numbers then creates the animation and in the completion block of the animation have it callback the same routine. THis does work, but it also keeps the animation from moving at the same velocity since the animations are all based on duration..

How to stop a audio SKAction?

吃可爱长大的小学妹 提交于 2019-11-26 22:01:20
问题 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

Rotate sprite by touch with a limited rotation speed

徘徊边缘 提交于 2019-11-26 20:45:42
问题 I'm trying to make my spriteNode rotate over finger touch. So far I can do it, but what I want is that my node have a "rotation speed". So I calculate the length of the angle then set a different timing to rotate with it (if the arc is long, it will take time...). Here's my code : override func touchesMoved(touches: NSSet, withEvent event: UIEvent) { _isTouched = true for touch in touches { let location:CGVector = touch.locationInNode(self) - miner.position miner.weaponRotation = location