So I have a simple card game which has a deal function. When called it takes the top 10 cards from the deck and moves them to top the top of the 10 piles with a nice SKAction move action. I also have a pause function, which removes all the cards from the game and puts a dark gray overlay over the board, and then when called again it replaces the cards. the cards are a subclass of SKSpriteNode. the deal function works fine normally, but if I pause and then unpause the game, it no longer works. The code before and after the card.runAction(move) is excecuted, but the cards don't move.
my deal function (simplified)
func deal {
for i in 0...9
{
x = cards.indexOf(topOfDeck!)! - i
cards[x].column = i
cards[x].row = topCardsOrdered[i].row + 1
let move = SKAction.moveTo(CGPoint(x:topCardsOrdered[i].position.x, y: topCardsOrdered[i].position.y - verticalSpacingFaceUp[i]), duration: 0.2)
cards[x].runAction(move, withKey: "dealAction")
}
}
my pause function
func pause() {
if container.paused == false
{
container.paused = true
self.addChild(grayFilter)
for i in 0...103
{
cards[i].removeFromParent()
}
}
else
{
container.paused = false
grayFilter.removeFromParent()
for i in 0...103
{
container.addChild(cards[i])
}
let move = SKAction.moveTo(CGPoint(x: 0, y: 0), duration: 1)
cards[10].runAction(move)
}
}
I thought maybe there was a problem with the action finding the correct position, but I put a simple action to rotate the node in its place, and just like the move action that was only run if the game hadn't been paused yet. I have checked and all of the properties of each card are the same before and after the pause, and the rest of the game works as it should after being unpaused, so after two days of troubleshooting this I am lost.