【发布时间】:2018-07-28 10:49:39
【问题描述】:
我尝试将图像添加到我的游戏场景中,但它不会出现。下面是我的代码。希望大家帮帮我
import SpriteKit
import GameplayKit
class GameScene: SKScene {
var Ground = SKSpriteNode()
var iceCream = SKSpriteNode()
override func didMove(to view: SKView) {
Ground = SKSpriteNode(imageNamed: "background")
Ground.setScale(0.5)
Ground.position = CGPoint(x: self.frame.width / 2, y: self.Ground.frame.height / 2)
self.addChild(Ground)
iceCream = SKSpriteNode(imageNamed: "VanillaIceCream")
iceCream.size = CGSize(width: 60, height: 70)
iceCream.position = CGPoint(x: self.iceCream.frame.width, y: self.frame.height / 2)
self.addChild(iceCream)
}
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
}
override func update(_ currentTime: CFTimeInterval) {
}
}
【问题讨论】:
-
您的代码正在编译并且工作正常,您是否看到任何带有“X”的图像?
-
没有。它没有出现在我的模拟器上
-
图片不显示。我不知道出了什么问题
标签: swift sprite-kit skspritenode addchild