Questions tagged [skaction]

Questions about programming SKAction objects in Apple's SpriteKit graphics rendering and animation framework.

Use this tag for questions about programming SKAction objects in Apple's graphics rendering and animation framework.

An SKAction changes a node property over time. It can also run custom blocks and it can be run on individual particles of an SKEmitterNode. Multiple actions can be run in parallel or sequence.

Actions are evaluated after the SKScene's update method. The scene receives the didEvaluateActions message when actions have been evaluated for the current frame.

Note: actions override physics behavior, for example a node with physicsBody that runs a SKMove action will not stop at collisions.

Click Here for Apple Docs.

667 questions
27
votes
2 answers

Run two SKActions at once

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){ …
Max Hudson
  • 9,961
  • 14
  • 57
  • 107
21
votes
1 answer

Is it possible to end an SKAction mid-action?

I have a subclass of SKSpriteNode (monsterNode). It automatically runs around the screen using vectors to follow the player. I am currently using the following action to make it run around: SKAction *actionMove = [SKAction moveTo:actualDistance…
EvilAegis
  • 733
  • 1
  • 9
  • 18
18
votes
2 answers

Stopping an running SKAction - Sprite Kit

The following code will animate a rotation. let something:SKSpriteNode = SKSpriteNode() func start(){ let rotateAction = SKAction.rotateToAngle(CGFloat(M_PI), duration: 10.0) something.runAction(SKAction.sequence([rotateAction])) } Now I want…
Clinton Lam
  • 687
  • 1
  • 8
  • 27
13
votes
2 answers

How to stop a audio SKAction?

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…
MB_iOSDeveloper
  • 4,178
  • 4
  • 24
  • 36
12
votes
2 answers

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

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…
Whirlwind
  • 14,286
  • 11
  • 68
  • 157
12
votes
3 answers

SKAction Completion Handlers; usage in Swift

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…
spacecash21
  • 1,331
  • 1
  • 19
  • 41
12
votes
5 answers

SpriteKit: fade out SKNode - children shines through

I have a SKSpriteNode which I fade out with baseNode.runAction(SKAction.fadeOutWithDuration(0.5)) The sprite has one Child. Also a SKSpriteNode. (The red block in the image) While the baseNode fades out there is the contour of die child node. What…
Jonas Ester
  • 535
  • 4
  • 19
11
votes
3 answers

Pause an SKAction in Spritekit with Swift

I have the following code to move an SKSpriteNode. let moveDown = SKAction.moveBy(CGVectorMake(0, -120), duration: 1) let moveUp = SKAction.moveBy(CGVectorMake(0, +120), duration: 1) let moveSequence = SKAction.sequence([moveDown,…
user4909608
11
votes
7 answers

SKAction playsoundfilenamed fails to load sound

No matter what wav file I tried to play in an project, I keep getting the same error. The error states: Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Resource namedfile.wav can not be loaded' I cannot get any sound…
sc24evr
  • 109
  • 1
  • 1
  • 5
11
votes
1 answer

Stop SKAction that RepeatsForever - Sprite Kit

I want to run two animations on my spriteNode depending on its rotation. If the value is negative run one of the animations, if it's positive run the other. And I managed to do that (kind of) but I have a problem. If Animation1 is running, and…
iSLB
  • 125
  • 1
  • 1
  • 5
11
votes
2 answers

Spritekit crashes when entering background

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…
Sabatino
  • 379
  • 4
  • 11
10
votes
3 answers

Swift 3 (SpriteKit): Stopping a forever looping SKAction has a delay

I have been trying to make a forever running SKAction that I can stop whenever I want to. I have done it like this: override func didMove(to view: SKView) { run(SKAction.repeatForever ( SKAction.sequence ([ …
J.Treutlein
  • 963
  • 8
  • 23
10
votes
4 answers

Sprite Kit: Why does playing sound return error?

I upgraded my Sprite Kit game to X-Code 8.0 and Swift 3 yesterday. Deployment target is currently set to iOS 9.3. I play sound effects the following way: self.run(SKAction.playSoundFileNamed("click.caf", waitForCompletion: false)) The sound effect…
salocinx
  • 3,715
  • 8
  • 61
  • 110
8
votes
1 answer

Making a half circle path with CGPath, and follow the path with SKAction

I have no idea how to make a half circle path with CGPath. There is the code i have: let path = CGPathCreateMutable() let Width: CGFloat = 38.0 let radius: CGFloat = (Width / 2.0) + (Treshold / 2.0) CGPathAddArc(pathOne, nil, x, 0.0,…
Nurassyl Nuridin
  • 444
  • 4
  • 13
8
votes
3 answers

Play Sound in Swift SpriteKit project?

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…
VIẾT NAM
  • 135
  • 2
  • 3
1
2 3
44 45