Cocos2d-x get SD card picture thread UI

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.