- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我有一个 Sprite Kit 游戏,当游戏结束时它崩溃了。这发生在 tvOS 9.1 和 iOS 9.2 上。之前,我让它在 iOS 9.1 上运行而没有崩溃。
这似乎是一个 OpenGL 问题,但是当我在 Xcode 中搜索该函数时,它没有给出任何结果。
不幸的是,错误在控制台中的显示并不一致。这是错误:
Jet: draw_indexed: indexType must be 'unsigned_int' or 'unsigned_short'
Assertion failed: (indexType == jet_component_type_unsigned_int || indexType
== jet_component_type_unsigned_short), function draw_indexed, file
/BuildRoot/Library/Caches/com.apple.xbs/Sources/Jet_Sim/Jet-
1.50.1/Jet/jet_context_OpenGL.mm, line 1426.
Xcode 在崩溃时也会指向 AppDelate 类:
AppDelegate 类:UIResponder,UIApplicationDelegate
启用断点异常后,Xcode 指向这一行。它是声音文件的常量:
let soundHitLava = SKAction.playSoundFileNamed("DrownFireBug.mp3",
waitForCompletion: false)
来自异常断点的更多信息:
SpriteKit`+[SKAction(SKActions) playSoundFileNamed:waitForCompletion:]:
0x10b95e738 <+0>: pushq %rbp
0x10b95e739 <+1>: movq %rsp, %rbp
0x10b95e73c <+4>: movq 0x15bf8d(%rip), %rdi ; (void *)0x000000010babd020: SKPlaySound
0x10b95e743 <+11>: movq 0x1618b6(%rip), %rax ; (void *)0x000000010b412be8: CGPointZero
0x10b95e74a <+18>: movsd (%rax), %xmm0
0x10b95e74e <+22>: movsd 0x8(%rax), %xmm1
0x10b95e753 <+27>: movq 0x159a46(%rip), %rsi ; "playSoundFileNamed:atPosition:waitForCompletion:"
0x10b95e75a <+34>: movzbl %cl, %ecx
0x10b95e75d <+37>: callq *0x1619a5(%rip) ; (void *)0x000000010d09e800: objc_msgSend
0x10b95e763 <+43>: movq %rax, %rdi
0x10b95e766 <+46>: callq 0x10ba192e8 ; symbol stub for: objc_retainAutoreleasedReturnValue
0x10b95e76b <+51>: movq %rax, %rdi // **Thread 1: Breakpoint 1.2
0x10b95e76e <+54>: popq %rbp
0x10b95e76f <+55>: jmp 0x10ba1929a ; symbol stub for: objc_autoreleaseReturnValue
这是 GameScene 中的 GameOver 函数:
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
#if os(tvOS) // tvOS
if startTouchX == 0.0 {
startTouchX = (touches.first?.locationInNode(self).x)!
}
#endif
switch gameState.currentState {
case is WaitingForTap:
gameState.enterState(WaitingForBomb)
// Switch to playing state
self.runAction(SKAction.waitForDuration(2.0),
completion:{
self.gameState.enterState(Playing)
})
case is GameOver:
let newScene = GameScene(fileNamed:"GameScene")
newScene!.scaleMode = .AspectFill
let reveal = SKTransition.flipHorizontalWithDuration(0.5)
self.view?.presentScene(newScene!, transition: reveal)
self.saveHighScore("com.prismstudios.jumpingcarl.leaderboard", score: GameState.sharedInstance.highScore)
GameState.sharedInstance.highScore = 0
GameState.sharedInstance.coins = 0
default:
break
}
}
这是 GameOver 类:
import SpriteKit
import GameplayKit
class GameOver: GKState {
unowned let scene: GameScene
init(scene: SKScene) {
self.scene = scene as! GameScene
super.init()
}
override func didEnterWithPreviousState(previousState: GKState?) {
if previousState is Playing {
scene.playBackgroundMusic("SpaceGame.caf")
let gameOver = SKSpriteNode(imageNamed: "GameOver")
gameOver.position = scene.getCameraPosition()
gameOver.zPosition = 10
scene.addChild(gameOver)
let explosion = scene.explosion(6.0)
explosion.position = gameOver.position
explosion.zPosition = 11
scene.addChild(explosion)
scene.runAction(scene.soundExplosions[3])
scene.screenShakeByAmt(200)
scene.addChild(button)
}
}
override func isValidNextState(stateClass: AnyClass) -> Bool {
return stateClass is WaitingForTap.Type
}
}
最佳答案
我找到的答案是降低 SKEmitterNode 的出生率和粒子发射率,因为这会导致游戏崩溃。
在 GameScene.swift 中:
func explosion(intensity: CGFloat) -> SKEmitterNode {
let emitter = SKEmitterNode()
let particleTexture = SKTexture(imageNamed: "spark")
emitter.zPosition = 2
emitter.particleTexture = particleTexture
//LOWER the particleBirthRate and numParticlesToEmit
emitter.particleBirthRate = 50; //4000 * intensity
emitter.numParticlesToEmit = 50; //Int(400 * intensity)
....
}
一旦分别降低到 50,游戏就不会崩溃。我不知道为什么会这样,但 Apple 目前正在处理这个问题,并且被认为是一个错误。
关于swift - Sprite Kit 游戏在 tvOS 9.1 和 iOS 9.2 上的游戏结束时崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34378530/
两部分问题: 首先,Apple TV 是否在 sleep 时在后台运行应用程序事件?我认为情况会是这样,因为 Apple TV 不依赖电池。 其次,如果不是这种情况,我将如何覆盖它以保持应用程序运行并
当我们在 tvOS 应用商店浏览应用程序并选择一个应用程序时,应用程序商店将显示一个主题图像作为所选应用程序的背景,我在 Xcode tvOS 项目中玩,但找不到可以为我的 tvOS 设置这样背景的地
我试图覆盖在 tvOS 上进行焦点更改时播放的声音,但我似乎找不到任何表明这是否可能的信息。我稍微浏览了一下 Apple 文档,并查看了一些声音 API,但似乎都不合适。有人知道这是否可能吗?如果可能
我收到以下错误: ERROR ITMS-90528: "Invalid Image Asset. The image asset 'App Icon - Small' in 'Payload/Proj
当我们接收到触摸时,即使我们按下触摸屏的右下角,触摸也会从触摸屏的中心开始(x 960 y 540)。 我们如何在远程触摸面板上获取绝对按下位置 - 左上角为 0 0,右下角为 1920 x 1080
与 UIButton , tvOS 产生 UIControlEvents.PrimaryActionTriggered (不是 .TouchUpInside ,就像在 iOS 上那样)当按钮获得焦点并
由于 tvOS 中不提供 UIDatePicker,所以向用户询问日期/时间有什么用?是否有一个新的类来代替 UIDatePicker ? 谢谢 最佳答案 由于 Apple 没有为 tvOS 提供日期
我知道,SwiftUI 目前处于测试阶段,但我想确保正确使用 focusable。 实际上,当我在列表中向下滚动时,焦点项目会在列表向下滚动时跳过 3 或 4 行(向上滚动方向即可)。 您可以在 b4
我已经设置并显示了一个基本的 MenuBarTemplate。 如何对用户的菜单选择使用react并加载适当的内容模板? 最佳答案 在 menuItem标签包括 template属性指向要加载的模板和
如果我通过蓝牙将 Siri Remote 连接到 MacBook,然后运行 tvOS 模拟器,它会检测运动事件吗? 最佳答案 是的,来自 Siri Remote 加速计的运动事件可用于模拟器。 但
我没有新的 Apple TV,但正在使用模拟器为其制作游戏原型(prototype)。不幸的是,正如 tvOS 文档所示,我似乎无法让 GCController 将 Siri Remote 列为可用
对于 Apple TVOS,使用 TVML 比自定义应用程序(基于媒体的应用程序而不是游戏)有什么优势吗?从我从苹果文档中读到的内容来看,我无法找出任何这样的优势(尽管它主要谈论 TVML/TVJ)。
我最近开始使用 TVML/TVJS,但不确定如何继续处理以下问题。 当前的问题是在渲染页面时在同一页面上使用多个模板,即我想在 ListTemplate 上添加 MenuBarTemplate 等。
关闭。这个问题不满足Stack Overflow guidelines .它目前不接受答案。 想改善这个问题吗?更新问题,使其成为 on-topic对于堆栈溢出。 9 个月前关闭。 Improve t
是否可以在 tvOS 应用程序中同时使用 native View / Controller 和 TVML?似乎使用 TVML 需要您设置一个“应用程序 Controller ”而不是普通的 View
是否可以在 tvOS 应用程序中同时使用 native View / Controller 和 TVML?似乎使用 TVML 需要您设置一个“应用程序 Controller ”而不是普通的 View
iOS 企业应用程序能够使用 list 文件在网络上分发。 tvOS 可以以类似的方式分发吗?我知道 tvOS 没有网络浏览器,但我想知道是否有办法将文件空投到 Apple TV 上以安装内部 tvO
我正在尝试通过 iTunes Connect 提交 tvOS 应用程序,每次我尝试时都会收到以下消息: Invalid Toolchain. New apps and app updates must
游戏 Controller 按钮B默认情况下,退出应用程序并导航回 tvOS 主屏幕。起初我认为这很直观,但很快意识到这就是 Nimbus MENU 按钮( Controller 的中间部分)的用途,
我有一个包含 2 个目标的 Xcode 项目:一个用于 iOS,一个用于 tvOS。我正在使用以下命令行命令来构建它: xcodebuild -workspace "/Users/xxx/Code/p
我是一名优秀的程序员,十分优秀!