Swift3 - Spritekit Sprite not full size - swift3

I want to have a game over screen pop up, using SKSpriteNodes and it scales correctly on first try but from the second, the whole game over is small.
func spawnPlayAgainBTN() {
playAgain = SKSpriteNode(imageNamed: "buttonPlay")
playAgain.position = CGPoint(x: self.frame.midX + 54, y: self.frame.midY - 10)
playAgain.zPosition = 8
playAgain.setScale(0)
self.addChild(playAgain)
playAgain.run(SKAction.scale(to: 0.4, duration: 0.4))
}
func spawnMainMenuBTN() {
mainMenu = SKSpriteNode(imageNamed: "buttonMainMenu ")
mainMenu.position = CGPoint(x: self.frame.midX - 54, y: self.frame.midY - 10)
mainMenu.zPosition = 8
mainMenu.setScale(0)
self.addChild(mainMenu)
mainMenu.run(SKAction.scale(to: 1.0, duration: 0.4))
}
func spawnGameOverScreen() {
gameOverBG = SKSpriteNode(imageNamed: "gameOverBG")
gameOverBG.position = CGPoint(x: self.frame.midX, y: self.frame.midY)
gameOverBG.zPosition = 7
gameOverBG.setScale(0)
self.addChild(gameOverBG)
gameOverBG.run(SKAction.scale(to: 1.0, duration: 0.4))
spawnPlayAgainBTN()
spawnMainMenuBTN()
isRunningGame = false
isShowingGameOver = true
}

Related

Error message given: Generic parameter 'Data' could not be inferred

I have tried many things, but seem to be getting continuous error messages which I cannot remove. The code is listed below, and I have the following questions:
Where is the error? The second ForEach statement has no errors, but the first results in "Generic parameter 'Data' could not be inferred".
Why can't I use a "for" statement within this block? When I do so, I get an error message
It's strange not to define i and j upfront, but when I do so I get error messages. Why?
I would like to make the various (8) circle segments which are drawn buttons. I have found references in older Swift versions (see commented lines below), but how should I create those in SwiftUI?
Any help to this beginner would be much appreciated.
struct ContentView: View {
static let segmentCount = 4
static let circleCount = 2
var body: some View {
let r = CGFloat(75.0)
let center_x = CGFloat(150.0)
let center_y = CGFloat(150.0)
var arc_start = CGFloat(45.0 * CGFloat(Double.pi) / 180.0)
let arc_length = CGFloat(90.0 * CGFloat(Double.pi) / 180.0)
var arc_width = CGFloat(25.0)
let line0Target_x = center_x + r * CGFloat(cos(Double(arc_start)))
let line0Target_y = center_y + r * CGFloat(sin(Double(arc_start)))
let line1Target_x = center_x + (r + arc_width) * CGFloat(cos(Double(arc_start + arc_length)))
let line1Target_y = center_x + (r + arc_width) * CGFloat(sin(Double(arc_start + arc_length)))
ZStack {
ForEach(1..<ContentView.circleCount){ j in
r = CGFloat(25.0 + CGFloat((j) - 1.0) * 25.0)
ForEach(1..<ContentView.segmentCount){ i in
Path { path in
arc_start = CGFloat((45.0 + (CGFloat(i) - 1.0) * 90.0)) * CGFloat(Double.pi) / 180.0
path.move(to: CGPoint(x: line0Target_x, y: line0Target_y))
path.addArc(center: CGPoint(x: center_x, y: center_y), radius: r, startAngle: Angle(radians: Double(arc_start)), endAngle: Angle(radians: Double(arc_start + arc_length)), clockwise: false)
path.addLine(to: CGPoint(x: line1Target_x, y: line1Target_y))
path.addArc(center: CGPoint(x: center_x, y: center_y), radius: (r + arc_width), startAngle: Angle(radians: Double(arc_start + arc_length)), endAngle: Angle(radians: Double(arc_start)), clockwise: true)
path.addLine(to: CGPoint(x: line0Target_x, y: line0Target_y))
path.closeSubpath()
// let shapeLayer = CAShapeLayer()
// shapeLayer.strokeColor = UIColor.red.cgColor
// shapeLayer.fillColor = UIColor.blue.cgColor
// shapeLayer.path = path.cgPath
}
}
}
}
}
}
Your code won't compile, because you are adding lets and vars in body closure, where compiler expects some View.
You can simply move your vars inside of Path closure (or you can make some functions for computing it):
struct ContentView: View {
static let segmentCount = 4
static let circleCount = 2
var body: some View {
ZStack {
ForEach(1..<ContentView.circleCount){ j in
ForEach(1..<ContentView.segmentCount){ i in
Path { path in
let r = CGFloat(25.0 + (CGFloat(j) - 1.0) * 25.0)
let center_x = CGFloat(150.0)
let center_y = CGFloat(150.0)
var arc_start = CGFloat(45.0 * CGFloat(Double.pi) / 180.0)
let arc_length = CGFloat(90.0 * CGFloat(Double.pi) / 180.0)
var arc_width = CGFloat(25.0)
let line0Target_x = center_x + r * CGFloat(cos(Double(arc_start)))
let line0Target_y = center_y + r * CGFloat(sin(Double(arc_start)))
let line1Target_x = center_x + (r + arc_width) * CGFloat(cos(Double(arc_start + arc_length)))
let line1Target_y = center_x + (r + arc_width) * CGFloat(sin(Double(arc_start + arc_length)))
arc_start = CGFloat((45.0 + (CGFloat(i) - 1.0) * 90.0)) * CGFloat(Double.pi) / 180.0
path.move(to: CGPoint(x: line0Target_x, y: line0Target_y))
path.addArc(center: CGPoint(x: center_x, y: center_y), radius: r, startAngle: Angle(radians: Double(arc_start)), endAngle: Angle(radians: Double(arc_start + arc_length)), clockwise: false)
path.addLine(to: CGPoint(x: line1Target_x, y: line1Target_y))
path.addArc(center: CGPoint(x: center_x, y: center_y), radius: (r + arc_width), startAngle: Angle(radians: Double(arc_start + arc_length)), endAngle: Angle(radians: Double(arc_start)), clockwise: true)
path.addLine(to: CGPoint(x: line0Target_x, y: line0Target_y))
path.closeSubpath()
}
}
}
}
}
}

How to add dictionary values to images using SpriteKit?

(( EDIT 4: Successful in making cards flip. Using .contains on the node and running a SKAction sequence. How would I create three states for the card? Tuple sounds like a fun idea. Unflipped, Flipped, Flipped-Highlighted. It loads with all cards down (done), I want to unflip the card (done), then tap it again to highlight it. In doing so the second time, it highlights itself and the top guess word. The two strings are then concatenated in a label at the bottom, and a Next button activated (not built yet). Upon successful match of the key[value] == A[B] then Score += 1. Getting closer! ))
(( EDIT 3: Update of didMove with split keys and values. Can get the title to be the first key now and I can put the first value on the top left card okay as a test. Progress. Now I just need to either blank out the card on touch down or find a way to flip it. How would the touch down code be done? touch Began? ))
(( EDIT 2: Now thinking of it from the perspective of dictionary key value pairs rather than values alone. Gets rid of the problem of finding the key when the value is assigned to the card. Now to play with labelling the card with SKLabelNode. Need to flip card, add value, compare key. ))
(( EDIT: I made the elements all code in GameScene.swift . That file is now included in this post. Also updated question text and removed some other text. ))
I'm new to SpriteKit and Swift 3. With a few million speakers there's not a lot of Esperanto software so I want to make a game for myself to learn 1000 Esperanto words. (not shown!)
I want to have each card flip to reveal a word value from the dictionary key/values.
Then see if that word matches the wordGuess label key for the value selected.
Also JSON might be better for breaking up 1000 words into modular sections but I'll cross that bridge at another time.
// Code updated to EDIT 4
//
//
import SpriteKit
class GameScene: SKScene {
let guessLabel = SKLabelNode(fontNamed: "HelveticaNeue-UltraLight")
let anotherLabel = SKLabelNode(fontNamed: "HelveticaNeue-UltraLight")
var cardTopLeftLabel = SKLabelNode(fontNamed: "Arial-BoldMT")
let cardTopLeft = SKSpriteNode(imageNamed: "Redcard")
var cardTopRightLabel = SKLabelNode(fontNamed: "Arial-BoldMT")
let cardTopRight = SKSpriteNode(imageNamed: "Redcard")
var cardBottomLeftLabel = SKLabelNode(fontNamed: "Arial-BoldMT")
let cardBottomLeft = SKSpriteNode(imageNamed: "Redcard")
var cardBottomRightLabel = SKLabelNode(fontNamed: "Arial-BoldMT")
let cardBottomRight = SKSpriteNode(imageNamed: "Redcard")
var cardsDictionary: [String:String] = [
"tree": "arbo",
"forest": "arbaro",
"spider": "araneo",
"water": "akvo",
"watermelon": "akvomelono",
"school": "lerno",
"year": "jaro",
"grasshopper": "akrido",
"lawn": "gazono",
"friend": "amiko",
"people": "homoj",
"city": "urbo",
"mayor": "urbestro",
"movie": "filmo",
"Monday": "lundo",
"dog": "hundo"
]
// not used yet
func randomSequenceGenerator(min: Int, max: Int) -> () -> Int {
var numbers: [Int] = []
return {
if numbers.count == 0 {
numbers = Array(min ... max)
}
let index = Int(arc4random_uniform(UInt32(numbers.count)))
return numbers.remove(at: index)
}
}
func addLabel(spriteNode:SKSpriteNode, labelNode: SKLabelNode, cardValue: String, cardName: String) {
labelNode.zPosition = 1
labelNode.text = cardValue
labelNode.name = cardName //"cardTopRightLabel"
labelNode.fontSize = 40
labelNode.fontColor = .black
labelNode.position = CGPoint.init(x: cardTopLeft.size.width/4, y: 0.5)
labelNode.isHidden = true
spriteNode.addChild(labelNode)
}
override func didMove(to view: SKView) {
if let words = self.userData?.value(forKey: "words")
{
print("word information contains \(words)")
}
// get all the card keys
var cardKeys:[String] = []
for (k,_) in cardsDictionary {
cardKeys.append(k)
}
print("all keys are \(cardKeys)")
// slice for four card keys
var fourCardKeys = cardKeys[0...3]
print("four keys are \(fourCardKeys)")
// get keys for display
var firstCardKey = fourCardKeys[0]
var secondCardKey = fourCardKeys[1]
var thirdCardKey = fourCardKeys[2]
var fourthCardKey = fourCardKeys[3]
// print("Card Keys are \(firstCardKey), \(secondCardKey), \(thirdCardKey), \(fourthCardKey)")
// get the card values
var cardsValue:[String] = []
for (_,v) in cardsDictionary {
cardsValue.append(v)
}
print(cardsValue)
// slice for card values
let fourCardValues = cardsValue[0...3]
print(fourCardValues)
// get values for display
let firstCardValue = fourCardValues[0]
let secondCardValue = fourCardValues[1]
let thirdCardValue = fourCardValues[2]
let fourthCardValue = fourCardValues[3]
print("Card Values are \(firstCardValue), \(secondCardValue), \(thirdCardValue), \(fourthCardValue)")
// put first card key into label
guessLabel.zPosition = 1
guessLabel.text = firstCardKey //cardKeys[0]
guessLabel.name = "guessLabel"
guessLabel.fontSize = 144;
guessLabel.fontColor = .black
//anotherLabel.position = CGPoint(x:frame.midX, y:frame.midY - 100.0)
guessLabel.position = CGPoint(x:-2, y:233)
addChild(guessLabel)
anotherLabel.zPosition = 0
anotherLabel.text = "Guess key here, values in cards"
anotherLabel.name = "anotherLabel"
anotherLabel.fontSize = 45;
anotherLabel.fontColor = .blue
//anotherLabel.position = CGPoint(x:frame.midX, y:frame.midY - 100.0)
anotherLabel.position = CGPoint(x:-2, y:203)
addChild(anotherLabel)
////////////////
// top left card
cardTopLeft.zPosition = 0
cardTopLeft.size = CGSize(width: 300.0, height: 300.0)
cardTopLeft.anchorPoint = CGPoint(x: 0.5, y: 0.5)
cardTopLeft.position = CGPoint(x:-229, y:-57)
addChild(cardTopLeft)
addLabel(spriteNode: cardTopLeft,
labelNode: cardTopLeftLabel,
cardValue: firstCardValue,
cardName: "cardTopLeftLabel")
/////////////////
// top right card
cardTopRight.zPosition = 1
cardTopRight.size = CGSize(width: 300.0, height: 300.0)
cardTopRight.anchorPoint = CGPoint(x: 0.5, y: 0.5)
cardTopRight.position = CGPoint(x:132, y:-57)
addChild(cardTopRight)
addLabel(spriteNode: cardTopRight,
labelNode: cardTopRightLabel,
cardValue: secondCardValue,
cardName: "cardTopRightLabel")
///////////////////
// bottom left card
cardBottomLeft.zPosition = 1
cardBottomLeft.size = CGSize(width: 300.0, height: 300.0)
cardBottomLeft.anchorPoint = CGPoint(x: 0.5, y: 0.5)
cardBottomLeft.position = CGPoint(x:-225, y:-365)
addChild(cardBottomLeft)
addLabel(spriteNode: cardBottomLeft,
labelNode: cardBottomLeftLabel,
cardValue: thirdCardValue,
cardName: "cardBottomLeftLabel")
////////////////////
// bottom right card
cardBottomRight.zPosition = 1
cardBottomRight.size = CGSize(width: 300.0, height: 300.0)
cardBottomRight.anchorPoint = CGPoint(x: 0.5, y: 0.5)
cardBottomRight.position = CGPoint(x:132, y:-365)
addChild(cardBottomRight)
addLabel(spriteNode: cardBottomRight,
labelNode: cardBottomRightLabel,
cardValue: fourthCardValue,
cardName: "cardBottomRightLabel")
}
func touchDown(atPoint pos : CGPoint)
{
}
func touchMoved(toPoint pos : CGPoint) {
}
func touchUp(atPoint pos : CGPoint) {
}
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
guard let touch = touches.first else {
return
}
let touchLocation = touch.location(in: self)
let touchedNode = self.atPoint(touchLocation)
func flipCard (node: SKNode, label: SKLabelNode)
{
label.isHidden = true
node.run(SKAction.sequence(
[SKAction.scaleX(to: 0, duration: 0.2),
SKAction.scale(to: 1, duration: 0.0),
SKAction.setTexture(SKTexture(imageNamed: "Redcard-blank"))
]
))
label.isHidden = false
}
func flipCardPause (node: SKNode, interval: Double)
{
node.run(SKAction.wait(forDuration: interval))
print("paused for \(interval) seconds")
}
func flipCardBack (node: SKNode, label: SKLabelNode)
{
label.isHidden = true
node.run(SKAction.sequence(
[SKAction.scaleX(to: 1, duration: 0.2),
SKAction.setTexture(SKTexture(imageNamed: "Redcard"))
// SKAction.scale(to: 1, duration: 0.2)
]
))
}
if cardTopLeft.contains(touchLocation)
{
flipCard(node: cardTopLeft, label: cardTopLeftLabel)
//flipCardPause(node: cardTopLeft, interval: 3)
//flipCardBack(node: cardTopLeft, label: cardTopLeftLabel)
}
if cardTopRight.contains(touchLocation)
{
flipCard(node: cardTopRight, label: cardTopRightLabel)
}
if cardBottomLeft.contains(touchLocation)
{
flipCard(node: cardBottomLeft, label: cardBottomLeftLabel)
}
if cardBottomRight.contains(touchLocation)
{
flipCard(node: cardBottomRight, label: cardBottomRightLabel)
}
for t in touches { self.touchDown(atPoint: t.location(in: self)) }
}
How to assign dictionary values to the cards?. EDIT 2: By not using values! I'm going to do from the perspective of dictionary keys, that way each card has a key value pair, then just display the value.
// get all the card keys
var cardKeys:[String] = []
for (k,_) in cardsDictionary {
cardKeys.append(k)
}
// slice for only four cards
var fourCardKeys = cardKeys[0...3]
// get 1st value for display
cardsDictionary[fourCardKeys[0]]
So SKLabelNode on touchDown? I'll try it. Also need to flip card so word is not on the image. Lastly compare the pressed card's key to the wordGuess key text. Getting closer
EDIT 3: Update of didMove with split keys and values. Can get the title to be the first key now and I can put the first value on the top left card okay as a test. Progress. Now I just need to either blank out the card on touchDown or find a way to flip it.
cardTopLeft.zPosition = 0
cardTopLeft.size = CGSize(width: 300.0, height: 300.0)
cardTopLeft.anchorPoint = CGPoint(x: 0.5, y: 0.5)
cardTopLeft.position = CGPoint(x:-229, y:-57)
addChild(cardTopLeft)
cardTopLeftLabel.zPosition = 1
cardTopLeftLabel.text = fourCardValues[0]
cardTopLeftLabel.name = "cardTopLeftLabel"
cardTopLeftLabel.fontSize = 40
cardTopLeftLabel.fontColor = .black
cardTopLeftLabel.position = CGPoint.init(x: cardTopLeft.size.width/4, y: 0.5)
cardTopLeft.addChild(cardTopLeftLabel)
EDIT 4: Successful in making cards flip. Using .contains on the node and running a SKAction sequence. How would I create three states for the card? Tuple sounds like a fun idea. Unflipped, Flipped, Flipped-Highlighted. It loads with all cards down (done), I want to unflip the card (done), then tap it again to highlight it (help?). In doing so the second time, it highlights itself and the top guess word. The two strings are then concatenated in a label at the bottom, and a Next button activated (not built yet). Upon successful match of the key[value] == A[B] then Score += 1. Getting closer! It's really similar to just a matching game but I'm adding an extra layer of card flipping.
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
guard let touch = touches.first else {
return
}
let touchLocation = touch.location(in: self)
let touchedNode = self.atPoint(touchLocation)
func flipCard (node: SKNode, label: SKLabelNode)
{
label.isHidden = true
node.run(SKAction.sequence(
[SKAction.scaleX(to: 0, duration: 0.2),
SKAction.scale(to: 1, duration: 0.0),
SKAction.setTexture(SKTexture(imageNamed: "Redcard-blank"))
]
))
label.isHidden = false
}
Personally, I don't like to use userData, my opinion is that isn't a readable code.
I'd some like to create a custom SKNode like:
class Card: SKSpriteNode {
var value....
var dictionary
etc
}
Another solution, you can create a tuples:
var cardsDictionary: [String:String] = [
"vegetable":"legomo",
"plant":"vegetalo",
"actually":"efektive",
"currently":"aktuale"
]
let cardTopLeft = (node:SKNode, value:Int, type:[String:String])
cardTopLeft.node = SKSpriteNode(imageNamed: "Redcard")
cardTopLeft.value = 1
cardTopLeft.type = cardsDictionary[0]
All SKNodes have a dictionary you can write to called userData. It is an optional NSMutableDictionary, so you are going to have to create it:
cardTopLeft.zPosition = 1
cardTopLeft.size = CGSize(width: 300.0, height: 300.0)
cardTopLeft.anchorPoint = CGPoint(x: 0.5, y: 0.5)
cardTopLeft.position = CGPoint(x:-229, y:-57)
cardTopLeft.userData = ["word":"tree","value","arbo"]
addChild(cardTopLeft)
To use:
let word = cardTopLeft.userData["word"]
let value = cardTopLeft.userData["value"]
Getting a better understanding of your question, I would use SKLabelNode as an alternative.
What you can do is create SKLabelNodes to the cards with the word you want to attach, and mark it as isHidden = true. When you are ready to reveal the word, you just mark isHidden = false
let value = SKLabelNode("arbo")
value.isHidden = false
cardTopLeft.zPosition = 1
cardTopLeft.size = CGSize(width: 300.0, height: 300.0)
cardTopLeft.anchorPoint = CGPoint(x: 0.5, y: 0.5)
cardTopLeft.position = CGPoint(x:-229, y:-57)
cardTopLeft.addChild(value)
addChild(cardTopLeft)
//to reveal it
if let label = cardTopLeft.children[0] as? SKLabelNode
{
label.isHidden = false
}
//to use it
if let label = cardTopLeft.children[0] as? SKLabelNode
{
let value = label.text
//compare value to dictionary of answers
}
You may want to give your labels a name so that you do not have to use children[0], but I will leave how you want to find a node up to you.

CAShapeLayer dashed line clipping at end of view

Okay so I'm trying to draw a dashed line inside of a view, which should be fairly simple but no matter what I've tried I keep getting the dashes at both ends clipping and I would like to have the dash not have any clipped segments. Here's the extension I made (the purple background color is just there so I can see the frame)
extension UIView {
public func addDashedLineToView(_ color : UIColor) {
self.backgroundColor = UIColor.purple
let cgColor = color.cgColor
let shapeLayer: CAShapeLayer = CAShapeLayer()
let frameSize = self.frame.size
let shapeRect = CGRect(x: 0, y: 0, width: frameSize.width, height: frameSize.height)
shapeLayer.bounds = shapeRect
shapeLayer.position = CGPoint(x: frameSize.width / 2, y: frameSize.height)
shapeLayer.fillColor = UIColor.clear.cgColor
shapeLayer.strokeColor = cgColor
shapeLayer.lineWidth = 6
shapeLayer.lineCap = kCALineCapRound
shapeLayer.lineJoin = kCALineJoinRound
shapeLayer.lineDashPattern = [8, 10]
let path: CGMutablePath = CGMutablePath()
path.move(to: .zero)
path.addLine(to: CGPoint(x: self.frame.width, y: 0))
shapeLayer.path = path
self.layer.addSublayer(shapeLayer)
self.layer.masksToBounds = true
}
and here's a screenshot of what it ends up looking like.
not sure where I'm messing up here, but I know that I must be doing something wrong since it shouldn't be this hard to draw a dashed line in swift (I hope).
You can adjust the start position of the pattern with lineDashPhase. Try
shapeLayer.lineDashPhase = -4

Why is friction not applied when two nodes come into contact? Swift

This is the code I have for the two nodes. Declarations not included.
//paddle node and its physicsbody
paddle = childNode(withName: "paddle") as! SKSpriteNode
paddle.physicsBody = SKPhysicsBody(rectangleOf: CGSize(width: paddle.size.width,
height: paddle.size.height))
paddle.physicsBody?.isDynamic = false
paddle.physicsBody?.affectedByGravity = false;
paddle.physicsBody?.friction = 100
paddle.physicsBody?.restitution = 0
//paddle.physicsBody?.linearDamping = 1
//paddle.physicsBody?.angularDamping = 1
//Second node
rect.position = CGPoint(x: 100, y:500)
rect.fillColor = UIColor(hue: 215/360, saturation: 49/100, brightness: 54/100, alpha: 1.0)
rect.strokeColor = UIColor(hue: 215/360, saturation: 49/100, brightness: 54/100, alpha: 1.0)
rect.physicsBody = SKPhysicsBody(rectangleOf: CGSize(width: rect.frame.width, height: rect.frame.height))
rect.physicsBody?.friction = 0.4
rect.physicsBody?.restitution = 0
rect.physicsBody?.mass = 100
rect.physicsBody?.allowsRotation = true
rect.physicsBody?.isDynamic = true
rect.physicsBody?.linearDamping = 0
rect.physicsBody?.angularDamping = 0
//rect.physicsBody?.velocity = CGVector(dx: 0, dy: -700)
rect.physicsBody!.applyImpulse(CGVector(dx: 2.0, dy: -2.0))
rect.lineWidth = 10
addChild(rect)
I am not sure if I am asking the right question but I have the rectangular node falling down unto a paddle that can be moved side to side by touch. Once the rect node is on top of the paddle I want it to stay on it while the I move the paddle but it stays pinned and does not move although everything else (gravity, rotation, etc.) works.
Here are the pictures to clarify
https://i.stack.imgur.com/LIqYT.png
https://i.stack.imgur.com/ap6Yy.png

Swift animatewithDuration() instantly completes

So, I have this code:
UIView.animate(withDuration: 10.0, delay: 0, options: .curveLinear , animations: {
self.gameLabel.alpha = 0
}, completion: nil)
The problem is when this code is called it instantly goes to a 0 alpha and doesn't slowly transition. What am I doing wrong?
Here is some more context for the the code:
var gameLabel = SKLabelNode()
override func didMove(to view: SKView) {
gameLabel.fontColor = UIColor.white
gameLabel.fontSize = 85
gameLabel.setScale(0.40)
gameLabel.text = "this is a game"
gameLabel.position = CGPoint(x: 0, y: 0)
gameLabel.zPosition = 0
gameLabel.alpha = 1
addChild(gameLabel)
}
func touchDown(atPoint pos : CGPoint) {
UIView.animate(withDuration: 2, animations: {
self.gameLabel.alpha = 0
})
}
So, i solved my problem by running.
self.gameLabel.run(SKAction.fadeOut(withDuration: 10))