Cannot convert value of type ‘SKScene.Type’ to expected argument type ‘SKScene’

I am getting this, “Cannot convert value of type ‘SKScene.Type’ to expected argument type ‘SKScene'”

 

this is my code for the problem

self.scene?.addChild(itemController.spawnItems(scene: SKScene));

 

 

This is my whole code.

/
/
/
/
/
/
/ 
import SpriteKit
class GameplaySceneClass: SKScene {
   
    private var Player: Player?;
   
    private var center = CGFloat();
   
    private var canMove = false
    private var moveLeft = false
   
    private var itemController = ItemController();
   
   
    override func didMove(to view: SKView) {
        initializeGame();
       
    }
   
   
    override func update(_ currentTime: TimeInterval) {
        managePlayer();
    }
   
   
   
   
   
   
   
   
    private func initializeGame() {
        Player = childNode(withName: "Player") as? Player!;
       
        center = self.frame.size.width / self.frame.size.height;
       
        Timer.scheduledTimer(timeInterval: TimeInterval(itemController.randomBetweenNumbers(firstNum: 1, secondNum: 2)), target: (Any).self, selector: #selector(GameplaySceneClass.spawnItems), userInfo: nil, repeats: true)
    }
   
    override func touchesBegan(_ touches: Set, with event: UIEvent?) {
       
        for touch in touches {
            let location = touch.location(in: self);
           
            if location.x > center {
                moveLeft = false;
            } else {
                moveLeft = true;
            }
        }
        canMove = true;
    }
   
    override func touchesMoved(_ touches: Set, with event: UIEvent?) {
        canMove = false;
    }
   
   
    private func managePlayer() {
        if canMove {
            Player?.move(left: moveLeft);
        }
    }
   
    @objc func spawnItems() {
        self.scene?.addChild(itemController.spawnItems(scene: SKScene));
    }
   
} /

Powered by WPeMatico

About

You may also like...

Comments are closed.