OGeek|极客世界-中国程序员成长平台

标题: ios - Sprite 工具包 - 命名重复的对象 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-13 06:53
标题: ios - Sprite 工具包 - 命名重复的对象

使用apple spritekit,如果20个节点具有相同的艺术作品并且要随机放置在屏幕上,我如何唯一标识节点?有没有像cocos2d那样更快的方法有一个“标签”功能来识别?



Best Answer-推荐答案


我不是最精通 Sprite ,但这是你要找的东西吗?

保存:

NSArray * nodesArray; // some array of nodes.
for (int x = 0; x < nodesArray.count; x++) {
    SKNode * node = nodesArray[x];
    node.name = [NSString stringWithFormat"%i", x];
}

检索:

int nodeToRetrieveTag = 2; // or whatever
SKNode* nodeToRetrieve = [self.scene childNodeWithName:[NSString stringWithFormat"%i", nodeToRetrieveTag]];

关于ios - Sprite 工具包 - 命名重复的对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22416084/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://sqlite.in/) Powered by Discuz! X3.4