cocos2d-x

C++/Cocos2d-x: how to add inapp billing (inapp purchase) in Cocos2d-x Android project?

混江龙づ霸主 提交于 2019-12-08 07:35:55
问题 I am currently developing an app which will be on Android Market. How can I implement in my Cocos2x-project the Google code for inapp billing on Android Market ? Detailed explanations (or a detailed step by step tutorial :)) would be appreciated ! Thanks !!! 回答1: JNI has to be used. The inapp is implemented in the Java part of the project. 回答2: The SOOMLA Project has implemented it for you. It's designed specifically for game developers and it's great - but i'm one of the creators so i'm a

Cocos2D-x sample application crashes on launch

谁说胖子不能爱 提交于 2019-12-08 07:34:59
问题 I tried to build the Cocos2D-x testCpp sample project (Cocos2D-x 2.2.2) on my Android device using the command line interface as described in the Readme.md file: $ cd cocos2d-x/samples/Cpp/TestCpp/proj.android/ $ export NDK_ROOT=/path/to/ndk $ ./build_native.sh $ ant debug install If the last command results in sdk.dir missing error then do: $ android list target $ android update project -p . -t (id from step 6) $ android update project -p cocos2d-x/cocos2dx/platform/android/java/ -t (id from

Many Errors with cocos2d-x-3.0 project creation

﹥>﹥吖頭↗ 提交于 2019-12-08 06:18:50
问题 So I'm trying to setup a project using cocos2d-x-3.0. I can set everything up just fine, and then import and run my new project in Eclipse with no problems; however, once I open the main.cpp file for the first time, a bunch of errors pop up and I can no longer compile my project. The error it gives me is Unresolved inclusion: AppDelegate.h on the #include "AppDelegate.h" #include "AppDelegate.h" #include "cocos2d.h" #include "CCEventType.h" #include "platform/android/jni/JniHelper.h" #include

How to draw simple rect with cocos2d-x v3.0

早过忘川 提交于 2019-12-08 05:17:21
问题 In cocos2d-x 3.0 dont work ccDrawSolidRect. 3.0 api have class Rect, but i cant find documentation about it. How to draw simple color rect with cocos2d-x 3.0? 回答1: You can use void drawRect( Point origin, Point destination ); declared in CCDrawingPrimitives . Call this method inside draw() method of any subclass of CCNode like: void TestNode::draw() { drawRect(Point::Point(10,10), Point::Point(40,40)); } 回答2: You can try DrawPrimitives::drawRect(const cocos2d::Point origin, const cocos2d:

Cocos2d.h No such file or directory

僤鯓⒐⒋嵵緔 提交于 2019-12-08 04:11:18
问题 I'm really struggling with setting up my Cocos2d-x project for android, and I can't figure this next one out. There's about 45 errors in my program, and I would assume that the code issues are spawned from the fact that it can't find any of the includes, like cocos2d.h. Any idea why it wouldn't be able to find this? Thanks Tom 回答1: Your program can't find a particular header file if you write: #include "cocos2d.h" The compiler will look in the "Header Search Paths" for that file. By default,

How can I copy a action in cocos2dx

隐身守侯 提交于 2019-12-08 03:25:43
问题 I use cocos2dx 2.2.3. Now I need duplicate a ccsequence or ccspawn. But copy() don't work. my code: layerParticalsFront->runAction(action); layerParticalsBack->runAction(action->copy()); 回答1: Simple example : CCScaleBy* action1 = CCScaleBy::create(1.0f, 1.5f); CCScaleBy* action2 = (CCScaleBy*)action1->copy()->autorelease(); 回答2: It changed a bit over time, this is how you can do it now. ScaleBy* action1 = ScaleBy::create(1.0f, 1.5f); ScaleBy* action2 = action1->clone(); 来源: https:/

How to get screenshot saved path by Cocos2d-x on android

Deadly 提交于 2019-12-08 03:15:01
问题 I use saveToFile method to save screenshot, and I check CCLOG, it shows /data/data/com.xxx.xxx/files/xxx.png However, when I use Java to get this file, it says "No such file or directory".... What can I do? 回答1: I had the same problem. Apparently, cocos2dx never creates the writable path directory so the screenshot doesn't get saved. My solution was to, instead of calling CCRenderTexture::saveToFile , copy its implementation and manually save the file to a different path: std::string MyClass:

How to get screenshot saved path by Cocos2d-x on android

拥有回忆 提交于 2019-12-08 02:17:32
I use saveToFile method to save screenshot, and I check CCLOG, it shows /data/data/com.xxx.xxx/files/xxx.png However, when I use Java to get this file, it says "No such file or directory".... What can I do? I had the same problem. Apparently, cocos2dx never creates the writable path directory so the screenshot doesn't get saved. My solution was to, instead of calling CCRenderTexture::saveToFile , copy its implementation and manually save the file to a different path: std::string MyClass::takeScreenshot(CCScene* scene) { cocos2d::CCSize screenSize = cocos2d::CCDirector::sharedDirector()-

ndk-gdb cannot find gdb.setup but it is there under x86

社会主义新天地 提交于 2019-12-07 18:46:20
问题 Cocos2d-x 3.7.1 + ndk r10e project on Mac trying to debug in Eclipse. Days pass and the errors keep coming... I can build and run using cocos compile and cocos run with -p android -m debug --ndk-mode NDK_DEBUG=1 from the terminal in proj.android. My app runs Ok (eventually) on my x86 emulator no problem. Typing 'ndk-gdb' in the terminal from ./proj.android and I get the error ERROR: Could not find gdb.setup under ./libs/ BUT the file gdb.setup (and gdbserver & libcocos2dcpp.so) can be seen in

Cocos2d-x小蜜蜂游戏

别等时光非礼了梦想. 提交于 2019-12-07 17:47:06
作业要求 游戏演示 实现细节 Thunder.h Thunder.cpp 资源以及视频 作业要求 利用键盘事件实现飞船左右移动。 利用键盘和触摸事件实现子弹发射。 用自定义事件实现:子弹和陨石相距小于一定距离时,陨 石爆炸,子弹消失。 游戏过程中有背景音乐,发射子弹、击中陨石有音效。 注意飞船、子弹的移动范围。 游戏结束飞船爆炸,移除所有监听器。 利用触摸事件实现飞船移动。(点击飞船后拖动鼠标) 陨石向下移动并生成新的一行陨石 子弹和陨石的数量显示正确 游戏演示 实现细节 Thunder.h #ifndef __THUNDER_H__ #define __THUNDER_H__ #include "cocos2d.h" #include "SimpleAudioEngine.h" USING_NS_CC; using namespace std ; class Thunder : public cocos2d::Layer { public : // there's no 'id' in cpp, so we recommend returning the class instance pointer static cocos2d::Scene* createScene(); // Here's a difference. Method 'init' in cocos2d-x