问题描述
(适用于 XCode 6 和 iOS 8 beta 4)
(this is for XCode 6 and iOS 8 beta 4)
喜欢新的 SceneKit 编辑器.我已成功将 .sks 文件中的场景加载到自定义 SKScene 类中.但是,其中的对象被实例化为默认类(SKNode、SKSpriteNode 等),我不确定如何将它们绑定为实例化为自定义子类.
Love the new SceneKit editor. I'm successfully loading the scene from .sks file into a custom SKScene class. However, objects inside it are instantiated as default classes (SKNode, SKSpriteNode, etc), and i'm not sure how to bind them to be instantiated as custom subclasses instead.
目前,我正在通过创建自定义类并将精灵节点作为属性链接来解决这个问题,并且工作正常
Currently, I'm getting around that by creating custom classes and linking to sprite nodes as a property, and that works ok
推荐答案
我写了一个小助手代理来处理这个问题:https://github.com/ice3-software/node-archive-delegate.它使用 NSKeyedUnarchiverDelegate
按名称子类化你的精灵.
I wrote a little helper delegate to deal with this: https://github.com/ice3-software/node-archive-delegate. It uses the NSKeyedUnarchiverDelegate
to subclass your sprites by name.
这篇关于子类化使用 SpriteKit .sks 场景文件创建的 SKNode的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!