Posts Tagged ‘Scoreloop’


01.07.2011

In-Game Scoreloop Account Access

posted by Karsten

in Uncategorized

It is relatively simple to set up the Scoreloop system within a game using the ScoreloopUI interface that comes with the API download. You just follow the instruction in the docs and voilà, it works, or at least it did for me 😉

However, I wanted to implement a feature in one of my games Rune Escape where I had to check the current in-game currency account, and based on that either show ads or give the user adfreedom within the game. (If this sounds difficult to understand, just download the game, it really isn’t)

I had quite a lot of problems implementing this feature, and I thought that others might benefit from the solution to my problems!

The solution lies in the Scoreloop Core API. What ever you do, do not try and do it by changing the ScoreloopUI code. I tried to do that, but you cannot be certain that the account is correct. The account there is maintaining the integrity, seemingly, for the UI, and not for “hackers” like me. What you need to do is to use the com.scoreloop.client.android.core.controller.UserController object to access the account. This is a little dubious as it is deprecated, but ChallengesController isn’t, and it is performing a similar job accessing challenges instead of the user account, so I assume it is OK, and the documentation doesn’t suggest any new method for accessing the account info.

In order to start the process you should get a UserController and load the user, I do this in the onCreate() of the game’s main Activity:

UserController myUserController = new UserController(this);

myUserController.loadUser();

The argument of UserController accepts a com.scoreloop.client.android.core.controller.UserControllerObserver, so the Activity should implement this interface:

public class GameActivity extends Activity implements UserControllerObserver {

(Alternatively you could do this in a separate class)

loadUser() access the Scoreloop servers and load the user account details. Once it has that it will call public void requestControllerDidReceiveResponse(RequestController cont) and you can now access the information through Session checking which Controller made the request through cont. For  instance this way you can access the balance of the user’s account:

if(cont instanceof UserController) {

Money m = Session.getCurrentSession().getBalance();

float fMoney = m.getAmount().floatValue();

//and do stuff

}

There are quite a few different Controllers available through the Scoreloop Core API and they all work this way, which is great. The only problem is that if you user the game’s Activity class as the Observer for all of them, they all will call requestControllerDidReceiveResponse and that could become a right mess, therefore if you have more than one Controller make sure you check thoroughly what you receive using cont, or alternatively, create Observer objects for each individual Controller – that keeps it clean!

If something goes wrong while the Controller fetch the data from Scoreloop the method public void requestControllerDidFail(RequestController arg0, Exception arg1) is called, and you can do whatever you need to do in that situation. (inform user, what ever…)

 

That’s it, this is all you need to do! I hope this will help someone…

Share
30.06.2011

Amazon Market not allowing Scoreloop Social Market – Solution

posted by Karsten

in Uncategorized

I’ve tried to have Android Apps been accepted to Amazon App Store with the Scoreloop Social Market, but was recently turned down in another game because the Social Market contain links to outside markets, i.e. Android Market.

This is not a unique experience as many people have reported similar issues (both acceptance and non-acceptance) due to this. Therefore, as the Samaritan I am, I thought I’d show how you remove the Social Market from the Scoreloop user interface. I don’t like doing it, as I believe I get a few downloads that way myself, but in times of trouble I believe this is one of the reasons why Scoreloop provide the source code to the developers.

Ok, the solution:

1:

Go to com.scoreloop.client.android.ui.ScoreloopManager and add

void setShowSocialMarke(boolean show);

to the interface.

 

2:

Go to com.scoreloop.client.android.ui.StandardScoreloopManager and add

private boolean showSocialMarket = true;

to the class.

 

3:

and add

@Override

public void setShowSocialMarke(boolean show) {

this.showSocialMarket = show;

}

 

4:

surround the line

description.addShortcutDescription(R.string.sl_market, R.drawable.sl_shortcut_market_default, R.drawable.sl_shortcut_market_active);

in the method

private ScreenDescription createScreenDescription(final User user, final Game game, final boolean useCached)

with a conditional on showScoialMarket, so that it reads:

if(showSocialMarket) {

description.addShortcutDescription(R.string.sl_market, R.drawable.sl_shortcut_market_default, R.drawable.sl_shortcut_market_active);

}

5:

Add the line:
ScoreloopManagerSingleton.get().setShowSocialMarke(false);

in your game Activity in onCreate()

6:

in method public ScreenDescription createEntryScreenDescription() in the line

description.setBodyDescription(new Intent(getContext(), EntryListActivity.class));

change to

if(this.showSocialMarket) description.setBodyDescription(new Intent(getContext(), EntryListActivity.class));

 

That’s it, this does the trick! Hope it helps you! Even though I really hate to shut these things off…

 

Share