ios - 在 Xcode 中设置自定义类适用于 iOS 9.1 模拟器,但不适用于 iOS 8.4

标签 ios xcode sprite-kit xcode7 ios8.4

我制作了一个游戏,我需要将触摸的 SKSpriteNode 转换为自定义类。它在 iOS 9.1 模拟器上运行良好,但在 iOS 8.4 模拟器中似乎根本无法转换。

在 iOS 9.1 中,我的类是 MyCustomClass 类型,但在 iOS 8.4 中,它是 SKSpriteNode。没有其他任何改变,只有模拟器操作系统。

我在 SpriteKit GameScene 中的 Xcode 中直接设置了自定义类(我单击节点并使用右侧选项卡在“自定义类”部分输入“MyCustomClass”)。我尝试在“Project.MyCustomClass”中添加项目名称,但这没有效果。
How I set my custom class in Spritekit Scene

如果您有解决方案,我很想知道!

if self.nodeAtPoint(location).isKindOfClass(MyCustomClass) {
    print("Is my class") //This is the result in iOS 9.1
}else if self.nodeAtPoint(location).isKindOfClass(SKSpriteNode){
    print("Is an SKSPriteNode") //This is the result in iOS 8.4
}else if self.nodeAtPoint(location).isKindOfClass(SKNode) {
    print("Is an SKNode")
}

if let touchedNode = self.nodeAtPoint(location) as? Objet {
    //Fails on iOS 8.4 but succeed in iOS 9.1
}

谢谢你的时间。

PS:我使用的是 Xcode 7.1.1。

最佳答案

可悲的是,自定义类(或子类)根本无法在 iOS 8.4 上运行。

我不得不重写我的逻辑。

无论如何,感谢您的帮助。

关于ios - 在 Xcode 中设置自定义类适用于 iOS 9.1 模拟器,但不适用于 iOS 8.4,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33760450/

相关文章:

swift - 如果我单击 "touches began",则更改 SKSpriteNode 的颜色返回我单击的颜色

cocoa - Xcode : Garbage Collector Setting

ios - 如何杀死多次点击的 Sprite ?

ios - 从 GameScene 到 viewController Swift 3

objective-c - 无法在 View 中设置标签

objective-c - 如何在 obj c 的 sqlite3 中插入​​、更新、删除和选择数据到数据库中?

iphone - iOS - 将变量传递给 View Controller

ios - 如何限制 MapKit 中 Apple map 特定区域的平移和缩小?

ios 二进制 .app 文件不可点击

swift - 如何在 SpriteKit Swift 中设置重心到屏幕中心