2

在我的应用程序中,我想StylekitSKScene.

这是我的代码:

import SpriteKit
import GameplayKit

class GameScene: SKScene {

  override init(size: CGSize) {
    super.init(size: size)     
    StyleKit.drawCanvas1()
  }

  required init?(coder aDecoder: NSCoder) {
    fatalError("init(coder:) has not been implemented")
  }

  override func didMove(to view: SKView) {
  }
}

我该如何解决这个问题?

4

1 回答 1

0

你可以SKSpriteNode这样构建:

func makeCircle(width:CGFloat = 200, height:CGFloat = 200) -> SKSpriteNode? {
  let size = CGSize(width: width, height: height)
  UIGraphicsBeginImageContextWithOptions(size, false, 0)
  StyleKit.drawCircle(frame: CGRect(origin: .zero, size: size), resizing: .AspectFit)
  let image = UIGraphicsGetImageFromCurrentImageContext()
  UIGraphicsEndImageContext()
  if let safeImage = image {
    return SKSpriteNode(texture: SKTexture(image: safeImage))
  } else {
    return nil
  }
}
于 2017-12-18T15:35:55.543 回答