cocos2d-x

How to show Dialog from a static method

谁说我不能喝 提交于 2019-12-10 18:14:22
问题 In my game, which is done for both Android and IOS using cocos2dx , I have to show video(for Android). I am planning to show it in Dialog(on top of game view). Problem is that, I don't have any Activity referenced to show Dialog(as Dialogs can only be shown in Activities). Even though, In cocos2dx lib folder, there is a Cocos2dxActivity but I am not getting how to make use of it. From C++ code, I am calling a static method from Java class as below void LMJNICommunicator::showVideo() { LOGD(

Can an embedded cocos2d-js app call back out to c++?

泪湿孤枕 提交于 2019-12-10 17:32:25
问题 I'm researching the possibility of using cocos2d-js by embedding it as a view inside an existing iOS app. In order to make this work, I'm going to need 2-way communication between cocos2d and the surrounding application. After some initial investigation, I have determined that it is possible to call in to cocos using ScriptingCore : ScriptingCore* sc = ScriptingCore::getInstance(); jsval outVal; sc->evalString("function()", &outVal); My question, then, is around doing the reverse. It is

Error when trying to compile using sqlite3_open in Visual Studio 2013

南笙酒味 提交于 2019-12-10 15:39:16
问题 I'm working in a Cocos2dx (c++) win 32 project and trying to use sqlite to save the game data. My knowledge of c++ / Visual Studio is very limited right now. This is part of the code that I'm trying to compile. #include <sqlite3\include\sqlite3.h> ... void HelloWorld::SaveAndLoadTest() { sqlite3 *pdb = NULL; sqlite3_open("writablePath", &pdb); ... } But when I try to compile the line with the sqlite3_open command I get the following error: Error 7 error LNK2019: unresolved external symbol

Back and Home buttons pressed event for Android devices (cocos2d-x 3)

萝らか妹 提交于 2019-12-10 14:17:29
问题 I have done this to catch Home and Back buttons press events on android devices: Overrided void Layer::onKeyReleased(EventKeyboard::KeyCode keyCode, Event* event) function like this: void MyLayer::onKeyReleased(EventKeyboard::KeyCode keyCode, Event* event) { if (keyCode == EventKeyboard::KeyCode::KEY_BACKSPACE /*KeyboardEvent::KeyCode::Menu(KEY_BACKSPACE)*/) { CCLOG("You pressed back button"); Director::getInstance()->end(); exit(0); } else if (keyCode == EventKeyboard::KeyCode::KEY_HOME) {

Convert Spritekit Game to Android?

馋奶兔 提交于 2019-12-10 12:36:17
问题 Are there any new options for converting a spritekit game to android? It seems the only options are to recode everything in Java or to use Cocos2D, LibGDX, etc. 回答1: Unfortunately ... no :{ And the cross-platform SpriteBuilder with the Apportable service that let you convert a Swift Cocos project to Android is no longer available (they got bought out by Google I believe). SpriteBuilder is still available on GitHub but it's not active afaik and is abandoned. So... what to do? I would focus on

Cocos2dx 3.17 TileMap Basic Sample - wrong tilecord position, object layer itmes position returned also wrong

孤街醉人 提交于 2019-12-10 11:33:27
问题 I tried cocos2d TileMap sample from here, In this tilecord returned for given player position is wrong. Here is code Point HelloWorld::tileCoordForPosition(Point position) { int x = position.x / mTileMap->getTileSize().width; int y = ((mTileMap->getMapSize().height * mTileMap->getTileSize().height) - position.y) / mTileMap->getTileSize().height; return Point(x, y); } Here is Map Screenshot Also tileCord returned is wrong. So collision is not working. I used it from sample in Ray Wenderlich

Couldn't load game: findLibrary returned null: with cocos2d-x, no success despite many attempts?

陌路散爱 提交于 2019-12-10 10:24:00
问题 I would like to try a simple project using Eclipse Mobile For Developers, the NDK, Android SDK, and Cocos2d-x. I have correctly set the paths in: cocos2d-x/create-android-project.sh : NDK_ROOT_LOCAL="/Users/Empon/android-ndk-r8e" ANDROID_SDK_ROOT_LOCAL="/Users/Empon/android" and in the settings in Eclipse ("NDK path" from the Properties). I followed the topics in stackoverflow but I can't make my project work. One thing that seems strange compared to one topic: I don't have anything below

Cocos2d-x3.2场景切换

不羁岁月 提交于 2019-12-10 09:23:00
//GameScene.h #include "cocos2d.h" class GameScene : public cocos2d::Layer { public: static cocos2d::Scene* createScene(); virtual bool init(); void menuCallback(cocos2d::Ref* pSender); CREATE_FUNC(GameScene); }; //GameScene.cpp #include "GameScene.h" #include "HelloWorldScene.h" USING_NS_CC; cocos2d::Scene* GameScene::createScene() { auto scene = Scene::create(); //创建一个场景 auto layer = GameScene::create(); //创建一个图层 scene->addChild(layer); return scene; } //初始化当前的图层 bool GameScene::init() { if(!Layer::init()) //初始化父类 return false; //添加一个图片精灵 Size visibleSize = Director::getInstance()-

cocos2d-x 3.1.1 lua 翻转方块 Flips Blocks记录

杀马特。学长 韩版系。学妹 提交于 2019-12-10 09:11:30
游戏规则: 游戏有3个等级,简单,中等,困难。对应的是3x3,5x5和9x9的方格数。 每次点击一个方块,与方块相邻的方块会转变颜色。 颜色是按顺序改变的,一共有2种颜色。 当所有方块都显示同一种颜色的时候,游戏结束。 游戏需要记录玩家的操作时间。 游戏退出的时候需要记录目前的状态和时间。 游戏再次启动的时候,检测之前是否有记录,有的话恢复之前的状态。 本项目使用了cocos2d-x 3.1.1 和 code ide github地址: Flip Blocks 在publish有编译好的apk文件。 在豌豆荚也可以下载: Flip Blocks 继上一次的贪吃蛇,这次的翻转方块主要学会了: 1、手机振动的实现。 2、通过UserDefault来实现用户设置。 3、截屏分享。 来源: oschina 链接: https://my.oschina.net/u/256571/blog/312223

cocos2d-x 基本概念的学习

泪湿孤枕 提交于 2019-12-10 06:57:49
cocos2d-x 基本概念的学习 基本元素 我们把内容相对不变的游戏元素成为 场景 ,游戏在场景之间的切换称为 流程控制 。 CCScene 层 是场景之下的游戏元素。 CCLayer 精灵 属于层,是场景中的课件图形。如主角。 CCSprite 节点 和 渲染树 。 CCNode 一旦建立起渲染树,组织复杂的场景就变得十分简单。我们赋予每个节点一系列属性,包括节点相对于父节点的位置、旋转角度、缩放比例、和变形参数等。我们只需要考虑 节点相对于父节点的属性 ,就可以创建复杂的对象或者动作。(这么说的话,实现血条也就可以用这个方法) 动作 和 动画 。动作: CCAction CCActionInterval CCActionInstant 。动画:帧。使用多个动画帧创建动画序列。 CCAnimation , 用帧动画序列创建可作用于精灵的帧动画。 CCAnimate ###命名空间和类名称### 我们可以发现USING_NS_CC-----<code>#define USING_NS_CC using namespace cocos2d</code> ###构造函数和初始化### Cocos2d-x中和C++有点区别: Cocos2d-x它所有的对象都创建在堆上,然后通过指针引用 创建Cocos2d-x对象通常有两种方法,一种是首先使用new操作符创建一个未初始化的对象