タップすると、サイコロの面が 1 つのドットに置き換えられ、1 つのドットが 2 つのドットに置き換えられます (1 つのダイスを行を横切って移動し、もう 1 つのダイスを行の下に移動します)。最後のダイスが最後にある場合は、それを取得します。行の最初のダイスを交換します。SKTextures を置き換えることはこれと関係がありますか? 前もって感謝します。
編集:
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)
}
}
編集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()
}
}