没有gamescene.sks文件的SpriteKit

时间:2018-09-17 10:27:35

标签: ios

一个SpriteKit查询:请有人帮忙吗?我看不到为什么没有显示我的gamecene.swift。

import UIKit
import SpriteKit

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        var newview = SKView()
        view.addSubview(newview)
        let  gamescene = GameScene(size: CGSize(width: view.bounds.width, height: view.bounds.height))

    newview.frame = self.view.frame
       // Present the scene
        newview.presentScene(gamescene)
    }
}

游戏场景只是

import UIKit
import SpriteKit

class GameScene: SKScene {
override func didMove(to view: SKView) {
    self.backgroundColor = .green
    let sprite = SKSpriteNode(color: .red, size: CGSize(width: 100, height: 100))
    sprite.position = CGPoint(x: 100, y: 100)
    addChild(sprite)
        }

}

0 个答案:

没有答案