Hello everyone!
I’m developing a game and trying to create animated city background. I want to make an illusion that houses are moving far away(by srinking them). So, what I need is just move and shrink node to center, then just place it where it started and repeat that action
forever. I tried to use sequence
and group
but all of my sprites just disapearing and nothing happening
Please help anyone
class GameScene: SKScene, SKPhysicsContactDelegate {
var background = SKSpriteNode(imageNamed: "background.png")
var house1Left = SKSpriteNode(imageNamed: "House1Left.png")
override func didMove(to view: SKView) {
self.anchorPoint = CGPoint(x: 0.5, y: 0.5)
addChild(background)
house1Left.position = CGPoint(x: -self.frame.size.width/2, y: 0)
addChild(house1Left)
let move = SKAction.moveTo(x: 0.0, duration: 2.0)
let resize = SKAction.scale(by: 0.1, duration: 2.0)
let group = SKAction.group([move, resize])
let resetPosition = SKAction.move(to: CGPoint(x: -self.frame.size.width/2, y:0), duration: 0.0)
let resetSize = SKAction.scale(by: 10.0, duration: 0.0)
let resetGroup = SKAction.group([resetPosition, resetSize])
let sequence = SKAction.sequence([group, resetGroup])
let runAction = SKAction.repeatForever(sequence)
house1Left.run(runAction)
}
}