Anyone tried the scoreloop wrapper upSL?

I have been playing around with upSL (https://github.com/ursine-paw/upSL), but I can’t seem to figure out how to integrate it. For any operation, upSL takes a callback function pointer. But if I call the static wrapper operations from my class, I do not know how to communicate my instance object when an operation is complete since upSL takes in a function pointer and not a members function pointer. The only thing I can think of is to use a static variable to communicate between the C callbacks and my instance members, but I don’t think that is a very good idea. Anyone have any thoughts?

Hi to comunicate with your instances use CCNotification when you get the callback from upSL. I send nottification in both cases (ok and errors). Subscribed instances will get these notification and can update the gui based on response codes or load aditional data from already initialized static SL controllers like next score, friends etc.

Alex Chan wrote:
>I do not know how to communicate my instance object when an operation is complete since upSL takes in a function pointer and not a members function pointer. The only thing I can think of is to use a static variable to communicate between the C callbacks and my instance members, but I don’t think that is a very good idea. Anyone have any thoughts?

Hello, as author of upSL i can say that we use static variables(Singleton pattern or global variable, not so important). Btw, on Blackberry Scorelooop have C-style API :slight_smile:

For example Achievements callback can be:

void LoadAchievementsComplete(int error_code)
{
  if (error_code == ErrorCode::Ok)
  {
    AchievementManager::Instance()->AchievementsLoaded(); // store something important for game logic, displays notification, etc.

    AchievementsLayer* achievements_layer = AchievementManager::Instance();
    if (achievements_layer)  // if user currently have opened "Achievements" screen opened
       achievements_layer->AchievementsLoaded();
  }
}

I have only wish have void* pointer to controller in all callbacks. Will look how make it if i have enough time.

`Petr Votocek, I never thought of using CCNotificationCenter. Thanks for pointing this out to me.

`Marat Yakupov, This is the route I’m currently doing but I am not sure if creating many singleton objects would be a good idea. Will look into this and the CCNotificationCenter. Thanks!

Hi Marat, first of all I want to say that your work in this wrapper is impresive, good job

I have downloaded the wrapper from https://github.com/ursine-paw/upSL and followed the Integration Guide in the wiki but I do not get my game working… I always get some JNI errors (as W/dalvikvm(1019): in Lcom/ursinepaw/scoreloop/Scoreloop;.nativeTOSAccepted:(J)V (NewGlobalRef)) so I suppose I did not set up the project in the right way.

Could someone who have used that explain where I should copy the wrapper files and provide me some advices to get it working?

Thank you very much!

Can you show your initialization code? and callback function passed to Initialize()?

Hi, thanks for your response

I followed the steps in this web http://pastebin.com/hH4GKd9s but it seems something there is not correct…

The callback function in the initialize(), what functionality should it have? As you can see I am a little bit lost… All your help will be grateful

Emilio Exposito wrote:

The callback function in the initialize(), what functionality should it have? As you can see I am a little bit lost… All your help will be grateful

Calling of this callback means that you can use Scoreloop functionality from this moment (so we create nessessary controllers & set global flag gScoreloopInitialized(which means we_can_use_scoreloop) to true)

Ok, so the callback function will be executed when the Scoreloop functionality can be used, I understand that.

On the other hand, I have tried to execute the game in Xcode and the page to accept the Scoreloop´s Terms of Service is showed, if I choose the cancel button the game is executed like always, but if I choose the accept button always a “signal SIGABRT” is launched in the main.m file and the game will close. Does this point give you an idea about what can be happening?

Just for my testings, the callback function is empty.

Thank you for all your help!

I believe that your situation like this http://github.com/ursine-paw/upSL/issues/3 :slight_smile:

Emilio Exposito wrote:

I have downloaded the wrapper from https://github.com/ursine-paw/upSL and followed the Integration Guide in the wiki but I do not get my game working… I always get some JNI errors (as W/dalvikvm(1019): in Lcom/ursinepaw/scoreloop/Scoreloop;.nativeTOSAccepted:(J)V (NewGlobalRef)) so I suppose

Thanks for report, i’ve fixed some issues and hope that this problem must be solved now :slight_smile:

Don’t forget to update upSL sources.

No problem We are all here just to help each others, aren’t we?

I have implemented my game in Xcode and it works perfect (almost, what I have done so far)… in Android it still throws exceptions when I invoke the method LoadUser, the error is “JNI WARNING: 0x412dc3e8 is not a valid JNI reference in Lcom/ursinepaw/scoreloop/Scoreloop;.nativeRequestComplete:(Lcom/scoreloop/client/android/core/controller/RequestController;IJ)V (CallObjectMethodV)” and the game is closed. I have update the files you modified some days ago… do you have any idea of what can it be happening?

Thank you for your Response!

Hi again

I “have found” the cause of the problem in my code, it was not caused by the wrapper, although the error launched indicates Scoreloop.java, I have tested my code in a real device and it works so I suppose it is a hardware limitation of the android emulator…

Marat, again, thank you very much for the extension, it opens a lot of possibilities.

guys anyone to help me regarding integration in android project, i have integrated core scoreloop but i just don’t know where to put upSL wrapper files(though i have done it for ios and everything working fine there)

the way i am putting the given wrapper files in my android project, it is giving me error in file named jni_scoreloop “error: android/jni/JniHelper.h” and when i change the import path to “platform/android/jni/JniHelper.h” it gives me error that “JniMethodInfo” and “JniHelper” has not been declared and are not in the scope.
its been such a disappointment for me, i have done everything related in ios and now my android scoring portion is only thing left before publishing my game.

fahad shafique wrote:

the way i am putting the given wrapper files in my android project, it is giving me error in file named jni_scoreloop “error: android/jni/JniHelper.h” and when i change the import path to “platform/android/jni/JniHelper.h” it gives me error that “JniMethodInfo” and “JniHelper” has not been declared and are not in the scope.
its been such a disappointment for me, i have done everything related in ios and now my android scoring portion is only thing left before publishing my game.

Can’t help you with the upSL wrapper, i had the same problems.
That’s why i’m building my own wrapper at the moment and i will share it with the community.
At the moment posting scores and posting to facebook is working :slight_smile:
When you get through the jni part (i used the simpleaudio in Cocosdension as example) then creating a wrapper is fairly basic work.

I hope to finish it this week to get my first Android game in the stores (it’s a new version of Asteroid Invaders which can already be found in the appstore for iPhone).

Edwin: i have solved them all and its working all perfect. please see https://github.com/ursine-paw/upSL/issues/6 and you will get to know what is to be done to solve the issues that i was having. i would really appreciate Marat Yakupov for his support… really admirable :slight_smile:

fahad shafique wrote:

Edwin: i have solved them all and its working all perfect. please see https://github.com/ursine-paw/upSL/issues/6 and you will get to know what is to be done to solve the issues that i was having. i would really appreciate Marat Yakupov for his support… really admirable :slight_smile:

Thanks, i will take a look at it :slight_smile:

Hi,
Anyone have try out upSL with cocos2d-2.0-x-2.0.4 ,
i am having error in jni_scoreloop.ccp
prototype for ‘void Scoreloop::ScoreController::SubmitScore(Scoreloop::ScoreController**, double, double, unsigned int, unsigned int, std::map<std::basic_string, std::basic_string >**)’ does not match any in class ‘Scoreloop::ScoreController’

and in Scoreloop.h
prototype for ‘void Scoreloop::ScoreController::SubmitScore(Scoreloop::ScoreController**, double, double, unsigned int, unsigned int, std::map<std::basic_string, std::basic_string >**)’ does not match any in class ‘Scoreloop::ScoreController’

Thank you.

Hi,
How to call SubmitScore from c++ i did know what parameter need to pass in last argument?
std::map<std::string, std::string>* context = NULL

Thank you.