子类化使用SpriteKit .sks场景文件创建的SKNodes [英] Subclassing SKNodes created with SpriteKit .sks scene file

查看:1250
本文介绍了子类化使用SpriteKit .sks场景文件创建的SKNodes的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

(这适用于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 - 软件/节点存档委托。它使用 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场景文件创建的SKNodes的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆