gpt4 book ai didi

android - 我如何使用 Cocos2d-x 制作类范围的 CCArray?

转载 作者:行者123 更新时间:2023-11-28 00:44:38 25 4
gpt4 key购买 nike

在使用了几年的 Objective-C 之后,我才刚刚开始学习 C++ 和 Cocos2d-x。今晚的障碍似乎是学习如何将 CCArray 函数用作类范围变量。

HelloWorldScene.h

class HelloWorld : public cocos2d::CCLayer
{

public:
// Here's a difference. Method 'init' in cocos2d-x returns bool, instead of returning 'id' in cocos2d-iphone
virtual bool init();

// there's no 'id' in cpp, so we recommand to return the exactly class pointer
static cocos2d::CCScene* scene();

// a selector callback
void menuCloseCallback(CCObject* pSender);

// implement the "static node()" method manually
CREATE_FUNC(HelloWorld);

// static Array of tiles
static cocos2d::CCArray* uniquetiles;
};

HelloWorldScene.cpp

uniquetiles=CCArray::create();
uniquetiles->addObject(d00);

当我尝试运行代码时,我收到一条错误消息“undefined reference to 'Helloworld::uniquetiles'

我在这里做错了什么?看起来这应该是直截了当的。

最佳答案

你应该在类定义中添加这个变量。

private:
CCArray* uniquetiles;

关于android - 我如何使用 Cocos2d-x 制作类范围的 CCArray?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16908971/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com