所以我看过关于Obj中随机和arc4random之间差异的旧帖子.C,我已经在网上看到了这个答案,但我并没有真正理解答案,所以我希望有人可以用更容易理解的方式解释它.
使用random和arc4random生成随机数有什么区别?
我正在尝试制作一个存储整数值的NSUserDefault变量,这是我现在的代码.
NSUserDefaults.standardUserDefaults().setObject(0, forKey: "HighScore")
Run Code Online (Sandbox Code Playgroud)
当我输入一个数字作为原始值时,它将其标识为UInt8而不仅仅是Int.我该如何改变?
谢谢,布伦南
skView.ignoreSiblingOrder = true初始化场景时,它有多重要/有效?
现在,我把它设置为true,但出于某种原因,当我从MainMenu场景开始我的GameScene时,它会在我的角色之前加载背景(即使背景的代码是第一个),但是一旦我死了它就会修复并返回到主菜单然后加载另一个游戏场景.为了避免这个问题,我制作了一个布尔值,它基本上可以检测我何时玩过多个游戏.它现在功能但非常难看,我确信有更好的方法.
代码:(在touchesBegan)
let skView = self.view as SKView!
skView.showsFPS = true
skView.showsNodeCount = true
if spriteNode.name == "StartButton"
{
/* Sprite Kit applies additional optimizations to improve rendering performance */
//sets ignoreSiblingOrder to false the first game because of XCode Glitch where background was rendering over player for some reason
skView.ignoresSiblingOrder = false
if(Game){
skView.ignoresSiblingOrder = true
}
if let scene = GameScene.unarchiveFromFile("GameScene") as? GameScene
{
skView.presentScene(scene)
/* Set the scale mode to scale to fit …Run Code Online (Sandbox Code Playgroud)