我开发了一个带有XCode的Cocos2d-X应用程序,当我在iOS设备上从XCode启动时,它可以很好地工作.
现在,我想将它移植到Android.我的理解是我必须找到一种方法将我的"XCode项目"导入Eclipse,以便能够编译它并在Android设备上启动它.
我正在尝试按照本教程将此项目转换为混合iOS/Android项目:http://gameit.ro/2012/01/creating-an-iphone-and-android-cocos2d-x-hybrid-project-updated /#评论-640
不过,当我打开这个混合项目时,我没有看到我的任何cpp类(cocos2d-x C++类)出现在Eclipse中,并且在尝试使用build_native.sh进行编译时出现以下错误:
Compile++ thumb : game_logic <= AppDelegate.cpp
jni/../../Classes/AppDelegate.cpp:14:23: error: IntroMenu.h: No such file or directory
jni/../../Classes/AppDelegate.cpp:15:23: error: GameLayer.h: No such file or directory
jni/../../Classes/AppDelegate.cpp:16:26: error: ScoreManager.h: No such file or directory
jni/../../Classes/AppDelegate.cpp: In member function 'virtual bool AppDelegate::applicationDidFinishLaunching()':
jni/../../Classes/AppDelegate.cpp:99: error: invalid use of incomplete type 'struct ScoreManager'
jni/../../Classes/AppDelegate.h:17: error: forward declaration of 'struct ScoreManager'
jni/../../Classes/AppDelegate.cpp:101: error: invalid use of incomplete type 'struct ScoreManager'
jni/../../Classes/AppDelegate.h:17: error: forward declaration of 'struct ScoreManager'
jni/../../Classes/AppDelegate.cpp:118: error: …Run Code Online (Sandbox Code Playgroud) 我现在用Xcode开发Cocos2d-x.但我不知道如何用LLDB检查C++对象的实际类.正如你可以在图片中看到,Xcode的检查员知道实际的类,但p还是po没有.
所以问题是:如何用LLDB检查C++对象的实际类?

我对Cocos2d和Cocos2dx很熟悉.但只有我在Mac工作,我知道在Windows中哪个可能与这个引擎(Cocos2dx)一起工作,但我不知道是否有可能在Linux上开发游戏.
顺便说一句:我不是在谈论端口,我想在Linux上开发一个Videogame多平台.非常了解如何在Linux上启动我的游戏.
谢谢!
我以前从未在开发环境的初始设置上花费太多时间,这有点荒谬.
我正在尝试运行cocos2dx附带的演示代码.我正在使用:
我已经尝试使用create-android-project.sh构建应用程序模板,我遇到了同样的问题,但对于这个问题,我将引用hello.cpp示例应用程序.
我运行build_native.sh脚本,然后在eclipse中导入它.接下来是我尝试过的所有不同教程的地方各不相同.有人说'转换为c ++项目',有人说你已经可以在这个时候'作为android项目'运行了.
对我来说,似乎android java项目无法链接到cocos2dx项目.
我明白了:
The import org.cocos2dx.lib cannot be resolved
Run Code Online (Sandbox Code Playgroud)
对于
import org.cocos2dx.lib.Cocos2dxActivity
Run Code Online (Sandbox Code Playgroud)
没有任何教程真的提到必须构建cocos2dx库,除了那个说你现在必须将cocos库作为项目导入到eclipse工作区中的库.所以我已经完成了并构建了它们但是在构建之后它们中存在一些错误.
我也尝试在项目中添加链接到的文件夹路径,对我来说是/cocos2d-2.1beta3-x-2.1.0/cocos2dx/platform/android/java/src/org/cocos2dx/lib但是没有没有帮助.
知道为什么我不能构建/运行cocos2dx附带的示例,即使遵循cocos2dx网站上的构建指令到T?
我从http://www.raywenderlich.com/11283/cocos2d-x-for-ios-and-android-getting-started开始使用Cocos2D-X for android .
我在xcode和android中运行演示没有任何问题,直到我去"在Eclipse中定义一个Java/C++项目组合"部分.
我做的这一切后,我得到了错误Symbol 'cocos2d' could not be resolved的using namespace cocos2d;在jni/hellocpp/main.cpp和许多其他类似的错误.我发现#include "cocos2d.h"这个文件丢失了,所以我添加了这一行,但错误仍然存在.
我不是为什么,但我认为必须要导入一些库.
在我的android项目中,有一个includes目录包括NDK和$(COCOS2DX_HOME)/ cocos2dx/include,但在$(COCOS2DX_HOME)/ cocos2dx/include中只有7个.h文件(包括cocos2d.h).我不知道这是否正确.
有人能帮助我,谢谢.
我正在使用Xcode IDE和Cocos2dx来开发多平台游戏.我刚刚开始开发并在一个地方涂成灰泥.我想根据屏幕大小更改资源文件夹.
CCSize screenSize = pEGLView->getFrameSize();
CCEGLView::sharedOpenGLView()->setDesignResolutionSize(768, 1024,
kResolutionExactFit);
if (screenSize.width > 768) {
CCFileUtils::sharedFileUtils()->setResourceDirectory("hd");
pDirector->setContentScaleFactor(2);
} else {
CCFileUtils::sharedFileUtils()->setResourceDirectory("sd");
pDirector->setContentScaleFactor(1);
}
Run Code Online (Sandbox Code Playgroud)
但由于不推荐使用setResourceDirectory(),我可以使用任何其他方法.我尝试使用setSearchPaths(),但它给出了错误.如果有人有相同的工作,请告诉我.提前致谢.
我正在开发游戏并面临创建计时器的问题.我需要一些逻辑,比如时间应该从60秒开始,当它达到0游戏应该结束.我是这个平台的新手.
我想Fire在另一个物理体(the arrow)之前添加一个粒子体(比方说).因此,我正在使用它spring joint来保持它们在20000左右的刚度,但它仍然以正确的方式开始并且粒子体从箭头摆动.这是我的代码:
fire part
CCParticleSystem *explosion= [CCParticleSystem particleWithFile:@"bomb.plist"];
explosion.position = ccpAdd(projectilePos, ccp(16,0));
explosion.physicsBody.mass=1.0;
explosion.physicsBody = [CCPhysicsBody bodyWithCircleOfRadius:16.0 andCenter:explosion.anchorPointInPoints];
explosion.physicsBody.type=CCPhysicsBodyTypeDynamic;
explosion.physicsBody.affectedByGravity=FALSE;
explosion.physicsBody.allowsRotation=FALSE; //so that fire flames go upwards only, and not rotate
[physicsWorld addChild:explosion];
explosion.physicsBody.collisionMask=@[];
Run Code Online (Sandbox Code Playgroud)
arrow part
CCSprite *tempSprite;
tempSprite = [CCSprite spriteWithImageNamed:@"arrow3@2x.png"];
[tempSprite setScale:0.05];
[tempSprite setScaleY:0.15];
tempSprite.rotation=rotation;
tempSprite.position=dummyBow.position;
tempSprite.name=[NSString stringWithFormat:@"%@,%d",[lifeOfSprite[1] objectForKey:@"name"],[[lifeOfSprite[1] objectForKey:@"life"] intValue]];
tempSprite.physicsBody = [CCPhysicsBody bodyWithRect:(CGRect){CGPointZero, tempSprite.contentSize} cornerRadius:0]; // 1
tempSprite.physicsBody.collisionGroup = @"playerGroup";
tempSprite.physicsBody.collisionType = @"projectileCollision";
[physicsWorld addChild:tempSprite z:0];
projectile.physicsBody.mass=100;
Run Code Online (Sandbox Code Playgroud)
now the joint …
出于某种原因,即使我的应用程序名称正确显示在应用程序图标旁边,当我在settings-> app下查找该应用程序时,该名称仍显示为“ libcocos2dx”,而不是正确的名称。
因此,我在AndroidManifest.xml中添加了以下行:
android:label="@string/app_name"
Run Code Online (Sandbox Code Playgroud)
但这导致了错误:
app/AndroidManifest.xml:12:6 Error:
Attribute application@label value=(@string/app_name) from AndroidManifest.xml:12:6
is also present at proj.android-studio:libcocos2dx:unspecified:13:9 value=(libcocos2dx)
Suggestion: add 'tools:replace="android:label"' to <application> element at AndroidManifest.xml:11:5 to override
Run Code Online (Sandbox Code Playgroud)
如何解决以上错误?我不知道将libcocos2dx指定为名称。我正在使用cocos2d-x v3.7,该版本使用libcocos2dx。
编辑:我可以看到使用“ tools:replace”的建议,但是我感觉我是在掩盖问题而不是解决它。有没有更好的方法来解决根本原因?
编辑:有人知道如何添加工具:替换吗?这对您来说似乎很明显,但是当我添加它时,出现错误:
与元素类型“应用程序”相关联的属性“ tools:replace”的前缀“ tools”未绑定
我想用cocos2d-x(c ++)读一个plist这里是我的plist:
<array>
<dict>
<key>x</key>
<integer>0</integer>
<key>y</key>
<integer>0</integer>
</dict>
<dict>
<key>x</key>
<integer>140</integer>
<key>y</key>
<integer>12</integer>
</dict>
<dict>
<key>x</key>
<integer>120</integer>
<key>y</key>
<integer>280</integer>
</dict>
<dict>
<key>x</key>
<integer>40</integer>
<key>y</key>
<integer>364</integer>
</dict>
<array>
Run Code Online (Sandbox Code Playgroud)
它基本上是由(x,y)坐标组成的字典数组.我原来的阅读代码是:
NSString *path = [[NSBundle mainBundle] pathForResource:[NSString stringWithFormat:@"w%i", world] ofType:@"plist"];
NSMutableArray* points = [NSMutableArray arrayWithContentsOfFile:path];
Run Code Online (Sandbox Code Playgroud)
但现在我需要将其翻译成c ++中的cocos2d-x.我用Google搜索了一些文章,但它们都是关于将plist读入字典.我需要一个阵列.
编辑:::
现在我改变了我的plist格式:
<dict>
<key>11x</key>
<integer>0</integer>
<key>11y</key>
<integer>0</integer>
<key>12x</key>
<integer>140</integer>
<key>12y</key>
<integer>12</integer>
<dict>
Run Code Online (Sandbox Code Playgroud)
我该怎么办???我仍然得到同样的错误:
CCDictionary<std::string, CCObject*>* dict = CCFileUtils::dictionaryWithContentsOfFile(plistPath);
int x = (int)dict->objectForKey("11x");
int y = (int)dict->objectForKey("11y");
Run Code Online (Sandbox Code Playgroud)
不行.请先试一试.看看你是否可以从样本plist中读取一个int