Get the SD card picture:
ccsprite* psprite = ccsprite::create ("/mnt/sdcard/x.png");
/mnt/sdcard is the root directory of the SD card, some of the machine is/sdcard, so it is best to use the internal function to obtain the root directory of the SD card.
UI updates cannot be thread on a child line, so there will be black or white blocks or just hanging off
Get a timer schedule real-time monitoring if you want to update the UI
. h file
class Public Cocos2d::cclayer { public: virtualbool init (); static cocos2d::ccscene* scene (); Create_func (A);
void setImagePath (const char * ImagePath);
BOOL m_ui; Whether to update the UI
Virtual void Update (float fdelta); // UI Update
. cpp Files
BOOLA::init () {if( !Cclayer::init ()) { return false; } This->scheduleupdate ();//call once per frame} voidA::setimagepath (Const Char* ImagePath)//Child thread Invocation{m_ui=true;}voidA::update (floatFdelta) { if(m_ui) {m_ui=false; //UI Update }}
Cocos2d-x get SD card picture thread UI