How to use SKSpriteNode when declaring functions in spritekit (Swift)
This is my first game using SpriteKit so bear with this question. I am trying to create a function for my blackjack game where I distribute two cards, each for the player. Here is the function:
func distribution(card: SKSpriteNode, x_position: CGFloat, y_position: CGFloat) {
let card = SKSpriteNode(imageNamed: cards[0])
card.setScale(0.1)
card.position = CGPoint(x: x_position, y: y_position)
card.zPosition = 2
self.addChild(card)
cards.remove(at: 0)
}
distribution(card: player_card_1 , x_position: self.size.width/2 + self.size.width/5 - self.size.width/12, y_position: self.size.height/3)
distribution(card: player_card_2, x_position: self.size.width/4 + self.size.width/12, y_position: self.size.height/3)
the variable cards is already a predefined array with the cards However, by doing this, it is giving me errors: Cannot find 'player_card_1' and 'player_card_2' in scope.
And I didn't predefine player_card_1 and player_card_2, just defined it when I called the distribution function
from Recent Questions - Stack Overflow https://ift.tt/3wZ3vLl
https://ift.tt/eA8V8J
Comments
Post a Comment