C++ Ubuntu上QtCreator中的Cocos2d-x
我尝试在QtCreator中运行cocos2d-x2.2helloword项目。我正在使用基于此存储库的此项目文件 My main.cpp文件:C++ Ubuntu上QtCreator中的Cocos2d-x,c++,opengl,ide,qt-creator,cocos2d-x,C++,Opengl,Ide,Qt Creator,Cocos2d X,我尝试在QtCreator中运行cocos2d-x2.2helloword项目。我正在使用基于此存储库的此项目文件 My main.cpp文件: #include "../Classes/AppDelegate.h" #include "cocos2d.h" #include "CCEGLView.h" #include <stdlib.h> #include <stdio.h> #include <unistd.h> #include <stri
#include "../Classes/AppDelegate.h"
#include "cocos2d.h"
#include "CCEGLView.h"
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string>
#include "../Classes/AppDelegate.h"
USING_NS_CC;
// 500 is enough?
#define MAXPATHLEN 500
int main(int argc, char **argv)
{
// get application path
int length;
char fullpath[MAXPATHLEN];
length = readlink("/proc/self/exe", fullpath, sizeof(fullpath));
fullpath[length] = '\0';
std::string resourcePath = fullpath;
resourcePath = resourcePath.substr(0, resourcePath.find_last_of("/"));
resourcePath += "/../../Resources/";
// create the application instance
AppDelegate app;
CCApplication::sharedApplication()->setResourceRootPath(resourcePath.c_str());
CCEGLView* eglView = CCEGLView::sharedOpenGLView();
eglView->setFrameSize(800, 480);
return CCApplication::sharedApplication()->run();
}
我尝试在Ubuntu 12.04上运行我的项目。有人知道我做错了什么吗
======编辑
AppDelegate:
#include "AppDelegate.h"
#include "HelloWorldScene.h"
USING_NS_CC;
AppDelegate::AppDelegate() {
}
AppDelegate::~AppDelegate()
{
}
bool AppDelegate::applicationDidFinishLaunching() {
// initialize director
CCDirector* pDirector = CCDirector::sharedDirector();
CCEGLView* pEGLView = CCEGLView::sharedOpenGLView();
pDirector->setOpenGLView(pEGLView);
// turn on display FPS
pDirector->setDisplayStats(true);
// set FPS. the default value is 1.0/60 if you don't call this
pDirector->setAnimationInterval(1.0 / 60);
// create a scene. it's an autorelease object
CCScene *pScene = HelloWorld::scene();
// run
pDirector->runWithScene(pScene);
return true;
}
// This function will be called when the app is inactive. When comes a phone call,it's be invoked too
void AppDelegate::applicationDidEnterBackground() {
CCDirector::sharedDirector()->stopAnimation();
// if you use SimpleAudioEngine, it must be pause
// SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic();
}
// this function will be called when the app is active again
void AppDelegate::applicationWillEnterForeground() {
CCDirector::sharedDirector()->startAnimation();
// if you use SimpleAudioEngine, it must resume here
// SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic();
}
但是我认为,appdelegate中的代码永远不会执行://p>这部分看起来不错,
检查AppDelegate::ApplicationIDFinishLaunching()方法,这是应用程序实际启动的地方,您也可以在上述方法中设置resourcepath变量,因为在此之前不会访问任何内容。如果需要更多信息,请粘贴AppDelegate::ApplicationIDFinishLaunching()中的代码methodAppDelegate.cpp包含在问题中:)我需要更多信息:P
cocos2d-x debug info [Ready for GLSL]
cocos2d-x debug info [Ready for OpenGL 2.0]
#include "AppDelegate.h"
#include "HelloWorldScene.h"
USING_NS_CC;
AppDelegate::AppDelegate() {
}
AppDelegate::~AppDelegate()
{
}
bool AppDelegate::applicationDidFinishLaunching() {
// initialize director
CCDirector* pDirector = CCDirector::sharedDirector();
CCEGLView* pEGLView = CCEGLView::sharedOpenGLView();
pDirector->setOpenGLView(pEGLView);
// turn on display FPS
pDirector->setDisplayStats(true);
// set FPS. the default value is 1.0/60 if you don't call this
pDirector->setAnimationInterval(1.0 / 60);
// create a scene. it's an autorelease object
CCScene *pScene = HelloWorld::scene();
// run
pDirector->runWithScene(pScene);
return true;
}
// This function will be called when the app is inactive. When comes a phone call,it's be invoked too
void AppDelegate::applicationDidEnterBackground() {
CCDirector::sharedDirector()->stopAnimation();
// if you use SimpleAudioEngine, it must be pause
// SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic();
}
// this function will be called when the app is active again
void AppDelegate::applicationWillEnterForeground() {
CCDirector::sharedDirector()->startAnimation();
// if you use SimpleAudioEngine, it must resume here
// SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic();
}