3

我正在尝试从为 cocos2d-x 3.0alpha 编写的示例源代码(因为该框架完全没有文档)中学习,该代码使用已弃用的类“Object”,我正在尝试将代码移植到版本3.0 但我不确定使用哪个类来代替 Object。

你有什么主意吗?

https://github.com/OiteBoys/Earlybird/blob/master/Earlybird/Classes/Number.h

编辑:很确定我需要的课程是 Ref


我正在尝试解决的当前问题是找到等效于 EGLView::getInstance()

编辑二: GLView::create("view"); 似乎是它。

4

1 回答 1

4

是的,你需要Ref. 以下是 3.0 版的发行说明。它在这里描述了这一点。之所以进行此更改,是因为 C++ 没有也不需要基础对象。Object最初是出于这个原因而创建的,但现在已弃用。

https://github.com/cocos2d/cocos2d-x/blob/v3/docs/RELEASE_NOTES.md

使用命令行工具EGLView创建一个快速示例“Hello World”项目cocos并查看AppController.mm,RootViewController.mmAppDelegate.cpp. 这些对于 3.0+ 版本已经发生了很大的变化。

编辑:根据您的编辑查看:bool AppDelegate::applicationDidFinishLaunching()

// initialize director
auto director = Director::getInstance();
auto glview = director->getOpenGLView();
if(!glview) {
    glview = GLView::create("My Game");
    director->setOpenGLView(glview);
}
于 2014-05-16T17:38:58.583 回答