c++ - How to trigger function from main thread when the app is on resume state using cocos2dx -
i want method called inside of cocos2d::ccapplication applicationwillenterforeground()
const char * helloworld::geturi(){ javavm *jvm; //this important avoid threading errors thisenv->getjavavm(&jvm); //this important avoid threading errors jvm->attachcurrentthread(&thisenv, 0); //this important avoid threading errors //jstring jstr = thisenv->newstringutf("from jni"); jclass cls = thisenv->getobjectclass(thisobj); jmethodid method = thisenv->getmethodid(cls, "getpath","()ljava/lang/string;"); jstring result = (jstring)thisenv->callobjectmethod(thisobj, method); // call sayhello() method const char * string=thisenv->getstringutfchars(result, 0); //ccmessagebox(string,"alert"); //if(string!=null){ ccsprite* person = ccsprite::create(string); //person->setposition(ccp(visiblesize.width/2 + origin.x, visiblesize.height/2 + origin.y)); person->setanchorpoint(ccp(0, -.75)); person->setposition(ccp(0,0)); this->addchild(person,204); return string; }
Comments
Post a Comment