Lets say I have five dice like so:
When I tap, Id like the die face with one dot to replace the one with two dots and (moving the 1 die across the row while moving the other die down the row) and if the last die is at the end, get it to replace the first die in the row. Would replacing the SKTextures have something to do with this? Thank you in advance.
Edit:
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
for touch: AnyObject in touches {
let touchLocation = touch.locationInNode(self)
let touchedNode = self.nodeAtPoint(touchLocation)
let texRight = SKAction.setTexture(SKTexture(imageNamed: "DieFace1"))
DieFace2.runAction(texRight)
}
}
Edit 2:
import SpriteKit
var arrayOfDieFaces = [onE, twO, threE, fouR, fivE]
class GameScene: SKScene {
}
func replace() {
var count = 1
while count <= 5 {
let changeTexture = SKAction.setTexture(SKTexture(imageNamed: "Dice\(count)"))
if count == 5 {
arrayOfDieFaces[0].runAction(changeTexture)
}
else{
arrayOfDieFaces[count].runAction(changeTexture)
}
count += 1
}
arrayOfDieFaces.append(arrayOfDieFaces[0])
arrayOfDieFaces.dropFirst()
}
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
for touch: AnyObject in touches {
let touchLocation = touch.locationInNode(self)
let touchedNode = self.nodeAtPoint(touchLocation)
replace()
}
}