cocos2d-x-2.x

How to resize the the animating sprite in cocos2d-x

ⅰ亾dé卋堺 提交于 2019-12-25 05:51:00
问题 I want to change the size of a Sprite which is animating. How can I do this ? I tried to change its size by using setScale property but it is not working here. where I am doing wrong ? CCArray* frames = CCArray::createWithCapacity(3); CCSpriteFrameCache* frameCache = CCSpriteFrameCache::sharedSpriteFrameCache(); char file[100] = {0}; for (int i = 0; i < 3; i++) { sprintf(file, "bird%d.png", i); CCSpriteFrame* frame = frameCache->spriteFrameByName(file); frames->addObject(frame); } CCAnimation

How to resize the the animating sprite in cocos2d-x

久未见 提交于 2019-12-13 05:04:06
问题 I want to change the size of a Sprite which is animating. How can I do this ? I tried to change its size by using setScale property but it is not working here. where I am doing wrong ? CCArray* frames = CCArray::createWithCapacity(3); CCSpriteFrameCache* frameCache = CCSpriteFrameCache::sharedSpriteFrameCache(); char file[100] = {0}; for (int i = 0; i < 3; i++) { sprintf(file, "bird%d.png", i); CCSpriteFrame* frame = frameCache->spriteFrameByName(file); frames->addObject(frame); } CCAnimation

get array data from json file using rapidjson

蓝咒 提交于 2019-12-08 17:12:11
问题 I'm new in rapidjson. I have test.json which contains {"points": [1,2,3,4]} and I use following code to get data of array "points" std::string fullPath = CCFileUtils::sharedFileUtils()->fullPathForFilename("json/deluxe/treasurebag.json"); unsigned long bufferSize = 0; const char* mFileData = (const char*)CCFileUtils::sharedFileUtils()->getFileData(fullPath.c_str(), "r", &bufferSize); std::string clearData(mFileData); size_t pos = clearData.rfind("}"); clearData = clearData.substr(0, pos+1);

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

cocos2dx save image in to gallery android

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-07 14:29:46
问题 I want to take screenshots and save it in the gallery. What I have tried: CCSize size = CCDirector::sharedDirector()->getWinSize(); CCRenderTexture* texture = CCRenderTexture::create((int)size.width, (int)size.height, kCCTexture2DPixelFormat_RGBA8888); texture->setPosition(ccp(size.width/2, size.height/2)); texture->begin(); CCDirector::sharedDirector()->getRunningScene()->visit(); texture->end(); texture->saveToFile("scrshot.png", kCCImageFormatJPEG); in iOS it is working perfectly and am

Cocos2D-x sample application crashes on launch

删除回忆录丶 提交于 2019-12-07 03:50:27
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 step 6) I can install the app on my device (Galaxy S4) but the application crashes immediately after

cocos2dx save image in to gallery android

淺唱寂寞╮ 提交于 2019-12-05 20:03:04
I want to take screenshots and save it in the gallery. What I have tried: CCSize size = CCDirector::sharedDirector()->getWinSize(); CCRenderTexture* texture = CCRenderTexture::create((int)size.width, (int)size.height, kCCTexture2DPixelFormat_RGBA8888); texture->setPosition(ccp(size.width/2, size.height/2)); texture->begin(); CCDirector::sharedDirector()->getRunningScene()->visit(); texture->end(); texture->saveToFile("scrshot.png", kCCImageFormatJPEG); in iOS it is working perfectly and am able to save image in to documents, but the problem is in android : There are two possibilities 1)

Error “Cast from pointer to smaller type 'int' loses information” in EAGLView.mm when update Xcode to 5.1 (5B130a)

放肆的年华 提交于 2019-11-27 12:29:16
问题 Yesterday, I updated Xcode to the newest version (5.1 (5B130a)) to compatible with iOS 7.1 . Then I build my project, I get the error "Cast from pointer to smaller type 'int' loses information" in EAGLView.mm file ( line 408 ) when 64-bit simulators (e.g.: iPhone Retina 4-inch 64-bit) is selected. I'm using cocos2d-x-2.2.2 . Before I update Xcode, my project still can build and run normally with all devices. Thanks for all recommendation. Update: Today, i download the latest version of