天道酬勤,学无止境

cocos2d-x-2.x

How to resize the the animating sprite in cocos2d-x

Question 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* animation = CCAnimation::createWithSpriteFrames(frames, 0.1); CCAnimate* animate = CCAnimate

2022-02-14 16:19:57    分类:技术分享    cocos2d-x   ccsprite   ccspritebatchnode   cocos2d-x-2.x

get array data from json file using rapidjson

Question 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); document.Parse<0>(clearData.c_str()); assert(document.HasMember("points")); const Value& a =

2022-01-15 07:31:37    分类:技术分享    c++   cocos2d-x-2.x   rapidjson

cocos2dx save image in to gallery android

Question 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

2022-01-12 14:58:57    分类:技术分享    android   bitmap   cocos2d-x-2.x

Cocos2D-x sample application crashes on launch

Question 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

2021-08-30 08:40:07    分类:技术分享    android   crash   cocos2d-x   cocos2d-x-2.x

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

Question 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 cocos2d-x (cocos2d-x 2.2.3). But the problem has still happened. Here is some piece of code where that

2021-04-30 17:07:38    分类:技术分享    iphone   xcode5   cocos2d-x   ios7.1   cocos2d-x-2.x