cocos2d-x

ant debug, and sdk.dir

痴心易碎 提交于 2019-12-04 10:51:09
问题 I have a problem to generate the Android APK file. When I run ant debug compilation work fine, but when I run ant debug I have following error: iMac:proj.android smartmind$ ant debug Buildfile: /Users/smartmind/Works/Smallthing/cocos2d-x/samples/HelloCpp/proj.android/build.xml BUILD FAILED /Users/smartmind/Works/Smallthing/cocos2d-x/samples/HelloCpp/proj.android/build.xml:46: sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through an

Cocos2d-x: possible to use HTML (UIWebView)?

痞子三分冷 提交于 2019-12-04 10:35:55
I'm trying out cocos2d-x and got to the point where I can build the Javascript samples for Android and run them inside a browser as well. Now I want to create my own game, but coming from a HTML background, I'd rather use HTML tags with CSS than use Javascript to setup the user interface. I've read about UIWebView which can display HTML-pages in an app, but I was wondering if anyone has ever done this in combination with Cocos2D-x ? And could this be transparent, to overlay a normal cocos2d-x screen in the app then? If so, how could this be done? You can use CCXWebview for that with Cocos2d-x.

Can't get touch to work in multi-platform cocos2d-x app

时光总嘲笑我的痴心妄想 提交于 2019-12-04 09:25:17
问题 So I'm trying to create a simple app using cocos2d-x newest build and for some reason can't get my touch wired up. Here are my classes: class GameLayer : public cocos2d::Layer { public: static cocos2d::Layer* createLayer(); void update(float dt); virtual bool init(); CREATE_FUNC(GameLayer); private: bool onTouchBegan(cocos2d::Touch* touch, cocos2d::Event* event); void onTouchMoved(cocos2d::Touch* touch, cocos2d::Event* event); void onTouchEnded(cocos2d::Touch* touch, cocos2d::Event* event); }

jni call java method which take a custom java interface as parameter

此生再无相见时 提交于 2019-12-04 08:40:47
I'm working on a plugin project on cocos2d-x platform , I'd like to write some c++ wrapper interface to invoke java method through JNI from jar SDK . I know how to use JNI to invoke a static java method, but I'm confused by the interface parameter in the java function. I hava a cpp function pointer to handling callbacks: typedef void (* MyCallback)(int responseCode, string arg1, set<string> arg2); and I want to write a cpp wrapper method like : static void MyCpp::setTags(set<string> tags, MyCallback callback) //it use `JNI` to invoke java method setTags(Context context, Set<String> tags,

cocos2d-X doesn't find android platform

送分小仙女□ 提交于 2019-12-04 08:40:39
问题 I'm using cocos2d-X v3 and I created a new cocos2d-X project following this tutorial. But when I run cocos run -s ~/MyCompany/MyGame -p android I get this error: building apk Android platform not specified, searching a default one... Can't find right android-platform for project : "/Users/filipeferminiano/MyCompany/MyGame/proj.android". The android-platform should be equal/larger than 10 回答1: These tutorials cover all steps: http://www.cocos2d-x.org/wiki/How_to_run_cpp-tests_on_Android and

Cocos2d-JS使用CocosDenshion引擎

浪尽此生 提交于 2019-12-04 06:37:11
Cocos2d-JS提供了一个音频CocosDenshion引擎。具体使用的API是cc.AudioEngine。cc.AudioEngine有几个常用的函数: playMusic(url, loop)。播放背景音乐,参数url是播放文件的路径,参数loop控制是否循环播放,缺省情况下false。 stopMusic()。停止播放背景音乐。 pauseMusic()。暂停播放背景音乐。 resumeMusic ()。继续播放背景音乐。 isMusicPlaying()。判断背景音乐是否在播放。 playEffect (url, loop)。播放音效,参数同playMusic函数。 pauseEffect(audioID)。暂停播放音效,参数audioID是playEffect函数返回ID。 pauseAllEffects ()。暂停所有播放音效。 resumeEffect (audioID)。继续播放音效,参数audioID是playEffect函数返回ID。 resumeAllEffects ()。继续播放所有音效。 stopEffect(audioID)。停止播放音效,参数audioID是playEffect函数返回ID。 stopAllEffects ()。停止所有播放音效。 音频文件的预处理 无论是播放背景音乐还是音效在播放之前进行预处理是有必要的。如果不进预处理

Cocos2d-x实例:设置背景音乐与音效- AppDelegate实现

前提是你 提交于 2019-12-04 06:36:58
为了进一步了解背景音乐和音效播放的,我们通过一个实例给大家介绍一下。如下图所示有两个场景:HelloWorld和Setting。在HelloWorld场景点击“游戏设置”菜单可以切换到Setting场景,在Setting场景中可以设置是否播放背景音乐和音效,设置完成后点击“OK”菜单可以返回到HelloWorld场景。 我们需要在AppDelegate中实现背景音乐播放暂停与继续函数,AppDelegate.h文件代码如下: [html] view plain copy #ifndef _APP_DELEGATE_H_ #define _APP_DELEGATE_H_ #include "cocos2d.h" #include "SimpleAudioEngine.h" ① using namespace CocosDenshion; ② class AppDelegate : private cocos2d::Application { public: AppDelegate(); virtual ~AppDelegate(); virtual bool applicationDidFinishLaunching(); virtual void applicationDidEnterBackground(); virtual void

How to enable Box2d debug draw with Coco2d-x 3.0 beta 2

╄→尐↘猪︶ㄣ 提交于 2019-12-04 06:02:18
问题 How I should enable debug draw with Cocos2d-x 3.0? There are some codes that do that with cocos2d-x 2.0 but they don't even compile on Cocos2d-x. Unfortunately I am new to both cocos2d-x and Box2d and I don't know how to port them. That would be great if you would share the method how you draw shapes. EDIT: I have found this: http://blog.csdn.net/tian2kong/article/details/20386213 I have overridden the draw method of my applications main Layer like this: void HelloWorld::draw() { GL:

How to use Android Studio with Cocos2d-x

て烟熏妆下的殇ゞ 提交于 2019-12-04 02:50:20
I work as an android programmer for just under a year now, and I just started to learn about android game development. The framework I choose to work with is Cocos2d-x. I have seen guides and tutorials on how to use Cocos2d-x with eclipse, but I'd really like to know if it's possible to be used with Android Studio. From what I've read, it is now possible to build NDK projects with gradle in Android Studio, which is good news. Nevertheless, I have yet to find any information about C++ programming using Android Studio. Eclipse uses the CDC ( https://www.eclipse.org/cdt/ ) plugin to achieve this.

Cocos2d-x 3.x plist+png 做动画

心不动则不痛 提交于 2019-12-04 02:24:51
***************************************转载请注明出处: http://blog.csdn.net/lttree ****************************************** 前言: 这次的东西,其实是在做完2048后,我有个Flash想用。 就像,天天系列,开头会有 ”提米“ 的叫声+动画, 是不是感觉很带感。 之前,做第一个游戏的时候,有做一套78帧的Flash, 但是当时不会用,现在正好拿过来用了,嘿嘿~ 正文: 这次例子,就拿我这几天想做的 FlappyBird 的小鸟为例吧: 1.首先,我们先来做需要的资源, 这个有三个层次(目前我知道的) ① 加载每个图片 ② 把所有图片压缩到一张图片中,然后分割取出。 ③借助于plist文件与png共同取出图片。 前两种,比较简单,而且效率不是很高,我就直接用这三者最好的,plist+png 其实,plist一般是用在mac上的, 在windows制作plist可以用 TexturePacker, (可以在这里下载: https://www.codeandweb.com/texturepacker/download ) 非常方便的一个工具, 安装完毕,打开,需要选择你的引擎,当然我们选择的是cocos2d的: 打开以后,会出现如下界面: 这个工具的使用细节,我不是很懂= =