How to consolidate all characters under one main player to perform same action in SpriteKit

I am building a game in SpriteKit. The game will include 5 players and instead of coding SKActions five times for every player, I want to consolidate all characters into one and code one time for each SKAction but the code below doesn't seem to work. Am I missing something?

import SpriteKit  var player1 = SKSpriteNode() var player2 = SKSpriteNode() var player3 = SKSpriteNode() var player4 = SKSpriteNode() var player5 = SKSpriteNode()  var mainPlayer = SKSpriteNode()  // in view did load   player1 = mainPlayer player2 = mainPlayer player3 = mainPlayer player4 = mainPlayer player5 = mainPlayer  //in touches began  let rightMoveAction = SKAction.moveByX(50, y: 0, duration: 0.1)  mainPlayer.runAction(SKAction.repeatActionForever(rightMoveAction)) 

Replay

Category: sprite Time: 2016-07-29 Views: 0
Tags: sprite

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development

search

Front-end development

Database

development tools

Open Platform

Javascript development

.NET development

cloud computing

server

Copyright (C) avrocks.com, All Rights Reserved.

processed in 0.164 (s). 12 q(s)