Note that there are some explanatory texts on larger screens.

plurals
  1. PORunning code on the main/UI thread in Cocos2dx
    primarykey
    data
    text
    <p><strong>Edit:</strong> So the issue was on the Java side. The purchase finished listener wasn't being called. This was very helpful: <a href="https://stackoverflow.com/questions/13831503/iabhelper-purchasefinishedlistener">IabHelper PurchaseFinishedListener</a></p> <p>My Cocos2dx game runs fine on Android and iOS for the most part. Only think giving me trouble is Android In-App Billing.</p> <p>I'm using JNI to call from C++ to Java. The Java code goes back and forth w/ Google Play billing system and ultimately calls back to the C++ code indicating how much treasure to give to the user (amount successfully purchased).</p> <p>The call from Java back to C++ is doing something very strange. The C++ code that runs should update the display of two things. However it only updates one and it's not consistent. Also multiple calls from Java to C++ result in CCNodes ignoring touches and doing other strange things.</p> <p>After reading up on similar issues I realized that perhaps the Java to C++ call wasn't on the main/UI thread. So I tried to fix that like this:</p> <pre><code>// Java code IabHelper.OnConsumeFinishedListener mConsumeFinishedListener = new IabHelper.OnConsumeFinishedListener() { public void onConsumeFinished(Purchase purchase, IabResult result) { if (result.isSuccess()) { String sku = purchase.getSku(); if (sku.equals(IAB_ID_ABC)) { me.runOnUiThread(new Runnable() { public void run() { callCppMethodFromJava_giveUserABC(); } }); } } }; </code></pre> <p>Here I'm trying to call giveUserABC on the main/UI thread. giveUserABC is called however it's exhibiting strange behavior as described above.</p> <p>Another thing I tried is posting a notification via CCNotificationCenter in giveUserABC. This was a shot in the dark but I read that it worked somewhere for someone.</p> <p>Unfortunately none of this has fixed the strange behavior. Any help in understanding and fixing this situation is greatly appreciated!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload