cocos2d-x

what is the memory management in cocos2dx 3.10?

廉价感情. 提交于 2019-12-12 04:06:58
问题 In class MainLayer init() function, I use a static vector to store the pointer of class block which extend Node. And then, after 5 seconds (I use a schedule to trigger run the function of runBlock()), I try to get data which are stored in static vector. However, the data that I got was wrong. From the debug, I understand it is the memory error. the data which I initialize looks like be deleted. I don't konw why the data was deleted. Please help me, Thanks! Here is my key code: MainLayer.cpp

XMXtiledmap getLayer() return null with tmx file in cocos2dx

南笙酒味 提交于 2019-12-12 04:04:20
问题 I am using tiled map editor to get a tmx file and loaded that into my game which is developed with cocos2d-x c++ version 3.15.1 Here is the tmx file: <?xml version="1.0" encoding="UTF-8"?> <map version="1.0" tiledversion="1.0.2" orientation="orthogonal" renderorder="right-down" width="7" height="7" tilewidth="100" tileheight="100" nextobjectid="1"> <tileset firstgid="1" source="map.tsx"/> <layer name="gamemap" width="7" height="7"> <data encoding="csv"> 2,2,1,2,2,2,1, 2,2,2,2,2,1,1, 1,1,1,1,2

cocos2dx-based project in android-studio using gradle-experimental plugin

不想你离开。 提交于 2019-12-12 03:55:19
问题 I have a gradle-experimental 0.6.0-alpha1 compliant build.gradle file: apply plugin: 'com.android.model.application' model { android { compileSdkVersion = 21 buildToolsVersion = "23.0.2" defaultConfig.with { applicationId = "com.company.application" minSdkVersion.apiLevel = 21 targetSdkVersion.apiLevel = 21 } } android.buildTypes { release { minifyEnabled = false proguardFiles.add(file('proguard-rules.pro')) } } android.ndk { moduleName = "moduleName" } } dependencies { compile project('

how to disable retina image scaling in cocos2d-x framework

怎甘沉沦 提交于 2019-12-12 03:19:36
问题 I'm porting my android game to osx I'm having problems on devices with retina display, the sprites are either unnececary scaled or the sprites offset are scaled and not in place, I'd like to have a possibility to control this by myself. Is it possible to work in retina mode without scale factor, can I somehow enable usage of a full screen 960x640 and with scale factor still set to 1.0? Could you please tell me how can I do it? 回答1: You can disable retinal display in AppDelegate.cpp file. In

Android - How to know maximal size/dimensions of the image that the device can load

天大地大妈咪最大 提交于 2019-12-12 02:50:09
问题 My question may not be very correct, but let me describe it in details. I use cocos2d-x (renders using opengl-es 2) game engine to show images on Android device. In some cases when image dimensions are very large the images are not being displayed. They just get skipped. But I see that the size of the image is smaller then the size of my device VRAM. Checked with this method with /dev/graphics/fb0 : How to measure VRAM consumption on Android?. So my file size is 532,042 bytes , its dimension

How to add a sprite that is always on the screen in Cocos2d?

心不动则不痛 提交于 2019-12-12 02:39:15
问题 I'm doing a platformer game using cocos2d-x v3 in c++, where the maps are usually very large, the visible screen follows the object through the map. Let's say I want to show a sprite in the top right corner of the screen and it would be in this position even when the screen is following the object. Using the object position doesn't do it. Is there a way to show a sprite or whatever in the screen and it would be in the screen even when the screen is moving? Ps. I'm super noob in game

Android Cocos2dX JNI Bridge

不打扰是莪最后的温柔 提交于 2019-12-12 02:38:44
问题 I am new to using Cocos2d-X and am just experimenting using JNI in my application. So here is my java code public class JNITest { public static native void printSomething(); public static void printSomethingFromJava(){ printSomething(); } } I use javah to generate a header file, and implement a C function in my MyScene.cpp file void notify(){ CCNotificationCenter::sharedNotificationCenter()->postNotification("hello",NULL); } extern "C" { void Java_com_nbs_test_JNITest_printSomething(JNIEnv *,

moving CCSprit to the left causing strange movement all other direction are working

て烟熏妆下的殇ゞ 提交于 2019-12-12 02:29:34
问题 i try to move simple CCNode with CCSprit as member to the left side and it give me strange result , all the other dirctions working fine that is right , up , down only left give me problem the sprit is moving way out of the screen . here are the functions i have they are called on ccTouchMoved the job is to take the near sprite (Gem* other ) and replace with the current //THIS IS THE PROBLEMATIC FUNCTION void Gem::setGemPositionAnimationLeft(Gem* other,bool bMatch) { CCLOG(

Sending Paramters to a CCCallFuncND::create Cocos2d-X

谁说胖子不能爱 提交于 2019-12-12 01:46:39
问题 I have the following code in my Cocos2d-X application void SampleRequest::setResponseCallback(CCCallFuncND* cb){ if(cb){ cb->retain(); stored_cb=cb; } } void SampleRequest::executeStoredCallback(){ if(stored_cb) stored_cb->execute(); } void SampleRequest::releaseCallback(){ if(stored_cb){ stored_cb->release(); stored_cb=NULL; } } and a simple class void RequestHandler::handleSampleRequest(int data){ CCLog("--------------------------------------------> Its here for me to do %d",data); } and

How to kill Cocos2d-x test app

北战南征 提交于 2019-12-12 01:39:12
问题 We are creating an SDK that is used in Cocos2d-x games (on Android/iOS). As part of development, we have setup a test framework for running various tests on a real device (Android only at the moment). One specific test needs to kill the app and launch it again. It seems that Cocos2d-x does not provide any API for exiting (or killing) the running app. Some online resources suggested that people have used the call to exit(0) . Is there any way to exit the game from Cocos2d-x ? Calling exit(0)