cocos2d-x-3.0项目创建的许多错误

时间:2013-11-14 02:35:34

标签: cocos2d-x

所以我正在尝试使用cocos2d-x-3.0设置项目。我可以很好地设置一切,然后在Eclipse中导入和运行我的新项目没有任何问题;但是,一旦我第一次打开main.cpp文件,就会弹出一堆错误,我无法再编译我的项目。它给出的错误是Unresolved inclusion: AppDelegate.h

上的#include "AppDelegate.h"
#include "AppDelegate.h"
#include "cocos2d.h"
#include "CCEventType.h"
#include "platform/android/jni/JniHelper.h"
#include <jni.h>
#include <android/log.h>

#define  LOG_TAG    "main"
#define  LOGD(...)  __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__)

using namespace cocos2d;

void cocos_android_app_init (struct android_app* app) {
    LOGD("cocos_android_app_init");
    AppDelegate *pAppDelegate = new AppDelegate();
}

然后我看了一下,发现我项目中的Classes文件夹是空的,尽管项目中的Classes文件夹中有类。所以我去添加了一个新的Class文件夹,其中包含项目文件夹中自动生成的Classes文件夹的链接。这再次修复了问题,但如果我打开新Class文件夹中的任何文件,它会突出显示无法解决的TON错误,我无法再编译。这是我的AppDelegate.h文件的一部分:

#ifndef  _APP_DELEGATE_H_
#define  _APP_DELEGATE_H_

#include "cocos2d.h"

/**
@brief    The cocos2d Application.

The reason for implement as private inheritance is to hide some interface call by Director.
*/
class  AppDelegate : private cocos2d::Application
{

cocos2d::Application部分Symbol 'Application' could not be resolved说错误。

编辑: 重新生成项目后,我发现Classes文件夹在Eclipse中自动标记为已弃用。我能够创建一个新的(非链接的)Class文件夹,并手动添加预先制作的类,不再给出任何错误。我不知道为什么会这样,但它确实有效。

抓一点,现在我只在四个文件中的一个中出错。在HelloWorldScene.cpp

// add a "close" icon to exit the progress. it's an autorelease object
auto closeItem = MenuItemImage::create(  // Says "Invalid arguments" for the create call
                                       "CloseNormal.png",
                                       "CloseSelected.png",
                                       CC_CALLBACK_1(HelloWorld::menuCloseCallback, this)); // "Symbol'_1' could not be resolved" (What is Symbol_1)?

closeItem->setPosition(Point(origin.x + visibleSize.width - closeItem->getContentSize().width/2 ,
                            origin.y + closeItem->getContentSize().height/2));

// create menu, it's an autorelease object
auto menu = Menu::create(closeItem, NULL);
menu->setPosition(Point::ZERO);
this->addChild(menu, 1);

还有一些Could not be resolvedInvalid arguments错误。最让我困惑的是,在我打开文件并加载错误之前,所有内容都会编译并运行正常。

3 个答案:

答案 0 :(得分:2)

在运动中,你应该使用COCOCS 2d-x2.2在cocos2d-x中创建项目。这很容易也很好。试试吧。

还有一件事去了Projectproperty int eclips和codeAnalysis(在C / c ++ Gneral中),然后点击使用项目设置UNMARK的SYANTax和Semantics错误的CHECK框。 它会消除很多错误

答案 1 :(得分:0)

确保两件事:

  1. 在您自己的项目目录下导入libcocos2dx,如http://www.cocos2d-x.org/wiki/How_to_Build_an_Android_Project_with_Eclipse所述;

  2. 在您的项目中 - 属性 - C / C ++一般&gt;代码分析,取消选择语法和语义错误 - 否则您将看到错误,并且无法从Eclipse构建。

  3. enter image description here

答案 2 :(得分:0)

我不知道为什么会这样,但你可以:

  1. 右键单击Eclipse中的项目&#34; Package Explorer &#34;
  2. 点击&#34; 运行C / C ++代码分析&#34;
  3. 这将删除错误,以便您可以再次构建/运行项目。

相关问题