《cocos2d-x权威指南》中第十一章范例(喵星战争)移植到android出现的问题

coos2d-x的版本为:2.0.4

1.

jni/../../Classes/GameMenuScene.h:39:31: error: ISO C++ forbids declaration of 'LAYER_CREATE_FUNC' with no type [-fpermissive] 

解决:

LAYER_CREATE_FUNC and SCENE_CREATE_FUNC can be replace by one macro CREATE_FUNC


2.
jni/../../Classes/AppDelegate.cpp: In member function 'virtual bool AppDelegate::applicationDidFinishLaunching()':

jni/../../Classes/AppDelegate.cpp:29:59: error: lvalue required as unary '&' operand

解决:

AppDelegate.cpp: pDirector->setOpenGLView(&CCEGLView::sharedOpenGLView());-->pDirector->setOpenGLView(CCEGLView::sharedOpenGLView());


3.
jni/../../Classes/GameAboutScene.cpp: In member function 'virtual bool GameAbout::init()':
jni/../../Classes/GameAboutScene.cpp:50:111: error: no matching function for call to 'cocos2d::CCLabelTTF::create(char [256], cocos2d::CCSize, cocos2d::CCTextAlignment, char const [12], int)'
解决:
CCLabelTTF * myjineng = CCLabelTTF::create(inf,"Marker Felt",40,CCSizeMake(400,400),kCCTextAlignmentLeft);


4.
jni/../../Classes/GameMark.cpp: In member function 'virtual void GameMark::onEnter()':

jni/../../Classes/GameMark.cpp:26:29: error: invalid conversion from 'int' to 'cocos2d::CCObject*' [-fpermissive]

解决:

bits = CCArray::createWithCapacity(5);


5.
jni/../../Classes/GameScene.cpp: In member function 'virtual bool GameMain::init()':
jni/../../Classes/GameScene.cpp:76:31: error: invalid conversion from 'int' to 'cocos2d::CCObject*' [-fpermissive]
同4.


6.
jni/../../Classes/GameScene.cpp: In member function 'virtual bool GameMain::init()':

jni/../../Classes/GameScene.cpp:92:47: error: no matching function for call to 'cocos2d::CCSprite::create(cocos2d::CCTexture2D*)'

解决:

blood1 = CCSprite::spriteWithTexture(ui->getTexture());


7.新游戏的图标名称为newgameA.png和newgameB.png,而代码中为newGameA.png和newGameB.png。大小写不一致。

你可能感兴趣的:(cocos2d-x,开发)