display update/rendering problem while using JNI

Hello friends,

After a lot of struggle i hav successfully implemented
* Java method calls from c*+
* c*+ functions calls from java

But the problem i am facing is when i call any c++ function from java n then from that (extern ‘c’) function i call another method in same class(ex HelloWorld.cpp to display a label) i face some display render/update issue.

Sometimes the label is’nt displayed properly,instead a black image is displayed in that label content area. Or sometimes a random texture is displayed in its place.

But when i update the display(by turning on/off the display) everything is displayed properly.
I guess the issue is because the display is not being updated continuously(as in j2me) the proper effect does not takes place.
I need some solution for this problem as my game is almost completed with the third party integration, i am just doing the final touch ups n finishing.

A detailed help will be appreciated.

Hi , your problem is because when you call from C*+ to java , and java to c**, may be it is not running on UI thread anymore. So the solution is: call from java to C**, save the result to variable in C*+ and then, use scheduler to update value (CCLabel setString) later.

Thanx brother, i tried the solution an it worked……

I just want to ask one more thing that is there a way to automatically update the layer without recreating it.

For example: Suppose, once an event happens and i want to remove some item from layer and then update the layer.

Sure, I do that with scheduler

Hey Cory… thanx for the reply

you could also do something like this:

GameStore* mStoreScene = dynamic_cast(cocos2d::CCDirector::sharedDirector()->getRunningScene()->getChildByTag(1));

just make sure you have some code like this in “GameStore” init()

    if ( !CCLayer::init() )
    {
        return false;
    }

    // we set the tag so we can find this layer via the scene
    this->setTag(1);

Thanx Cory….