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
-1
votes
1 answer

Swift loop runs in reverse? Code conundrum

I don't understand what is happening in this code... fileprivate func genericNodeWalker(_ direction:Follow, encapsulatedMethod: @escaping (_ iNode:Int) -> Void) { switch direction { case .forwards: for nodeIndex in…
user3069232
  • 8,587
  • 7
  • 46
  • 87
-1
votes
1 answer

Why am I getting a Thread 1: fatal error in this function

I am getting the following error on the line basicTop.run(SK... Thread 1: Fatal error: Unexpectedly found nil while unwrapping an Optional value I do not know why I am getting this. I get this error message when I click on the simulator…
-1
votes
1 answer

Spawn SKSpriteNode objects at random times

I am making a game where I would like to spawn obstacles at random times. The obstacles are going to make contact with the player. Here the code that I have: var obstacle : SKSpriteNode? func createObstacles() { let obstaclesArray = ["obstacle_1",…
Mich1394
  • 5
  • 5
-1
votes
1 answer

Why does the app lag a lot when calling functions

I am building a game that requires a function (out of several) to be called depending if a condition is true or not. The condition checks the variable every 0.0001 seconds for game purposes, but the functions are called every 4-6 seconds. I just…
Alex Merlin
  • 341
  • 1
  • 3
  • 12
-1
votes
1 answer

I am trying to create a function that allows an object to move down the screen

I am trying to create a function that allows an object to move down the screen from top to bottom but I get this error: Cannot call value of non-function type 'Int' import UIKit import SpriteKit class ViewController: UIViewController { …
eb1928
  • 1
  • 2
-1
votes
1 answer

SpriteKit not playing audio file?

I have made a custom class, SoundNode, to handle the playing of audio files. For now, it only plays the default "A2.mp3" class SoundNode : SKSpriteNode{ func playSound(){ run(SKAction.playSoundFileNamed("A2", waitForCompletion: false)) …
Erik Martin
  • 99
  • 1
  • 1
  • 8
-1
votes
1 answer

Get progress of an animation - SpriteKit SKAction

The following code runs a sequence of images. let powerBar:SKSpriteNode = SKSpriteNode() func animate(){ var textures:[SKTexture] = [] for i in 1...30 { textures.append(SKTexture(imageNamed: "power\(String(format: "%04d", i))")) …
Clinton Lam
  • 687
  • 1
  • 8
  • 27
-1
votes
2 answers

How to create a custom SKAction in swift

The idea is that I am creating blocks that are falling out of the sky. To do this I need an custom action that does four things: Create an node with my block class Set the position of that node add the node to the scene after an delay go to point…
Thomas Pereira
  • 239
  • 1
  • 4
  • 18
-1
votes
1 answer

Xcode swift iOS - GameScene does non have a member named

Please can anyone help me relocate some code, I understand the event may need to be moved but I'm not sure where. I've looked for the answer already but I cant see anything specific to my problem. The error is 'GameScene' does not have a member…
Rich Townsend
  • 571
  • 1
  • 5
  • 21
-1
votes
1 answer

Changing the value of a variable in an SKAction

I've tried to change the value of an variable in an SKAction but it did not work and now I want to know if it is possible and if yes then how? Thank you for your answers
Macehil
  • 69
  • 10
-1
votes
2 answers

Change CGSize with a variable

I want to change the size of my SKNode with a variable so it can be made smaller with a for loop. It is giving me an error: Cannot find an initializer for type 'CGSize' that accepts an argument list of type '(width:... , height:...)' for (var i =…
-1
votes
2 answers

Sprite kit detect sound completion

I have used sequence of action and one of the action plays sound for me. SKAction *wait = [SKAction waitForDuration:1]; NSString* completion_sound = self.gameData[@"level_data"][@"completion_sound"]; SKAction *playSound =…
Matrosov Oleksandr
  • 25,505
  • 44
  • 151
  • 277
-1
votes
1 answer

How do I convert this line of code to swift, Im trying to make a sprite follow a circular path

How do I convert this line of code to swift: // circle path UIBezierPath *circle = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, 100, 100) cornerRadius:100]; SKAction *followCircle = [SKAction followPath:circle.CGPath asOffset:YES…
-1
votes
1 answer

SpriteKit - Random Movement

I have a node that i want to move by random value, do something and then move again by another random value. here is my code: var randomValues = [250, 300, 90, 130] var randomSpace = CGFloat(arc4random_uniform(UInt32(randomValues.count))) …
Abdou023
  • 1,654
  • 2
  • 24
  • 45
-1
votes
1 answer

SKAction from stringWithFormat

I'm trying to make a space-invaders-ish game that goes through levels automatically. The way I've been trying to do so is by running an action, that dynamically run another x SKAction. Example: int currentLevel = 1; [self runAction:…
1 2 3
44
45