Forum > C++ > Anyone tried the scoreloop wrapper upSL?

Anyone tried the scoreloop wrapper upSL?

By tookerwoot Posted 2012-08-11 02:49 Comments 20
tookerwoot
  • Posts: 4

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?

elensar
  • Posts: 14
  • Location: Prague

#1 RE: 2012-08-11 08:52

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.

moadib
  • Posts: 99

#2 RE: 2012-08-11 11:09

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 :)

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.

tookerwoot
  • Posts: 4

#3 RE: 2012-08-12 00:11

`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!

elr0nd
  • Posts: 43

#4 RE: 2012-08-22 08:00

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[]()!

moadib
  • Posts: 99

#5 RE: 2012-08-22 15:30

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

elr0nd
  • Posts: 43

#6 RE: 2012-08-23 06:24

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[]()[]()

moadib
  • Posts: 99

#7 RE: 2012-08-23 14:45

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)

elr0nd
  • Posts: 43

#8 RE: 2012-08-23 16:13

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[]()!

moadib
  • Posts: 99

#9 RE: 2012-08-23 17:42

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

moadib
  • Posts: 99

#10 RE: 2012-08-24 07:27

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 :)
http://github.com/ursine-paw/upSL/commit/49e43449e79b63db04f08ef419e495d70dba0b4e

Don’t forget to update upSL sources.

elr0nd
  • Posts: 43

#11 RE: 2012-08-28 19:53

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[]()!

elr0nd
  • Posts: 43

#12 RE: 2012-08-30 06:38

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.

Fahad3
  • Posts: 17

#13 RE: 2012-10-31 07:22

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)

Fahad3
  • Posts: 17

#14 RE: 2012-10-31 14:05

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.

edwinvanpoeijer
  • Posts: 39
  • Location: The Netherlands

#15 RE: 2012-11-03 15:13

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 :-)
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).

Fahad3
  • Posts: 17

#16 RE: 2012-11-04 21:34

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 :)

edwinvanpoeijer
  • Posts: 39
  • Location: The Netherlands

#17 RE: 2012-11-05 08:21

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 :)

Thanks, i will take a look at it :-)

jigariam
  • Posts: 10

#18 RE: 2012-12-04 13:26

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::mapstd::basic_string<char, std::basic_string<char> >**)’ 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::mapstd::basic_string<char, std::basic_string<char> >**)’ does not match any in class ‘Scoreloop::ScoreController’

Thank you.

jigariam
  • Posts: 10

#19 RE: 2012-12-05 10:37

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.

rtissera
  • Posts: 48
  • Location: Paris, France

#20 RE: 2013-01-28 16:43

Cannot use upSL with current master / (old “gles20”) branch because of lack of setEventHandler / getWindowGroupId() function to CCEGLView BlackBerry implementation.
Will take care of it and submit a pull request shortly.

Loggin to reply

Copyright © 2010 - 2013 Cocos2d-x.orgClustrmaps