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

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

问题描述

(适用于 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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