cocos2d-x

What does “[ this ]” mean in C++

妖精的绣舞 提交于 2019-12-03 09:19:07
When I was reading the Cocos2dx 3.0 API, I found something like this: auto listener = [this](Event* event){ auto keyboardEvent = static_cast<EventKeyboard*>(event); if (keyboardEvent->_isPressed) { if (onKeyPressed != nullptr) onKeyPressed(keyboardEvent->_keyCode, event); } else { if (onKeyReleased != nullptr) onKeyReleased(keyboardEvent->_keyCode, event); } }; What does [this] mean? Is this new syntax in C++11 ? What does [this] means? It introduces a lambda - a callable function object. Putting this in the brackets means that the lambda captures this , so that members of this object are

Cocos2d-x on Android Studio - New CPP files are not listed

匿名 (未验证) 提交于 2019-12-03 09:14:57
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Android Studio 2.3.3 (LATEST) Cocos2d-x 3.15.1 (LATEST) It's my first experience with Cocos2d-x Game Engine, I encountered a lot of problems. The first time I tried the latest NDK of Android Studio but there is a bug on this NDK version when I tried to compile my project with : cocos compile -p android --android-studio so I change the NDK version to 13b. When I changed to NDK 13b the compilation was done without any problems and android studio build my project successfully but when I tried to create new CPP FILE or JAVA FILE or anything

why “cocos compile -p android” gives “The android command is no longer available.” error

匿名 (未验证) 提交于 2019-12-03 08:44:33
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am working on a cocos2d-x project. i always compile android project using cocos command cocos compile -p android --android-studio -m debug . But now this command returning an error. The android command is no longer available. For manual SDK and AVD management, please use Android Studio. For command-line tools, use tools/bin/sdkmanager and tools/bin/avdmanager Error running command, return code: 1. Error running command, return code: 14. i can't figure out the problem. why this is giving error? what did i changed that caused this issue? I

cocos2d-x CCTouchDispatcher - no sharedDispatcher

匿名 (未验证) 提交于 2019-12-03 08:36:05
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I'm currently porting an ObjC cocos2d game to cocos2d-x, but I'm encountering some problems when trying to create a registerWithTouchDispatcher method, at the moment I'm doing void GameLayer :: registerWithTouchDispatcher () { CCTouchDispatcher :: sharedDispatcher ()-> addTargetedDelegate ( this , 0 , true ); } but this gives an error 'No member named sharedDispatcher' in cocos2d::CCTouchDispatcher'. Is there another way that this must be done in cocos2d-x? 回答1: If you are using 2.0, they have been merged in to CCDirector. please

cocos2d-x android set up error - java.lang.NullPointerException

℡╲_俬逩灬. 提交于 2019-12-03 08:19:23
I'm trying to set up cocos2d-x for android and I followed a video tutorial I passed the steps for terminal without any problem ( setup.py command result is as expected). My problem is after I set NDK_ROOT in C/C++ Build - environment section , I get some java.lang.NullPointerException exceptions. For example when I restart eclipse I get the following error. An internal error occurred during: "Android Library Update". java.lang.NullPointerException When I try to reopen C/C++ Build - environment section I get The currently displayed page contains invalid values. error and I can't edit the

How can I include cocos2d-x templates in Xcode?

女生的网名这么多〃 提交于 2019-12-03 07:20:53
问题 I'm trying to follow this guide which is often quoted as being an excellent tutorial for Cocos2d-x. The problem is that my downloads for Cocos2d-x (2.2 and 3.0 alpha0) do not include the file the tutorial indicates, install-templates-xcode.sh . Any idea what happened here? I did a search for that term, and nothing came up, so I'm assuming it's not hidden deeper in the files. Out of frustration I downloaded cocos2d-iphone, and that folder clearly has the install-templates.sh file. I'd rather

ant debug, and sdk.dir

岁酱吖の 提交于 2019-12-03 07:03:27
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 env var Total time: 0 seconds I don't know what is problem. Your project should have a local.properties

cocos2D-X 常用功能封装

帅比萌擦擦* 提交于 2019-12-03 06:27:55
Packaging_Kernel.h #pragma once #include <string> #include <map> #include <vector> #include "cocos2d.h" #include "ui\CocosGUI.h" #include "SimpleAudioEngine.h" #include "cocostudio\CocoStudio.h" #include "cocos\editor-support\spine\SkeletonAnimation.h" #include "cocos\platform\desktop\CCGLViewImpl-desktop.h" #include "cocos\math\CCGeometry.h" #include "cocos\editor-support\spine\extension.h" #include "cocos\math\Vec2.h" #include "cocos2d/extensions/GUI/CCScrollView/CCTableView.h" #include <iostream> #include <windows.h> #include <tchar.h> using namespace std; using namespace cocos2d; using

Android back button does not work

放肆的年华 提交于 2019-12-03 04:42:14
I am using cocos2dx to make a small game and in the activity of my game i give the following functions to handle back button. @Override public boolean onKeyDown(int keyCode, KeyEvent event) { return super.onKeyDown(keyCode, event); } @Override public void onDestroy() { android.os.Process.killProcess(android.os.Process.myPid()); super.onDestroy(); } On pressing back button i get the following warning in my logcat Can't open keycharmap file Error loading keycharmap file '/system/usr/keychars/qtouch-touchscreen.kcm.bin'. hw.keyboards.65538.devname='qtouch-touchscreen' The call doesn't reach

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

谁说胖子不能爱 提交于 2019-12-03 03:52:31
设置场景(Setting),Setting.h文件代码如下: [html] view plain copy #ifndef __Setting_SCENE_H__ #define __Setting_SCENE_H__ #include "cocos2d.h" #include "SimpleAudioEngine.h" class Setting : public cocos2d::Layer { bool isEffect; ① public: static cocos2d::Scene* createScene(); virtual bool init(); virtual void onEnter(); virtual void onEnterTransitionDidFinish(); virtual void onExit(); virtual void onExitTransitionDidStart(); virtual void cleanup(); void menuSoundToggleCallback(cocos2d::Ref* pSender); void menuMusicToggleCallback(cocos2d::Ref* pSender); void menuOkCallback(cocos2d::Ref* pSender); CREATE