Okay I am fairly new to programming and am trying to create a simple game. In the background I'm having an object move from one side of the screen to another and then off the screen using SKAction and SKTransition. All I need to do is loop this transition so when the object goes back off the screen it starts again and comes back on. I'm using SpriteKit. Here is my code.
//Walls
Walls = SKSpriteNode(imageNamed: "Walls")
Walls.position = CGPoint(x: 1080 + Walls.frame.width / 2, y: self.frame.height / 2)
Walls.zPosition = 1
Walls.runAction(SKAction.moveTo(CGPoint(x: -300 + Walls.frame.width / 2, y: self.frame.height / 2),duration: 6.0))
self.addChild(Walls)
Where can I add in the reapeatActionForever code command or something similar? Thanks for your help in advance. Sam. :)
From what I gather, you're looking for how to use repeatActionForever... Please clarify the question so people don't have to guess
I'd put this code in didMoveToView if you want it to start immediately after the scene loads. Otherwise, put it in a block or function where you want it to start. To stop it, change it to:
Then to stop it: