Scoreoid Wrapper released: UPDATED TO VERSION 2.0

Hi,

I have just “officially” released the new version of my Scoreoid cocos2d-x wrapper, the code can be downloaded from github:

version 2,0

Version 2,0 works completely different, i’m not using CCDictionary anymore but dedicated objects are returned. This should make working with the wrapper even more easier!

Version 1.0:

ScoreoidX is a wrapper for using Scoreoid leaderboards in your project. The nice thing about Scoreoid is that the interface is using http/https calls and returns xml or json files. ScoreoidX uses rapidjson (included) to process the json results. As extra i have made a login/create player to link the scores to a specific device.

There is no need to install any additional sdks for Scoreoid.

Take a look at their website for more information and to register.

www.scoreoid.net

www.scoreoid.com

Hi, I tired your wrapper and there seems to be a couple issues, however I am stomped in solving
one; when recieving the response from getNotification Api call the app crashes at.

IN FUNCTION

/*
* Process the JSON data, RapidJSON is used for this
/
CCDictionary
Scoreoid::processJSON(const char jsonData,const char apiCall, int& result)
>

HERE

CCArray* allKeys = apiDict->allKeys();
>
// Iterate through all objects
for (Value::ConstValueIterator itr = document.Begin(); itr != document.End(); ++itr)
{

Jamal Glasgow wrote:

Hi, I tired your wrapper and there seems to be a couple issues, however I am stomped in solving
one; when recieving the response from getNotification Api call the app crashes at.
>
>
IN FUNCTION
> /*
> * Process the JSON data, RapidJSON is used for this
> /
> CCDictionary
Scoreoid::processJSON(const char jsonData,const char apiCall, int& result)
>
>
HERE
> CCArray* allKeys = apiDict->allKeys();
>
> // Iterate through all objects
> for (Value::ConstValueIterator itr = document.Begin(); itr != document.End(); ++itr)
> {

Sorry for the late reply, i was ill this weekend :frowning:
Thanks for trying the wrapper, ik will check this tonight. What other issues did you have so i can resolve those also?

Thanks,
Edwin

No problem, hope your better now :slight_smile:

this~~>_playerInProgress = false;
is missing from
Scoreoid::HttpRequestPlayerCallback

If value is empty error occurs, so I placed

!value.empty
inside
const char* Scoreoid::removeEmptyFields

Also I didn’t quite understand how to deal with the return data but I figure it out after awhile, probably you could add it to your example to save people some time.

ifreturnDictionary~~>objectForKey(“api”))>getCString, “getNotification”) == 0)
{
>
>
CCArray * pResultArray = returnDictionary
>objectForKey(“result”));
CCDictionary* childDict = NULL;
CCObject* pObject = NULL;
CCARRAY_FOREACH(pResultArray, pObject)
{
childDict = (CCDictionary*)pObject;
>
>
if(!childDict)
break;
//Do something with the data
}
}

As for my previous, I think its because the getNotification api returns an object with a nested array, where as the processJSON fucntion doesn’t seem to handle the parsing properly, for now I have hard-coded the expected response for the data. You can probably have it checked if the response is an array or object with nested array of elements. I am not familiar with json nor scoreoid, so i have just be hacking away at it.

Jamal Glasgow wrote:

No problem, hope your better now :slight_smile:
>
> this~~>_playerInProgress = false;
is missing from
> Scoreoid::HttpRequestPlayerCallback
>
>
If value is empty error occurs, so I placed
> !value.empty
inside
> const char* Scoreoid::removeEmptyFields
>
>
>
Also I didn’t quite understand how to deal with the return data but I figure it out after awhile, probably you could add it to your example to save people some time.
>
> ifreturnDictionary~~>objectForKey(“api”))>getCString, “getNotification”) == 0)
> {
>
>
> CCArray * pResultArray = returnDictionary
>objectForKey(“result”));
> CCDictionary* childDict = NULL;
> CCObject* pObject = NULL;
> CCARRAY_FOREACH(pResultArray, pObject)
> {
> childDict = (CCDictionary*)pObject;
>
>
> if(!childDict)
> break;
> //Do something with the data
> }
> }
>
As for my previous, I think its because the getNotification api returns an object with a nested array, where as the processJSON fucntion doesn’t seem to handle the parsing properly, for now I have hard-coded the expected response for the data. You can probably have it checked if the response is an array or object with nested array of elements. I am not familiar with json nor scoreoid, so i have just be hacking away at it.

Thanks, i will resolve these issues.
For the notifications, your right, the handling in the processJSON function cannot handle this response, i will fix it. The notification setup from scoreoid is different then when you get all the scores for example.
I’m also planning an easier to use version of the wrapper (with dedicated objects).

Thanks for trying the scoreoid wrapper!

Great, I will be looking for to test it, keep up the good work.

Hey Edwin!

I used your ScoreoidX on my last game “Harlem Shake - Tap Game”, http://bit.ly/harlemShakeGame, and I am porting it to the iOS right now (have released to Android first without too much trouble (just changing the main stuff about UIDevice and uniqueID).

I must say that you need to update your git with the last version of cocos2d-x, otherwise it won’t run on iPhone5 (need new libcurl), and also need to add the framework for sqlite3.0 into the xcode project (if anyone runs into the same problem)

Thanks a lot for it!

Pedro Kayatt wrote:

Hey Edwin!
>
I used your ScoreoidX on my last game “Harlem Shake - Tap Game”, http://bit.ly/harlemShakeGame, and I am porting it to the iOS right now (have released to Android first without too much trouble (just changing the main stuff about UIDevice and uniqueID).
>
I must say that you need to update your git with the last version of cocos2d-x, otherwise it won’t run on iPhone5 (need new libcurl), and also need to add the framework for sqlite3.0 into the xcode project (if anyone runs into the same problem)
>
Thanks a lot for it!

Cool :slight_smile: , i will try your game tonight.
I’m at the moment finishing my next game and after that i will update scoreoidX. I don’t have any problems running the wrapper on iPhone 5 at the moment but i will look into it.

Sorry if I wasn’t clear! The ScoreoidX works with all the devices that I had tried!

The changes are needed to the Sample inside your git repository, that is out-dated :smiley:

Hope you like the game!

I compiled it and get this Errors. Which lib is missing?

Error   1   error LNK2019: unresolved external symbol "public: static class Scoreoid * __cdecl Scoreoid::GetInstance(void)" (?GetInstance@Scoreoid@@SAPAV1@XZ) referenced in function "public: virtual bool __thiscall HelloWorld::init(void)" (?init@HelloWorld@@UAE_NXZ)  C:\_00_Cocos2Dx\cocos2d-2.1rc0-x-2.1.2\LostLabyrinthMobile\proj.win32\HelloWorldScene.obj   LostLabyrinthMobile.win32
Error   3   error LNK2019: unresolved external symbol "public: static char const * __cdecl CrossPlatform::Identifiers::uniqueID(void)" (?uniqueID@Identifiers@CrossPlatform@@SAPBDXZ) referenced in function "public: virtual bool __thiscall HelloWorld::init(void)" (?init@HelloWorld@@UAE_NXZ)   C:\_00_Cocos2Dx\cocos2d-2.1rc0-x-2.1.2\LostLabyrinthMobile\proj.win32\HelloWorldScene.obj   LostLabyrinthMobile.win32
Error   2   error LNK2019: unresolved external symbol "public: bool __thiscall Scoreoid::login(char const *,bool)" (?login@Scoreoid@@QAE_NPBD_N@Z) referenced in function "public: virtual bool __thiscall HelloWorld::init(void)" (?init@HelloWorld@@UAE_NXZ)  C:\_00_Cocos2Dx\cocos2d-2.1rc0-x-2.1.2\LostLabyrinthMobile\proj.win32\HelloWorldScene.obj   LostLabyrinthMobile.win32
Error   7   error LNK2001: unresolved external symbol "public: virtual void __thiscall HelloWorld::scoreoidAvailable(class cocos2d::CCDictionary *,char const *,int &)" (?scoreoidAvailable@HelloWorld@@UAEXPAVCCDictionary@cocos2d@@PBDAAH@Z)  C:\_00_Cocos2Dx\cocos2d-2.1rc0-x-2.1.2\LostLabyrinthMobile\proj.win32\HelloWorldScene.obj   LostLabyrinthMobile.win32
Error   4   error LNK2001: unresolved external symbol "public: virtual void __thiscall HelloWorld::scoreCallback(class cocos2d::CCDictionary *,char const *,int &)" (?scoreCallback@HelloWorld@@UAEXPAVCCDictionary@cocos2d@@PBDAAH@Z)  C:\_00_Cocos2Dx\cocos2d-2.1rc0-x-2.1.2\LostLabyrinthMobile\proj.win32\HelloWorldScene.obj   LostLabyrinthMobile.win32
Error   5   error LNK2001: unresolved external symbol "public: virtual void __thiscall HelloWorld::playerCallback(class cocos2d::CCDictionary *,char const *,int &)" (?playerCallback@HelloWorld@@UAEXPAVCCDictionary@cocos2d@@PBDAAH@Z)    C:\_00_Cocos2Dx\cocos2d-2.1rc0-x-2.1.2\LostLabyrinthMobile\proj.win32\HelloWorldScene.obj   LostLabyrinthMobile.win32
Error   6   error LNK2001: unresolved external symbol "public: virtual void __thiscall HelloWorld::gameCallback(class cocos2d::CCDictionary *,char const *,int &)" (?gameCallback@HelloWorld@@UAEXPAVCCDictionary@cocos2d@@PBDAAH@Z)    C:\_00_Cocos2Dx\cocos2d-2.1rc0-x-2.1.2\LostLabyrinthMobile\proj.win32\HelloWorldScene.obj   LostLabyrinthMobile.win32

I think you didn’t import the codes of scoreid as it should, I had that problem first.

Try to import without folders, but with filters…it should help!

[]’s

I add more libs now and it works better.
Only this is missed:

Error   2   error LNK2019: unresolved external symbol "public: static char const * __cdecl CrossPlatform::Identifiers::uniqueID(void)" (?uniqueID@Identifiers@CrossPlatform@@SAPBDXZ) referenced in function "public: virtual bool __thiscall HelloWorld::init(void)" (?init@HelloWorld@@UAE_NXZ)   C:\_00_Cocos2Dx\cocos2d-2.1rc0-x-2.1.2\LostLabyrinthMobile\proj.win32\HelloWorldScene.obj   LostLabyrinthMobile.win32

I add more libs now and it works better.
Only this is missed:

Error   2   error LNK2019: unresolved external symbol "public: static char const * __cdecl CrossPlatform::Identifiers::uniqueID(void)" (?uniqueID@Identifiers@CrossPlatform@@SAPBDXZ) referenced in function "public: virtual bool __thiscall HelloWorld::init(void)" (?init@HelloWorld@@UAE_NXZ)   C:\_00_Cocos2Dx\cocos2d-2.1rc0-x-2.1.2\LostLabyrinthMobile\proj.win32\HelloWorldScene.obj   LostLabyrinthMobile.win32

I did not found a cpp wich has the implementation of CrossPlatform::Identifiers::uniqueID(void);

I changed this source line:

Scoreoid::GetInstance()->login(CrossPlatform::Identifiers::uniqueID(), false);

to

Scoreoid::GetInstance()->login("TEST", false);

And I got this error from scoreoid now:

FIELD:username=TEST
Posting:api_key=YOUR API KEY&game_id=YOUR GAME IDE&response=json&username=TEST
API: CREATE PLAYER FAILED

How can I test it with an correct CREATE PLAYER? (Or did i forget to read something?)

P. E. wrote:

I changed this source line:
[…]
to
[…]
And I got this error from scoreoid now:
[…]
How can I test it with an correct CREATE PLAYER? (Or did i forget to read something?)

You should setup your API key and GAME key, in the response you see that they are not defined.

Ahh. I understand. Thanks.
But what about the link error with:

Error    2    error LNK2019: unresolved external symbol "public: static char const * __cdecl CrossPlatform::Identifiers::uniqueID(void)" (?uniqueID@Identifiers@CrossPlatform@@SAPBDXZ) referenced in function "public: virtual bool __thiscall HelloWorld::init(void)" (?init@HelloWorld@@UAE_NXZ) 

P. E. wrote:

Ahh. I understand. Thanks.
But what about the link error with:
[…]

Did you include the cross platform files? , i think they are only for iOS at the moment (i will fix that as soon as possible).
I use the uniqueID to create a new user, the Android part isn’t implemented yet (i noticed now).