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
4
votes
2 answers

How to use timing function for slowly speed up scaling function with SpriteKit

I have a sprite that I'm trying to scale out. I'm using the scaleTo skaction to do this... I want it to slowly ease in. And this was my initial solution: let scal = SKAction.scale(by: 100, duration: 10) scal.timingMode =…
Discoveringmypath
  • 1,049
  • 9
  • 23
4
votes
1 answer

SKAction applyForce not working?

I want to mimic gravity without using physicsBody. However when I do this let applyForce = SKAction.applyForce(CGVector(dx:0,dy:-9.8), duration:duration) sprite.run(applyForce) Nothing happens. Why is that so?
phindle
  • 73
  • 5
4
votes
1 answer

Cannot disable, then reenable touch, after an SKAction animation

I am working on an interactive, animated scene. I want all touches on the scene to be disabled on entry. Then, once the objects (which are subclassed nodes) in the scene finish rotating/moving, I want to re-enable all touches on the screen to allow…
user5480023
4
votes
1 answer

Remove a specific list of SKAction from a SKNode

During the development of some interactions between different nodes, I realized I need to remove a specific list of actions from a node. The current version of Sprite-Kit framework provides some instance methods as: removeAllActions() action(forKey…
Alessandro Ornano
  • 34,887
  • 11
  • 106
  • 133
4
votes
3 answers

OpenAL vs AVAudioPlayer vs other techniques for playing sounds

I know that OpenAL is fast library but it doesn't support any compressed audio format and it's not so easy to use... AVAudioPlayer is not so fast, but supports wide range file formats, as well as compressed formats like mp3. Also there is an…
Whirlwind
  • 14,286
  • 11
  • 68
  • 157
4
votes
1 answer

Following a CGPath with SKAction without starting from beginning of CGPath

I have an SKShape node that represents an ellipse. A player is placed on the current point of a Bezier Path that is based on the ellipse's CGPath: I have two actions that the player node can perform. The player can either follow the path…
JuJoDi
  • 14,627
  • 23
  • 80
  • 126
4
votes
3 answers

Spritekit adding a sound effect

I'm trying to add a sound effect to a game whenever the screen is touched. I already have a touchesBegan method that moves a character, can i put the : [SKAction playSoundFileNamed:@"sfx.wav" waitForCompletion:NO]; into that method or do I need to…
user3299383
  • 213
  • 5
  • 17
4
votes
3 answers

Check if SKAction is running

How do I check if a SKAction has finished its animation? I need to check if my action has already finished or is still performing its action. After that I want to create a boolean to avoid multiple actions during the main action. SKAction…
David P
  • 228
  • 2
  • 14
4
votes
2 answers

SKAction playSoundFileNamed stops background music

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" …
Andrey Gordeev
  • 30,606
  • 13
  • 135
  • 162
4
votes
3 answers

How to create an autoreversing animation that loops forever in Sprite Kit?

I'm trying to do a simple automatically reversing animation. SKAction *a = [SKAction moveToX:10 duration:0.5]; a = [SKAction repeatActionForever:a]; [car runAction:a]; But the action doesn't reverse. How do you get a similar autoreverse effect like…
openfrog
  • 40,201
  • 65
  • 225
  • 373
4
votes
3 answers

SKAction playSoundFileNamed ERROR

I am getting this error after about 80 shots of a laser using a controlled Timer Interval so it fires every 0.2 seconds. * Terminating app due to uncaught exception 'Failed to Load Resource', reason: 'Resource squish.mp3 can not be loaded' * First…
Mixstah
  • 411
  • 1
  • 7
  • 22
4
votes
2 answers

How do I get a callback from a SpriteKit repeating action when the sprite reaches the end of a path?

I have created my SKAction in this manner: unicornAction = [SKAction followPath:mypath asOffset:NO orientToPath:YES duration:0.1]; and added it to my SKSprite: [sprite runAction:[SKAction repeatActionForever:unicornAction] withKey:@"move"]; I do…
Andrew
  • 15,357
  • 6
  • 66
  • 101
3
votes
1 answer

If an SKAction is removed, is the completion still run?

As in the title, if I remove an action using sprite.removeAllActions(), does the action's completion still get run? Here is a basic code snippet to help show what I am asking: import SpriteKit /// The action to add let action = SKAction.moveBy(x:…
George
  • 25,988
  • 10
  • 79
  • 133
3
votes
2 answers

How to create realistic spinning wheel in SpriteKit

I am trying to create a spinning fortune wheel action via SKAction. I have a SKNode which used as wheel, this SKNode is a circle that divided to four quarters (each quarter in different color). also I set an SKAction (which is repeating for 10…
omerc
  • 179
  • 1
  • 11
3
votes
2 answers

Xcode Swift SKAction.follow start point

I am trying to make a spaceship orbit around a planet. I am currently doing let playerPos = player.position let planetPos = planet.position let radius = playerPos.x - planetPos.x let rect = CGRect(x: planetPos.x - radius, y: planetPos.y - radius,…