<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>XPG Live</title>
	<atom:link href="http://blog.xpglive.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.xpglive.com</link>
	<description>social gamng without limits</description>
	<lastBuildDate>Sun, 20 May 2012 14:43:38 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>How To: Use Leaderboards on BlackBerry with XPG</title>
		<link>http://blog.xpglive.com/2012/01/30/how-to-use-leaderboards-on-blackberry-with-xpg/</link>
		<comments>http://blog.xpglive.com/2012/01/30/how-to-use-leaderboards-on-blackberry-with-xpg/#comments</comments>
		<pubDate>Mon, 30 Jan 2012 23:52:33 +0000</pubDate>
		<dc:creator>Troy (XPG)</dc:creator>
				<category><![CDATA[CodeProject]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[XPG Games]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[BlackBerry]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[cross-platform]]></category>
		<category><![CDATA[Dev]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Framework]]></category>
		<category><![CDATA[Game]]></category>
		<category><![CDATA[GUI]]></category>
		<category><![CDATA[IDE]]></category>
		<category><![CDATA[Intermediate]]></category>
		<category><![CDATA[Leaderboard]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Posting]]></category>
		<category><![CDATA[Retrieving]]></category>
		<category><![CDATA[Score]]></category>
		<category><![CDATA[UI]]></category>
		<category><![CDATA[XPG]]></category>

		<guid isPermaLink="false">http://blog.xpglive.com/?p=295</guid>
		<description><![CDATA[This is a continuation of the How To series. This previous post is here. This article will cover: Leaderboard types and setup Accessing leaderboards in game Posting a score to a leaderboard Retrieving scores from a leaderboard Prerequisites Eclipse with BlackBerry plugin XPG Live API for BlackBerry An existing project or XPG Demo Source for [...]]]></description>
				<content:encoded><![CDATA[<p>This is a continuation of the How To series. This previous post is <a href="http://blog.xpglive.com/?p=216">here</a>.</p>
<p>This article will cover:</p>
<ul>
<li>Leaderboard types and setup </li>
<li>Accessing leaderboards in game </li>
<li>Posting a score to a leaderboard </li>
<li>Retrieving scores from a leaderboard </li>
</ul>
<ul></ul>
<p>Prerequisites</p>
<ul>
<li><a href="http://us.blackberry.com/developers/javaappdev/javaplugin.jsp">Eclipse with BlackBerry plugin</a></li>
<li><a href="http://www.xpglive.com/downloads">XPG Live API for BlackBerry</a></li>
<li>An existing project or <a href="http://www.xpglive.com/downloads">XPG Demo Source for BlackBerry</a></li>
</ul>
<h4>Leaderboard types and setup</h4>
<p>In order to setup a leaderboard you’ll need to have a free developer account with XPG and have registered a game in the management app. Assuming you’ve done these things, you can click on the leaderboards tab in the management app and begin defining your leaderboards. </p>
<p align="center"><a href="http://blog.xpglive.com/wp-content/uploads/2012/01/image24.png"><img title="image" border="0" alt="image" src="http://blog.xpglive.com/wp-content/uploads/2012/01/image_thumb24.png" width="396" height="350" /></a></p>
<p>In the above image you can see the leaderboard dialog. As with most display values in the XPG system, the leaderboard name is globalized to help you provide a local experience for the end user. A display image can be defined by clicking the icon in the top right corner. The XPG system allows you to define a game-unique identifier for your leaderboard which is particularly helpful when migrating from another system to XPG, or implementing XPG along side another system. The available score types are Float, Integer, Money, and Time and each can be used with a score order of Ascending or Descending. The score order indicates if the high scores take high ranks (Descending) or if the lower scores take high ranks (Ascending). You can also limit this leaderboard’s availability by game version. Game versions are defined on the Access Keys tab in the Games area of the management app. Each version gets a new access key (or secret key) which positively identifies your game and game version.</p>
<p align="center"><a href="http://blog.xpglive.com/wp-content/uploads/2012/01/image25.png"><img title="image" border="0" alt="image" src="http://blog.xpglive.com/wp-content/uploads/2012/01/image_thumb25.png" width="420" height="214" /></a></p>
<h4>Accessing leaderboards in game</h4>
<p>As with many things in XPG, accessing leaderboards within your game is very simple. When your game was initialized (<a href="http://blog.xpglive.com/2012/01/08/how-to-initialize-a-game-on-blackberry-with-xpg/" target="_blank">discussed in this post</a>) the leaderboards defined in the&#160; were loaded in-game. Once these leaderboards were loaded the first page of scores for each of them was also retrieved and loaded.</p>
<p></p><pre class="crayon-plain-tag">public ScreenLeaderboard(XPGLeaderboardInfo leaderboard) {
	super(MainScreen.VERTICAL_SCROLL | MainScreen.VERTICAL_SCROLLBAR);

	if (leaderboard == null) {
		close();
	}

	lb = leaderboard;

	grid = new GridFieldManager(20, 1, FIELD_LEFT);
	managerRow1 = new HorizontalFieldManager(FIELD_LEFT);

	labelInfo = new LabelField(lb.getDisplayName());
	managerRow1.add(buttonRefresh);
	managerRow1.add(buttonScoreHigh);
	managerRow1.add(buttonScoreMed);
	managerRow1.add(buttonScoreLow);

	grid.add(labelInfo, FIELD_LEFT);
	grid.add(managerRow1, FIELD_LEFT);
}</pre><p></p>
<h4>Posting a score to a leaderboard</h4>
<p>There are overloads provided to work with each of the score types mentioned above. The API will perform local updates of the leaderboard data after posting a score to the server when it detects that no user data from other players has affected the ranking other than the local user. Alternatively, the API will also initiate a full update of the leaderboard local data if it detects that one or more users have affected the leaderboard ranking other than the local user. This is all handled auto-magically in order to conserve bandwidth, processor time, and device battery.</p>
<p>Here is an example of score posting simplicity.</p>
<p></p><pre class="crayon-plain-tag">buttonScoreHigh.setCommand(new Command(new CommandHandler() {
	public void execute(ReadOnlyCommandMetadata metadata, Object context) {
		if (userScore != null) {
			XPGAPI.Instance.submitScore(
					lb.getLeaderboardTag(),
					new Double(
							userScore.getUserScore().doubleValue() + 10),
					null);
		} else {
			try {
				XPGLeaderboardScoreInfo score = ((XPGLeaderboardScoreInfo) scores
						.elementAt(0));
				XPGAPI.Instance.submitScore(
						lb.getLeaderboardTag(),
						new Double(
								score.getUserScore().doubleValue() + 10),
						null);
			} catch (Exception e) {
				XPGAPI.Instance.submitScore(lb.getLeaderboardTag(),
						new Double(10), null);
			}
		}
	}
}));</pre><p></p>
<h4>Retrieving scores from a leaderboard</h4>
<p>Retrieving scores from XPG is equally simple. The scores are stored locally on the leaderboard instance of the initialized game instance, so there are no collections for you to keep up with and manage on your own. Also, leaderboards support paging, so you are not required to have all the ranked user scores in memory at once.</p>
<p></p><pre class="crayon-plain-tag">//Hook event to trigger getting scores
buttonRefresh.setCommand(new Command(new CommandHandler() {
	public void execute(ReadOnlyCommandMetadata metadata, Object context) {
		XPGAPI.Instance.getScores(lb.getLeaderboardTag(), new Long(0),
				null);
	}
}));

//Set GetScores callback
XPGAPI.Instance.setCallbackGetScores(new XPGAPICallbackGetScores() {
	public void gotResponse(XPGAPIResponse response,
			XPGScoresResultInfo body) {
		if (!response.getFailed().booleanValue() &amp;&amp; body != null) {
			clearScores();
			scores = body.getScores();
			displayScores();
		}
	}
});

// Clear previously displayed scores
private void clearScores() {
	grid.deleteRange(2, grid.getRowCount() - 2);
}

// Displayed new scores from server
private void displayScores() {
	if (scores != null &amp;&amp; scores.size() &gt; 0) {
		for (int i = 0; i &lt; scores.size(); i++) {
			final XPGLeaderboardScoreInfo score = (XPGLeaderboardScoreInfo) scores
					.elementAt(i);
			HorizontalFieldManager hfm = new HorizontalFieldManager(
					FIELD_LEFT);
			LabelField labelUser = new LabelField(&quot;User: &quot;
					+ score.getUserNameDisplay());
			labelUser.setMargin(0, 15, 0, 0);
			LabelField labelScore = new LabelField(&quot;Score: &quot;
					+ String.valueOf(score.getUserScore()));

			hfm.add(labelUser);
			hfm.add(labelScore);
			grid.add(hfm, Field.FIELD_LEFT);
			if (score.getUserName().equalsIgnoreCase(
					XPGAPI.Instance.getCurrentUser().getUserName())) {
				userScore = score;
			}
		}
	}
}</pre><p></p>
<h4 align="left">Full Code</h4>
<p></p><pre class="crayon-plain-tag">package XPG.Demo.BlackBerry;

import java.util.Vector;

import net.rim.device.api.command.Command;
import net.rim.device.api.command.CommandHandler;
import net.rim.device.api.command.ReadOnlyCommandMetadata;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.component.ButtonField;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.container.GridFieldManager;
import net.rim.device.api.ui.container.HorizontalFieldManager;
import net.rim.device.api.ui.container.MainScreen;

import com.xpglive.api.XPGAPI;
import com.xpglive.api.XPGAPICallbackGetScores;
import com.xpglive.api.XPGAPICallbackSubmitScore;
import com.xpglive.api.XPGAPIResponse;
import com.xpglive.api.XPGLeaderboardInfo;
import com.xpglive.api.XPGLeaderboardScoreInfo;
import com.xpglive.api.XPGScoreResultInfo;
import com.xpglive.api.XPGScoresResultInfo;

public class ScreenLeaderboard extends MainScreen {
	private GridFieldManager grid;
	HorizontalFieldManager managerRow1;
	private LabelField labelInfo;
	private ButtonField buttonRefresh = new ButtonField(&quot;Refresh&quot;);
	private ButtonField buttonScoreHigh = new ButtonField(&quot;High&quot;);
	private ButtonField buttonScoreMed = new ButtonField(&quot;Med&quot;);
	private ButtonField buttonScoreLow = new ButtonField(&quot;Low&quot;);
	private XPGLeaderboardInfo lb;
	private XPGLeaderboardScoreInfo userScore;

	private Vector scores;

	public ScreenLeaderboard(XPGLeaderboardInfo leaderboard) {
		super(MainScreen.VERTICAL_SCROLL | MainScreen.VERTICAL_SCROLLBAR);

		if (leaderboard == null) {
			close();
		}

		lb = leaderboard;

		grid = new GridFieldManager(20, 1, FIELD_LEFT);
		managerRow1 = new HorizontalFieldManager(FIELD_LEFT);

		labelInfo = new LabelField(lb.getDisplayName());
		managerRow1.add(buttonRefresh);
		managerRow1.add(buttonScoreHigh);
		managerRow1.add(buttonScoreMed);
		managerRow1.add(buttonScoreLow);

		grid.add(labelInfo, FIELD_LEFT);
		grid.add(managerRow1, FIELD_LEFT);

		buttonRefresh.setCommand(new Command(new CommandHandler() {
			public void execute(ReadOnlyCommandMetadata metadata, Object context) {
				XPGAPI.Instance.getScores(lb.getLeaderboardTag(), new Long(0),
						null);
			}
		}));

		buttonScoreHigh.setCommand(new Command(new CommandHandler() {
			public void execute(ReadOnlyCommandMetadata metadata, Object context) {
				if (userScore != null) {
					XPGAPI.Instance.submitScore(
							lb.getLeaderboardTag(),
							new Double(
									userScore.getUserScore().doubleValue() + 10),
							null);
				} else {
					try {
						XPGLeaderboardScoreInfo score = ((XPGLeaderboardScoreInfo) scores
								.elementAt(0));
						XPGAPI.Instance.submitScore(
								lb.getLeaderboardTag(),
								new Double(
										score.getUserScore().doubleValue() + 10),
								null);
					} catch (Exception e) {
						XPGAPI.Instance.submitScore(lb.getLeaderboardTag(),
								new Double(10), null);
					}
				}
			}
		}));

		buttonScoreMed.setCommand(new Command(new CommandHandler() {
			public void execute(ReadOnlyCommandMetadata metadata, Object context) {
				if (userScore != null) {
					XPGAPI.Instance.submitScore(
							lb.getLeaderboardTag(),
							new Double(
									userScore.getUserScore().doubleValue() + 5),
							null);
				} else {
					try {
						XPGLeaderboardScoreInfo score = ((XPGLeaderboardScoreInfo) scores
								.elementAt(0));
						XPGAPI.Instance.submitScore(
								lb.getLeaderboardTag(),
								new Double(
										score.getUserScore().doubleValue() + 5),
								null);
					} catch (Exception e) {
						XPGAPI.Instance.submitScore(lb.getLeaderboardTag(),
								new Double(5), null);
					}
				}
			}
		}));

		buttonScoreLow.setCommand(new Command(new CommandHandler() {
			public void execute(ReadOnlyCommandMetadata metadata, Object context) {
				if (userScore != null) {
					XPGAPI.Instance.submitScore(
							lb.getLeaderboardTag(),
							new Double(
									userScore.getUserScore().doubleValue() + 1),
							null);
				} else {
					try {
						XPGLeaderboardScoreInfo score = ((XPGLeaderboardScoreInfo) scores
								.elementAt(0));
						XPGAPI.Instance.submitScore(
								lb.getLeaderboardTag(),
								new Double(
										score.getUserScore().doubleValue() + 1),
								null);
					} catch (Exception e) {
						XPGAPI.Instance.submitScore(lb.getLeaderboardTag(),
								new Double(1), null);
					}
				}
			}
		}));

		XPGAPI.Instance.setCallbackGetScores(new XPGAPICallbackGetScores() {
			public void gotResponse(XPGAPIResponse response,
					XPGScoresResultInfo body) {
				if (!response.getFailed().booleanValue() &amp;&amp; body != null) {
					clearScores();
					scores = body.getScores();
					displayScores();
				}
			}
		});

		XPGAPI.Instance.setCallbackSubmitScore(new XPGAPICallbackSubmitScore() {
			public void gotResponse(XPGAPIResponse response,
					XPGScoreResultInfo body) {
				if (!response.getFailed().booleanValue() &amp;&amp; body != null) {
					XPGAPI.Instance.getScores(lb.getLeaderboardTag(), new Long(
							0), null);
				}
			}
		});

		add(grid);

		if (lb.getScores() != null &amp;&amp; lb.getScores().size() &gt; 0) {
			clearScores();
			scores = lb.getScores();
			displayScores();
		}
	}

	private void clearScores() {
		grid.deleteRange(2, grid.getRowCount() - 2);
	}

	private void displayScores() {
		if (scores != null &amp;&amp; scores.size() &gt; 0) {
			for (int i = 0; i &lt; scores.size(); i++) {
				final XPGLeaderboardScoreInfo score = (XPGLeaderboardScoreInfo) scores
						.elementAt(i);
				HorizontalFieldManager hfm = new HorizontalFieldManager(
						FIELD_LEFT);
				LabelField labelUser = new LabelField(&quot;User: &quot;
						+ score.getUserNameDisplay());
				labelUser.setMargin(0, 15, 0, 0);
				LabelField labelScore = new LabelField(&quot;Score: &quot;
						+ String.valueOf(score.getUserScore()));

				hfm.add(labelUser);
				hfm.add(labelScore);
				grid.add(hfm, Field.FIELD_LEFT);
				if (score.getUserName().equalsIgnoreCase(
						XPGAPI.Instance.getCurrentUser().getUserName())) {
					userScore = score;
				}
			}
		}
	}
}</pre><p></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.xpglive.com/2012/01/30/how-to-use-leaderboards-on-blackberry-with-xpg/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How To: Use Leaderboards on Android with XPG</title>
		<link>http://blog.xpglive.com/2012/01/30/how-to-use-leaderboards-on-android-with-xpg/</link>
		<comments>http://blog.xpglive.com/2012/01/30/how-to-use-leaderboards-on-android-with-xpg/#comments</comments>
		<pubDate>Mon, 30 Jan 2012 23:14:43 +0000</pubDate>
		<dc:creator>Troy (XPG)</dc:creator>
				<category><![CDATA[CodeProject]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[XPG Games]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[Android]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[cross-platform]]></category>
		<category><![CDATA[Dev]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Framework]]></category>
		<category><![CDATA[Game]]></category>
		<category><![CDATA[Generics]]></category>
		<category><![CDATA[GUI]]></category>
		<category><![CDATA[IDE]]></category>
		<category><![CDATA[Intermediate]]></category>
		<category><![CDATA[Leaderboard]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Mono]]></category>
		<category><![CDATA[MonoDroid]]></category>
		<category><![CDATA[Posting]]></category>
		<category><![CDATA[Retrieving]]></category>
		<category><![CDATA[Score]]></category>
		<category><![CDATA[UI]]></category>
		<category><![CDATA[XPG]]></category>

		<guid isPermaLink="false">http://blog.xpglive.com/?p=290</guid>
		<description><![CDATA[This is a continuation of the How To series. This previous post is here. This article will cover: Leaderboard types and setup Accessing leaderboards in game Posting a score to a leaderboard Retrieving scores from a leaderboard Prerequisites Android SDK Eclipse or Visual Studio with MonoDroid XPG Live API for Android or MonoDroid An existing [...]]]></description>
				<content:encoded><![CDATA[<p>This is a continuation of the How To series. This previous post is <a href="http://blog.xpglive.com/?p=216">here</a>.</p>
<p>This article will cover:</p>
<ul>
<li>Leaderboard types and setup </li>
<li>Accessing leaderboards in game </li>
<li>Posting a score to a leaderboard </li>
<li>Retrieving scores from a leaderboard </li>
</ul>
<ul></ul>
<p>Prerequisites</p>
<ul>
<li><a href="http://developer.android.com/sdk/index.html">Android SDK</a> </li>
<li><a href="http://www.eclipse.org/downloads/">Eclipse</a> or <a href="http://www.microsoft.com/visualstudio/en-us/products/2010-editions/express">Visual Studio</a> with <a href="http://xamarin.com/monoforandroid">MonoDroid</a> </li>
<li><a href="http://www.xpglive.com/downloads">XPG Live API for Android or MonoDroid</a> </li>
<li>An existing project or <a href="http://www.xpglive.com/en/downloads">XPG Demo Source for Android or MonoDroid</a> </li>
</ul>
<h4>Leaderboard types and setup</h4>
<p>In order to setup a leaderboard you’ll need to have a free developer account with XPG and have registered a game in the management app. Assuming you’ve done these things, you can click on the leaderboards tab in the management app and begin defining your leaderboards.</p>
<p align="center"><a href="http://blog.xpglive.com/wp-content/uploads/2012/01/image24.png"><img title="image" border="0" alt="image" src="http://blog.xpglive.com/wp-content/uploads/2012/01/image_thumb24.png" width="396" height="350" /></a></p>
<p>In the above image you can see the leaderboard dialog. As with most display values in the XPG system, the leaderboard name is globalized to help you provide a local experience for the end user. A display image can be defined by clicking the icon in the top right corner. The XPG system allows you to define a game-unique identifier for your leaderboard which is particularly helpful when migrating from another system to XPG, or implementing XPG along side another system. The available score types are Float, Integer, Money, and Time and each can be used with a score order of Ascending or Descending. The score order indicates if the high scores take high ranks (Descending) or if the lower scores take high ranks (Ascending). You can also limit this leaderboard’s availability by game version. Game versions are defined on the Access Keys tab in the Games area of the management app. Each version gets a new access key (or secret key) which positively identifies your game and game version.</p>
<p align="center"><a href="http://blog.xpglive.com/wp-content/uploads/2012/01/image25.png"><img title="image" border="0" alt="image" src="http://blog.xpglive.com/wp-content/uploads/2012/01/image_thumb25.png" width="420" height="214" /></a></p>
<h4>Accessing leaderboards in game</h4>
<p>As with many things in XPG, accessing leaderboards within your game is very simple. When your game was initialized (<a href="http://blog.xpglive.com/?p=216" target="_blank">discussed in this post</a>) the leaderboards defined in the <a href="http://www.xpglive.com/manage" target="_blank">XPG Management App</a> were loaded in-game. Once these leaderboards were loaded the first page of scores for each of them was also retrieved and loaded.</p>
<p>Java Code</p>
<p>  </p><pre class="crayon-plain-tag">@Override
protected void onStart() {
	super.onStart();
	position = this.getIntent().getIntExtra(&quot;position&quot;, 0);
	lb = XPGAPI.Instance.getCurrentGame().getLeaderboards().get(position);

	if (lb == null) {
		onBackPressed();
	}

	Button refreshButton = (Button) findViewById(R.id.lbview_buttonRefresh);
	refreshButton.setOnClickListener(new OnRefreshClicked());

	Button scoreHighButton = (Button) findViewById(R.id.lbview_scoreHigh);
	scoreHighButton.setOnClickListener(new OnScoreHighClicked());

	Button scoreMedButton = (Button) findViewById(R.id.lbview_scoreMed);
	scoreMedButton.setOnClickListener(new OnScoreMedClicked());

	Button scoreLowButton = (Button) findViewById(R.id.lbview_scoreLow);
	scoreLowButton.setOnClickListener(new OnScoreLowClicked());

	scores = lb.getScores();

	TextView tt = (TextView) findViewById(R.id.lbview_name);
	if (tt != null) {
		tt.setText(lb.getDisplayName());
	}

	if (scores != null &amp;&amp; scores.size() &gt; 0) {
		ListView lv = (ListView) findViewById(R.id.lbview_items);
		lv.setAdapter(new AdapterLeaderboardScores(
				ActivityLeaderboard.this, R.layout.lbview_listitem, scores));
	}

	XPGAPI.Instance.setCallbackSubmitScore(new SubmitScoreCompleted());
}</pre><p></p>
<p>C# Code</p>
<p></p><pre class="crayon-plain-tag">protected override void OnStart()
{
	base.OnStart();
	position = this.Intent.GetIntExtra(&quot;position&quot;, 0);

	try
	{
		lb = XPGAPI.Instance.CurrentGame.Leaderboards[position];
	}
	catch
	{
		OnBackPressed();
	}

	if (lb == null) { OnBackPressed(); }

	scores = lb.Scores.ToList();

	Button refreshButton = FindViewById&lt;Button&gt;(Resource.Id.lbview_buttonRefresh);
	refreshButton.Click += OnRefreshClicked;

	Button scoreHighButton = FindViewById&lt;Button&gt;(Resource.Id.lbview_scoreHigh);
	scoreHighButton.Click += OnScoreHighClicked;

	Button scoreMedButton = FindViewById&lt;Button&gt;(Resource.Id.lbview_scoreMed);
	scoreMedButton.Click += OnScoreMedClicked;

	Button scoreLowButton = FindViewById&lt;Button&gt;(Resource.Id.lbview_scoreLow);
	scoreLowButton.Click += OnScoreLowClicked;

	TextView tt = FindViewById&lt;TextView&gt;(Resource.Id.lbview_name);
	if (tt != null)
	{
		tt.SetText(lb.DisplayName, TextView.BufferType.Normal);
	}

	ListView lv = FindViewById&lt;ListView&gt;(Resource.Id.lbview_items);
	if (scores != null &amp;&amp; scores.Count &gt; 0)
	{
		lv.Adapter = new AdapterLeaderboardScores(this, Resource.Layout.lbview_listitem, scores);
	}
}</pre><p></p>
<h4>Posting a score to a leaderboard</h4>
<p>There are overloads in C# and Java provided to work with each of the score types mentioned above. The API will perform local updates of the leaderboard data after posting a score to the server when it detects that no user data from other players has affected the ranking other than the local user. Alternatively, the API will also initiate a full update of the leaderboard local data if it detects that one or more users have affected the leaderboard ranking other than the local user. This is all handled auto-magically in order to conserve bandwidth, processor time, and device battery.</p>
<p>Here is an example of score posting simplicity.</p>
<p>Java Code </p>
<p></p><pre class="crayon-plain-tag">private class OnScoreHighClicked implements OnClickListener {
	@Override
	public void onClick(View arg0) {
		if (userScore != null) {
			XPGAPI.Instance.submitScore(lb.getLeaderboardTag(), new Double(
					userScore.getUserScore().doubleValue() + 10), null);
		} else {
			try {
				XPGLeaderboardScoreInfo score = ((XPGLeaderboardScoreInfo) scores
						.get(0));
				XPGAPI.Instance
						.submitScore(lb.getLeaderboardTag(), new Double(
								score.getUserScore().doubleValue() + 10),
								null);
			} catch (Exception e) {
				XPGAPI.Instance.submitScore(lb.getLeaderboardTag(),
						new Double(10), null);
			}
		}
	}
}</pre><p></p>
<p>C# Code </p>
<p></p><pre class="crayon-plain-tag">public void OnScoreHighClicked(object sender, EventArgs e)
{
	if (userScore != null)
	{
		XPGAPI.Instance.SubmitScore(lb.LeaderboardTag, userScore.UserScore + 10, SubmitScoreCompleted);
	}
	else
	{
		try
		{
			XPGLeaderboardScoreInfo score = scores[0];
			XPGAPI.Instance.SubmitScore(lb.LeaderboardTag, score.UserScore + 10, SubmitScoreCompleted);
		}
		catch (Exception ex)
		{
			XPGAPI.Instance.SubmitScore(lb.LeaderboardTag, 10, SubmitScoreCompleted);
		}
	}
}</pre><p></p>
<h4>Retrieving scores from a leaderboard</h4>
<p>Retrieving scores from XPG is equally simple. The scores are stored locally on the leaderboard instance of the initialized game instance, so there are no collections for you to keep up with and manage on your own. Also, leaderboards support paging, so you are not required to have all the ranked user scores in memory at once.</p>
<p>Java Code </p>
<p></p><pre class="crayon-plain-tag">private class OnRefreshClicked implements OnClickListener {
	@Override
	public void onClick(View arg0) {
		XPGAPI.Instance.getScores(lb.getLeaderboardTag(), 0,
				new GetScoresCompleted());
	}
}

private class GetScoresCompleted extends
			XPGAPICallbackGeneric&lt;XPGScoresResultInfo&gt; {
	@Override
	public void gotResponse(
			XPGAPIResponseGeneric&lt;XPGScoresResultInfo&gt; response) {
		if (!response.getFailed() &amp;&amp; response.getBody() != null) {
			lb = XPGAPI.Instance.getCurrentGame().getLeaderboards()
					.get(position);
			scores = lb.getScores();
			ListView lv = (ListView) findViewById(R.id.lbview_items);
			lv.setAdapter(new AdapterLeaderboardScores(
					ActivityLeaderboard.this, R.layout.lbview_listitem,
					scores));
		} else {
			Toast.makeText(ActivityLeaderboard.this,
					&quot;GetScores failed: &quot; + response.getMessage(),
					Toast.LENGTH_LONG).show();
		}
	}
}</pre><p></p>
<p>C# Code </p>
<p></p><pre class="crayon-plain-tag">public void OnRefreshClicked(object sender, EventArgs e)
	{
		XPGAPI.Instance.GetScores(lb.LeaderboardTag, 0, GetScoresCompleted);
	}

public void GetScoresCompleted(XPGAPIResponse&lt;XPGScoresResultInfo&gt; response)
	{
		if (!response.Failed)
		{
			if (response.Body != null &amp;&amp; response.Body.Scores != null &amp;&amp; response.Body.Scores.Count &gt; 0)
			{
				scores = response.Body.Scores.ToList();
				ListView lv = FindViewById&lt;ListView&gt;(Resource.Id.lbview_items);
				lv.Adapter = new AdapterLeaderboardScores(this, Resource.Layout.lbview_listitem, scores);
			}
		}
		else
		{
			Toast.MakeText(this, &quot;GetScores failed: &quot; + response.Message, ToastLength.Long).Show();
		}
	}</pre><p></p>
<h4 align="left">Full Code</h4>
<p>Java Code </p>
<p></p><pre class="crayon-plain-tag">package XPG.Demo.Android;

import java.util.ArrayList;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

import com.xpglive.api.XPGAPI;
import com.xpglive.api.XPGAPICallbackGeneric;
import com.xpglive.api.XPGAPIResponseGeneric;
import com.xpglive.api.XPGLeaderboardInfo;
import com.xpglive.api.XPGLeaderboardScoreInfo;
import com.xpglive.api.XPGScoreResultInfo;
import com.xpglive.api.XPGScoresResultInfo;

public class ActivityLeaderboard extends Activity {
	XPGLeaderboardInfo lb = null;
	private int position;
	private XPGLeaderboardScoreInfo userScore;
	private ArrayList&lt;XPGLeaderboardScoreInfo&gt; scores;

	@Override
	protected void onStart() {
		super.onStart();
		position = this.getIntent().getIntExtra(&quot;position&quot;, 0);
		lb = XPGAPI.Instance.getCurrentGame().getLeaderboards().get(position);

		if (lb == null) {
			onBackPressed();
		}

		Button refreshButton = (Button) findViewById(R.id.lbview_buttonRefresh);
		refreshButton.setOnClickListener(new OnRefreshClicked());

		Button scoreHighButton = (Button) findViewById(R.id.lbview_scoreHigh);
		scoreHighButton.setOnClickListener(new OnScoreHighClicked());

		Button scoreMedButton = (Button) findViewById(R.id.lbview_scoreMed);
		scoreMedButton.setOnClickListener(new OnScoreMedClicked());

		Button scoreLowButton = (Button) findViewById(R.id.lbview_scoreLow);
		scoreLowButton.setOnClickListener(new OnScoreLowClicked());

		scores = lb.getScores();

		TextView tt = (TextView) findViewById(R.id.lbview_name);
		if (tt != null) {
			tt.setText(lb.getDisplayName());
		}

		if (scores != null &amp;&amp; scores.size() &gt; 0) {
			ListView lv = (ListView) findViewById(R.id.lbview_items);
			lv.setAdapter(new AdapterLeaderboardScores(
					ActivityLeaderboard.this, R.layout.lbview_listitem, scores));
		}

		XPGAPI.Instance.setCallbackSubmitScore(new SubmitScoreCompleted());
	}

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.lbview);
	}

	private class OnRefreshClicked implements OnClickListener {
		@Override
		public void onClick(View arg0) {
			XPGAPI.Instance.getScores(lb.getLeaderboardTag(), 0,
					new GetScoresCompleted());
		}
	}

	private class OnScoreHighClicked implements OnClickListener {
		@Override
		public void onClick(View arg0) {
			if (userScore != null) {
				XPGAPI.Instance.submitScore(lb.getLeaderboardTag(), new Double(
						userScore.getUserScore().doubleValue() + 10), null);
			} else {
				try {
					XPGLeaderboardScoreInfo score = ((XPGLeaderboardScoreInfo) scores
							.get(0));
					XPGAPI.Instance
							.submitScore(lb.getLeaderboardTag(), new Double(
									score.getUserScore().doubleValue() + 10),
									null);
				} catch (Exception e) {
					XPGAPI.Instance.submitScore(lb.getLeaderboardTag(),
							new Double(10), null);
				}
			}
		}
	}

	private class OnScoreMedClicked implements OnClickListener {
		@Override
		public void onClick(View arg0) {
			if (userScore != null) {
				XPGAPI.Instance.submitScore(lb.getLeaderboardTag(), new Double(
						userScore.getUserScore().doubleValue() + 5), null);
			} else {
				try {
					XPGLeaderboardScoreInfo score = ((XPGLeaderboardScoreInfo) scores
							.get(0));
					XPGAPI.Instance.submitScore(lb.getLeaderboardTag(),
							new Double(score.getUserScore().doubleValue() + 5),
							null);
				} catch (Exception e) {
					XPGAPI.Instance.submitScore(lb.getLeaderboardTag(),
							new Double(5), null);
				}
			}
		}
	}

	private class OnScoreLowClicked implements OnClickListener {
		@Override
		public void onClick(View arg0) {
			if (userScore != null) {
				XPGAPI.Instance.submitScore(lb.getLeaderboardTag(), new Double(
						userScore.getUserScore().doubleValue() + 1), null);
			} else {
				try {
					XPGLeaderboardScoreInfo score = ((XPGLeaderboardScoreInfo) scores
							.get(0));
					XPGAPI.Instance.submitScore(lb.getLeaderboardTag(),
							new Double(score.getUserScore().doubleValue() + 1),
							null);
				} catch (Exception e) {
					XPGAPI.Instance.submitScore(lb.getLeaderboardTag(),
							new Double(1), null);
				}
			}
		}
	}

	private class GetScoresCompleted extends
			XPGAPICallbackGeneric&lt;XPGScoresResultInfo&gt; {
		@Override
		public void gotResponse(
				XPGAPIResponseGeneric&lt;XPGScoresResultInfo&gt; response) {
			if (!response.getFailed() &amp;&amp; response.getBody() != null) {
				lb = XPGAPI.Instance.getCurrentGame().getLeaderboards()
						.get(position);
				scores = lb.getScores();
				ListView lv = (ListView) findViewById(R.id.lbview_items);
				lv.setAdapter(new AdapterLeaderboardScores(
						ActivityLeaderboard.this, R.layout.lbview_listitem,
						scores));
			} else {
				Toast.makeText(ActivityLeaderboard.this,
						&quot;GetScores failed: &quot; + response.getMessage(),
						Toast.LENGTH_LONG).show();
			}
		}
	}

	private class SubmitScoreCompleted extends
			XPGAPICallbackGeneric&lt;XPGScoreResultInfo&gt; {
		@Override
		public void gotResponse(
				XPGAPIResponseGeneric&lt;XPGScoreResultInfo&gt; response) {
			if (!response.getFailed()) {
				lb = XPGAPI.Instance.getCurrentGame().getLeaderboards()
						.get(position);
				scores = lb.getScores();
				ListView lv = (ListView) findViewById(R.id.lbview_items);
				lv.setAdapter(new AdapterLeaderboardScores(
						ActivityLeaderboard.this, R.layout.lbview_listitem,
						scores));
			} else {
				Toast.makeText(ActivityLeaderboard.this,
						&quot;SubmitScore failed: &quot; + response.getMessage(),
						Toast.LENGTH_LONG).show();
			}
		}
	}

	private class AdapterLeaderboardScores extends
			ArrayAdapter&lt;XPGLeaderboardScoreInfo&gt; {
		private ArrayList&lt;XPGLeaderboardScoreInfo&gt; items;

		public AdapterLeaderboardScores(Context context,
				int textViewResourceId,
				ArrayList&lt;XPGLeaderboardScoreInfo&gt; scoreItems) {
			super(context, textViewResourceId, scoreItems);
			this.items = scoreItems;
		}

		@Override
		public View getView(int position, View convertView, ViewGroup parent) {
			if (convertView == null) {
				LayoutInflater vi = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
				convertView = vi.inflate(R.layout.lbview_listitem, null);
			}
			XPGLeaderboardScoreInfo score = items.get(position);
			if (score != null) {
				if (score.getUserName().equalsIgnoreCase(
						XPGAPI.Instance.getCurrentUser().getUserName())) {
					userScore = score;
				}
				TextView name = (TextView) convertView
						.findViewById(R.id.lbview_itemname);
				if (name != null) {
					name.setText(&quot;User: &quot; + score.getUserNameDisplay());
				}
				TextView scoreVal = (TextView) convertView
						.findViewById(R.id.lbview_itemscore);
				if (scoreVal != null) {
					scoreVal.setText(&quot;Score: &quot; + score.getUserScore());
				}
			}
			return convertView;
		}
	}

}</pre><p></p>
<p>C# Code </p>
<p></p><pre class="crayon-plain-tag">using System;
using System.Collections.Generic;
using System.Linq;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Util;
using Android.Views;
using Android.Widget;
using XPG.Demo.MonoDroid;

namespace XPG.Demo.Android
{
	[Activity(Label = &quot;XPG Demo MonoDroid&quot;)]
	public class ActivityLeaderboard : Activity
	{
		private int position;
		XPGLeaderboardInfo lb = null;
		private XPGLeaderboardScoreInfo userScore;
		private List&lt;XPGLeaderboardScoreInfo&gt; scores;

		protected override void OnStart()
		{
			base.OnStart();
			position = this.Intent.GetIntExtra(&quot;position&quot;, 0);

			try
			{
				lb = XPGAPI.Instance.CurrentGame.Leaderboards[position];
			}
			catch
			{
				OnBackPressed();
			}

			if (lb == null) { OnBackPressed(); }

			scores = lb.Scores.ToList();

			Button refreshButton = FindViewById&lt;Button&gt;(Resource.Id.lbview_buttonRefresh);
			refreshButton.Click += OnRefreshClicked;

			Button scoreHighButton = FindViewById&lt;Button&gt;(Resource.Id.lbview_scoreHigh);
			scoreHighButton.Click += OnScoreHighClicked;

			Button scoreMedButton = FindViewById&lt;Button&gt;(Resource.Id.lbview_scoreMed);
			scoreMedButton.Click += OnScoreMedClicked;

			Button scoreLowButton = FindViewById&lt;Button&gt;(Resource.Id.lbview_scoreLow);
			scoreLowButton.Click += OnScoreLowClicked;

			TextView tt = FindViewById&lt;TextView&gt;(Resource.Id.lbview_name);
			if (tt != null)
			{
				tt.SetText(lb.DisplayName, TextView.BufferType.Normal);
			}

			ListView lv = FindViewById&lt;ListView&gt;(Resource.Id.lbview_items);
			if (scores != null &amp;&amp; scores.Count &gt; 0)
			{
				lv.Adapter = new AdapterLeaderboardScores(this, Resource.Layout.lbview_listitem, scores);
			}
		}

		protected override void OnCreate(Bundle bundle)
		{
			base.OnCreate(bundle);
			SetContentView(Resource.Layout.lbview);
		}

		public void OnRefreshClicked(object sender, EventArgs e)
		{
			XPGAPI.Instance.GetScores(lb.LeaderboardTag, 0, GetScoresCompleted);
		}

		public void OnScoreHighClicked(object sender, EventArgs e)
		{
#if ANDROID
			Log.Debug(&quot;XPG&quot;, &quot;lb.ScoreType = &quot; + lb.ScoreType);
#endif
			if (userScore != null)
			{
				XPGAPI.Instance.SubmitScore(lb.LeaderboardTag, userScore.UserScore + 10, SubmitScoreCompleted);
			}
			else
			{
				try
				{
					XPGLeaderboardScoreInfo score = scores[0];
					XPGAPI.Instance.SubmitScore(lb.LeaderboardTag, score.UserScore + 10, SubmitScoreCompleted);
				}
				catch (Exception ex)
				{
					XPGAPI.Instance.SubmitScore(lb.LeaderboardTag, 10, SubmitScoreCompleted);
				}
			}
		}

		public void OnScoreMedClicked(object sender, EventArgs e)
		{
#if ANDROID
			Log.Debug(&quot;XPG&quot;, &quot;lb.ScoreType = &quot; + lb.ScoreType);
#endif
			if (userScore != null)
			{
				XPGAPI.Instance.SubmitScore(lb.LeaderboardTag, userScore.UserScore + 5, SubmitScoreCompleted);
			}
			else
			{
				try
				{
					XPGLeaderboardScoreInfo score = scores[0];
					XPGAPI.Instance.SubmitScore(lb.LeaderboardTag, score.UserScore + 5, SubmitScoreCompleted);
				}
				catch (Exception ex)
				{
					XPGAPI.Instance.SubmitScore(lb.LeaderboardTag, 5, SubmitScoreCompleted);
				}
			}
		}

		public void OnScoreLowClicked(object sender, EventArgs e)
		{
#if ANDROID
			Log.Debug(&quot;XPG&quot;, &quot;lb.ScoreType = &quot; + lb.ScoreType);
#endif
			if (userScore != null)
			{
				XPGAPI.Instance.SubmitScore(lb.LeaderboardTag, userScore.UserScore + 1, SubmitScoreCompleted);
			}
			else
			{
				try
				{
					XPGLeaderboardScoreInfo score = scores[0];
					XPGAPI.Instance.SubmitScore(lb.LeaderboardTag, score.UserScore + 1, SubmitScoreCompleted);
				}
				catch (Exception ex)
				{
					XPGAPI.Instance.SubmitScore(lb.LeaderboardTag, 1, SubmitScoreCompleted);
				}
			}
		}

		public void GetScoresCompleted(XPGAPIResponse&lt;XPGScoresResultInfo&gt; response)
		{
			if (!response.Failed)
			{
				if (response.Body != null &amp;&amp; response.Body.Scores != null &amp;&amp; response.Body.Scores.Count &gt; 0)
				{
					scores = response.Body.Scores.ToList();
					ListView lv = FindViewById&lt;ListView&gt;(Resource.Id.lbview_items);
					lv.Adapter = new AdapterLeaderboardScores(this, Resource.Layout.lbview_listitem, scores);
				}
			}
			else
			{
				Toast.MakeText(this, &quot;GetScores failed: &quot; + response.Message, ToastLength.Long).Show();
			}
		}

		public void SubmitScoreCompleted(XPGAPIResponse&lt;XPGScoreResultInfo&gt; response)
		{
			if (!response.Failed)
			{
				XPGAPI.Instance.GetScores(lb.LeaderboardTag, 0, GetScoresCompleted);
			}
			else
			{
				Toast.MakeText(this, &quot;SubmitScore failed: &quot; + response.Message, ToastLength.Long).Show();
			}
		}

		private class AdapterLeaderboardScores : ArrayAdapter&lt;XPGLeaderboardScoreInfo&gt;
		{
			private List&lt;XPGLeaderboardScoreInfo&gt; items;
			private Context ctxt;

			public AdapterLeaderboardScores(Context context,
					int textViewResourceId,
					List&lt;XPGLeaderboardScoreInfo&gt; scores)
				: base(context, textViewResourceId, scores)
			{
				this.items = scores;
				ctxt = context;
			}

			public override View GetView(int position, View convertView, ViewGroup parent)
			{
				if (convertView == null)
				{
					LayoutInflater vi = (LayoutInflater)ctxt.GetSystemService(Context.LayoutInflaterService);
					convertView = vi.Inflate(Resource.Layout.lbview_listitem, null);
				}
				XPGLeaderboardScoreInfo score = items[position];
				if (score != null &amp;&amp; !score.UserName.Equals(&quot;No Scores To Display.&quot;, StringComparison.OrdinalIgnoreCase))
				{
					TextView name = convertView.FindViewById&lt;TextView&gt;(Resource.Id.lbview_itemname);
					if (name != null)
					{
						name.SetText(&quot;User: &quot; + score.UserNameDisplay, TextView.BufferType.Normal);
					}
					TextView scoreVal = convertView.FindViewById&lt;TextView&gt;(Resource.Id.lbview_itemscore);
					if (scoreVal != null)
					{
						scoreVal.SetText(&quot;Score: &quot; + score.UserScore, TextView.BufferType.Normal);
					}
				}
				else
				{
					TextView name = convertView.FindViewById&lt;TextView&gt;(Resource.Id.lbview_itemname);
					if (name != null)
					{
						name.SetText(score.UserName, TextView.BufferType.Normal);
					}
				}
				return convertView;
			}
		}
	}
}</pre><p></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.xpglive.com/2012/01/30/how-to-use-leaderboards-on-android-with-xpg/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How To: Use leaderboards on iOS (iPhone/iPad) with XPG</title>
		<link>http://blog.xpglive.com/2012/01/25/how-to-use-leaderboards-on-ios-iphoneipad-with-xpg/</link>
		<comments>http://blog.xpglive.com/2012/01/25/how-to-use-leaderboards-on-ios-iphoneipad-with-xpg/#comments</comments>
		<pubDate>Wed, 25 Jan 2012 20:04:00 +0000</pubDate>
		<dc:creator>Derik (XPG)</dc:creator>
				<category><![CDATA[CodeProject]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[XPG Games]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[cross-platform]]></category>
		<category><![CDATA[Dev]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Framework]]></category>
		<category><![CDATA[Game]]></category>
		<category><![CDATA[Generics]]></category>
		<category><![CDATA[GUI]]></category>
		<category><![CDATA[IDE]]></category>
		<category><![CDATA[Intermediate]]></category>
		<category><![CDATA[iOS]]></category>
		<category><![CDATA[iPad]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Leaderboard]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Mono]]></category>
		<category><![CDATA[MonoDevelop]]></category>
		<category><![CDATA[MonoTouch]]></category>
		<category><![CDATA[Obj-C]]></category>
		<category><![CDATA[ObjC]]></category>
		<category><![CDATA[Posting]]></category>
		<category><![CDATA[Retrieving]]></category>
		<category><![CDATA[Score]]></category>
		<category><![CDATA[UI]]></category>
		<category><![CDATA[XCode]]></category>
		<category><![CDATA[XPG]]></category>

		<guid isPermaLink="false">http://blog.xpglive.com/?p=283</guid>
		<description><![CDATA[This is a continuation of the How To series. This first post is here. This article will cover: Leaderboard types and setup Accessing leaderboards in game Posting a score to a leaderboard Retrieving scores from a leaderboard Prerequisites XCode 4 and the iOS SDK MonoFramework, and MonoDevelop with MonoTouch XPG Live API for iOS or [...]]]></description>
				<content:encoded><![CDATA[<p>This is a continuation of the How To series. This first post is <a href="http://blog.xpglive.com/2011/12/30/how-to-get-started-with-xpg/">here</a>.</p>
<p>This article will cover:</p>
<ul>
<li>Leaderboard types and setup </li>
<li>Accessing leaderboards in game </li>
<li>Posting a score to a leaderboard </li>
<li>Retrieving scores from a leaderboard </li>
</ul>
<p>Prerequisites</p>
<ul>
<li><a href="http://developer.apple.com/xcode/index.php" target="_blank">XCode 4</a> and the iOS SDK </li>
<li><a href="http://www.go-mono.com/mono-downloads/download.html" target="_blank">MonoFramework</a>, and <a href="http://monodevelop.com/Download" target="_blank">MonoDevelop</a> with <a href="http://xamarin.com/monotouch" target="_blank">MonoTouch</a> </li>
<li><a href="http://www.xpglive.com/downloads" target="_blank">XPG Live API for iOS or MonoTouch</a> </li>
<li>An existing project or <a href="http://www.xpglive.com/en/downloads" target="_blank">XPG Demo Source for iOS or MonoTouch</a> </li>
</ul>
<h4>Leaderboard types and setup</h4>
<p>In order to setup a leaderboard you’ll need to have a free developer account with XPG and have registered a game in the management app. Assuming you’ve done these things, you can click on the leaderboards tab in the management app and begin defining your leaderboards.</p>
<p>&#160;</p>
<p align="center"><a href="http://blog.xpglive.com/wp-content/uploads/2012/01/image24.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px" title="image" border="0" alt="image" src="http://blog.xpglive.com/wp-content/uploads/2012/01/image_thumb24.png" width="396" height="350" /></a></p>
<p>&#160;</p>
<p>In the above image you can see the leaderboard dialog. As with most display values in the XPG system, the leaderboard name is globalized to help you provide a local experience for the end user. A display image can be defined by clicking the icon in the top right corner. The XPG system allows you to define a game-unique identifier for your leaderboard which is particularly helpful when migrating from another system to XPG, or implementing XPG along side another system. The available score types are Float, Integer, Money, and Time and each can be used with a score order of Ascending or Descending. The score order indicates if the high scores take high ranks (Descending) or if the lower scores take high ranks (Ascending). You can also limit this leaderboard&#8217;s availability by game version. Game versions are defined on the Access Keys tab in the Games area of the management app. Each version gets a new access key (or secret key) which positively identifies your game and game version.</p>
<p>&#160;</p>
<p align="center"><a href="http://blog.xpglive.com/wp-content/uploads/2012/01/image25.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; margin-right: auto; padding-top: 0px" title="image" border="0" alt="image" src="http://blog.xpglive.com/wp-content/uploads/2012/01/image_thumb25.png" width="420" height="214" /></a></p>
<p>&#160;</p>
<h4>Accessing leaderboards in game</h4>
<p>As with many things in XPG, accessing leaderboards within your game is very simple. When your game was initialized (<a title="How To: Initialize a game on iOS (iPhone/iPad) with XPG" href="http://blog.xpglive.com/2012/01/11/how-to-initialize-a-game-on-ios-iphoneipad-with-xpg/" target="_blank">discussed in this post</a>) the leaderboards defined in the <a href="http://www.xpglive.com/manage" target="_blank">XPG Management App</a> were loaded in-game. Once these leaderboards were loaded the first page of scores for each of them was also retrieved and loaded. All the objects provided in the XPG API for MonoTouch implement the <a title="Mono Docs - INotifyPropertyChanged Interface" href="http://docs.go-mono.com/monodoc.ashx?link=T%3aSystem.ComponentModel.INotifyPropertyChanged" target="_blank">INotifyPropertyChanged</a> interface to provide UI binding assistance and to help simplify your coding effort.</p>
<p>Objective-C Code</p>
<p> </p><pre class="crayon-plain-tag">- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
	static NSString *CellIdentifier = @&quot;Cell&quot;;    
	UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
	if (cell == nil) {
		cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
	}
    
	XPGLeaderboardScoreInfo* score = [((XPGLeaderboardInfo*)[[XPGAPI getCurrentGame].Leaderboards objectAtIndex:boardIndex]).Scores objectAtIndex:indexPath.row];
	NSNumberFormatter* formatter = [[NSNumberFormatter new] autorelease];
	formatter.numberStyle = NSNumberFormatterDecimalStyle;
		
	UILabel* scoreValLabel = [[UILabel alloc] initWithFrame:CGRectMake(350, 7, 150, 36)];
	scoreValLabel.text = [formatter stringFromNumber:[NSNumber numberWithDouble:score.UserScore]];
	scoreValLabel.textAlignment = UITextAlignmentRight;
		
	cell.textLabel.text = [NSString stringWithFormat:@&quot;%d. %@&quot;, score.UserRank, score.UserNameDisplay, nil];
	cell.accessoryView = scoreValLabel;
    
	return cell;
}</pre><p></p>
<p>C# Code</p>
<p></p><pre class="crayon-plain-tag">public override UITableViewCell GetCell(UITableView tableView, MonoTouch.Foundation.NSIndexPath indexPath)
{
	string cellIdentifier = string.Format(&quot;CellForSection{0}&quot;, indexPath.Section);
	var cell = tableView.DequeueReusableCell(cellIdentifier);
	if(cell == null)
	{
		cell = new UITableViewCell(UITableViewCellStyle.Default, cellIdentifier);
	}

	if(indexPath.Section == 0)
	{
		XPGLeaderboardScoreInfo score = XPGAPI.Instance.CurrentGame.Leaderboards[controller.BoardIndex].Scores[indexPath.Row];

		UILabel scoreValLabel = new UILabel(new RectangleF(350f, 7f, 150f, 36f));
		scoreValLabel.Text = score.UserScore.ToString();
		scoreValLabel.TextAlignment = UITextAlignment.Right;
		
		cell.TextLabel.Text = string.Format(&quot;{0}. {1}&quot;, score.UserRank, score.UserNameDisplay);
		cell.AccessoryView = scoreValLabel;
	}
	else if(indexPath.Section == 1)
	{
		switch(indexPath.Row)
		{
			case 0:				
				cell.TextLabel.Text = &quot;Post High Score&quot;;
				break;
			case 1:				
				cell.TextLabel.Text = &quot;Post Medium Score&quot;;
				break;
			case 2:				
				cell.TextLabel.Text = &quot;Post Low Score&quot;;
				break;
			case 3:				
				cell.TextLabel.Text = &quot;Refresh Scores&quot;;
				break;				
			default:
				break;
		}
	}

	return cell;
}</pre><p></p>
<h4>Posting a score to a leaderboard</h4>
<p>There are overloads in C# and additional methods in Objective-C provided to work with each of the score types mentioned above. The API will perform local updates of the leaderboard data after posting a score to the server when it detects that no user data from other players has affected the ranking other than the local user. Alternatively, the API will also initiate a full update of the leaderboard local data if it detects that one or more users have affected the leaderboard ranking other than the local user. This is all handled auto-magically in order to conserve bandwidth, processor time, and device battery.</p>
<p>Here is an example of score posting simplicity.</p>
<p>Objective-C Code</p>
<p></p><pre class="crayon-plain-tag">- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
	if (indexPath.section == 1)
	{
		XPGLeaderboardInfo* leaderboard = [[XPGAPI getCurrentGame].Leaderboards objectAtIndex:boardIndex];
		if (leaderboard != nil)
		{
			NSArray* sortedArray;
			NSArray* sortDescriptors;
			NSSortDescriptor* sortDescriptor;
			double scoreLow, scoreHigh;
			
			sortDescriptor = [[[NSSortDescriptor alloc] initWithKey:@&quot;UserScore&quot; ascending:NO] autorelease];
			sortDescriptors = [NSArray arrayWithObject:sortDescriptor];
			sortedArray = [leaderboard.Scores sortedArrayUsingDescriptors:sortDescriptors];
			
			scoreHigh = ((XPGLeaderboardScoreInfo*)[sortedArray objectAtIndex:0]).UserScore;
			
			sortDescriptor = [[[NSSortDescriptor alloc] initWithKey:@&quot;UserScore&quot; ascending:YES] autorelease];
			sortDescriptors = [NSArray arrayWithObject:sortDescriptor];
			sortedArray = [leaderboard.Scores sortedArrayUsingDescriptors:sortDescriptors];
			
			scoreLow = ((XPGLeaderboardScoreInfo*)[sortedArray objectAtIndex:0]).UserScore;
			
			
			switch (indexPath.row)
			{
				case 0:
					[XPGAPI submitScoreFor:leaderboard.LeaderboardTag withLong:(scoreHigh + 10) andCallback:self];
					break;
				case 1:
					[XPGAPI submitScoreFor:leaderboard.LeaderboardTag withLong:(scoreLow + (scoreHigh - scoreLow)) andCallback:self];
					break;
				case 2:
					[XPGAPI submitScoreFor:leaderboard.LeaderboardTag withLong:(scoreHigh - 10) andCallback:self];
					break;			
				default:
					break;
			}
		}
	}
	
    [tableView deselectRowAtIndexPath:indexPath animated:true];
}</pre><p></p>
<p>C# Code</p>
<p></p><pre class="crayon-plain-tag">public override void RowSelected(UITableView tableView, NSIndexPath indexPath)
{
	if(indexPath.Section == 1)
	{
		double lowScore, highScore;
		XPGLeaderboardInfo leaderboard = XPGAPI.Instance.CurrentGame.Leaderboards[controller.BoardIndex];
		if(leaderboard != null)
		{
			lowScore = leaderboard.Scores.Min(x =&gt; x.UserScore);
			highScore = leaderboard.Scores.Max(x =&gt; x.UserScore);

			switch(indexPath.Row)
			{
				case 0:
					XPGAPI.Instance.SubmitScore(leaderboard.LeaderboardTag, (highScore + 10), HandleScoreSubmitted);
					break;
				case 1:
					XPGAPI.Instance.SubmitScore(leaderboard.LeaderboardTag, (lowScore + (highScore - lowScore)), HandleScoreSubmitted);
					break;
				case 2:
					XPGAPI.Instance.SubmitScore(leaderboard.LeaderboardTag, (highScore - 10), HandleScoreSubmitted);
					break;				
				default:
					break;
			}
		}
	}

	tableView.DeselectRow(indexPath, true);
}</pre><p></p>
<h4>Retrieving scores from a leaderboard</h4>
<p>Retrieving scores from XPG is equally simple. The scores are stored locally on the leaderboard instance of the initialized game instance, so there are no collections for you to keep up with and manage on your own. Also, leaderboards support paging, so you are not required to have all the ranked user scores in memory at once.</p>
<p>Objective-C Code</p>
<p></p><pre class="crayon-plain-tag">- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
	if (indexPath.section == 1)
	{
		XPGLeaderboardInfo* leaderboard = [[XPGAPI getCurrentGame].Leaderboards objectAtIndex:boardIndex];
		if (leaderboard != nil)
		{
			switch (indexPath.row)
			{
				case 3:
					[XPGAPI getScoresFor:leaderboard.LeaderboardTag atOffset:0 withCallback:self];
					break;			
				default:
					break;
			}
		}
	}
	
    [tableView deselectRowAtIndexPath:indexPath animated:true];
}</pre><p></p>
<p>C# Code</p>
<p></p><pre class="crayon-plain-tag">public override void RowSelected(UITableView tableView, NSIndexPath indexPath)
{
	if(indexPath.Section == 1)
	{
		XPGLeaderboardInfo leaderboard = XPGAPI.Instance.CurrentGame.Leaderboards[controller.BoardIndex];
		if(leaderboard != null)
		{
			switch(indexPath.Row)
			{
				case 3:
					XPGAPI.Instance.GetScores(leaderboard.LeaderboardTag, 0, HandleScoresObtained);
					break;				
				default:
					break;
			}
		}
	}

	tableView.DeselectRow(indexPath, true);
}</pre><p></p>
<h4>The full code</h4>
<p>Objective-C Code</p>
<p></p><pre class="crayon-plain-tag">#import &lt;UIKit/UIKit.h&gt;
#import &lt;XPGLive/XPGLive.h&gt;

@interface LeaderboardViewController : UITableViewController  &lt;XPGAPIReceiver&gt;
{
    int boardIndex;
}

@property (nonatomic) int boardIndex;

-(void)reset;

@end</pre><p></p>
<p></p><pre class="crayon-plain-tag">#import &quot;LeaderboardViewController.h&quot;

@implementation LeaderboardViewController

@synthesize boardIndex;

- (id)initWithStyle:(UITableViewStyle)style
{
    self = [super initWithStyle:style];
    if (self) {
        // Custom initialization
    }
    return self;
}

#pragma mark - View lifecycle

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
	
	XPGLeaderboardInfo* leaderboard = (XPGLeaderboardInfo*)[[XPGAPI getCurrentGame].Leaderboards objectAtIndex:boardIndex];
	self.title = leaderboard.DisplayName;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 2;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
	NSInteger retVal = 0;
	
	if (section == 0)
	{
		XPGLeaderboardInfo* leaderboard = (XPGLeaderboardInfo*)[[XPGAPI getCurrentGame].Leaderboards objectAtIndex:boardIndex];
		retVal = [leaderboard.Scores count];
	}
	else if (section == 1) { retVal = 4; }
	
	return retVal;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @&quot;Cell&quot;;    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    }
    
	if (indexPath.section == 0)
	{
		XPGLeaderboardScoreInfo* score = [((XPGLeaderboardInfo*)[[XPGAPI getCurrentGame].Leaderboards objectAtIndex:boardIndex]).Scores objectAtIndex:indexPath.row];
		NSNumberFormatter* formatter = [[NSNumberFormatter new] autorelease];
		formatter.numberStyle = NSNumberFormatterDecimalStyle;
		
		UILabel* scoreValLabel = [[UILabel alloc] initWithFrame:CGRectMake(350, 7, 150, 36)];
		scoreValLabel.text = [formatter stringFromNumber:[NSNumber numberWithDouble:score.UserScore]];
		scoreValLabel.textAlignment = UITextAlignmentRight;
		
		cell.textLabel.text = [NSString stringWithFormat:@&quot;%d. %@&quot;, score.UserRank, score.UserNameDisplay, nil];
		cell.accessoryView = scoreValLabel;
	}
	else if (indexPath.section == 1)
	{
		switch (indexPath.row)
		{
			case 0:				
				cell.textLabel.text = @&quot;Post High Score&quot;;
				break;
			case 1:				
				cell.textLabel.text = @&quot;Post Medium Score&quot;;
				break;
			case 2:				
				cell.textLabel.text = @&quot;Post Low Score&quot;;
				break;
			case 3:				
				cell.textLabel.text = @&quot;Refresh Scores&quot;;
				break;				
			default:
				break;
		}
	}
    
    return cell;
}

#pragma mark - XPG API delegate

-(void)getScoresCompletedWith:(XPGAPIResponse *)response
{
	[self.tableView reloadData];
}

-(void)submitScoreCompletedWith:(XPGAPIResponse *)response
{
	[self.tableView reloadData];
}

-(void)reset
{
}

#pragma mark - Table view delegate

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
	if (indexPath.section == 1)
	{
		XPGLeaderboardInfo* leaderboard = [[XPGAPI getCurrentGame].Leaderboards objectAtIndex:boardIndex];
		if (leaderboard != nil)
		{
			NSArray* sortedArray;
			NSArray* sortDescriptors;
			NSSortDescriptor* sortDescriptor;
			double scoreLow, scoreHigh;
			
			sortDescriptor = [[[NSSortDescriptor alloc] initWithKey:@&quot;UserScore&quot; ascending:NO] autorelease];
			sortDescriptors = [NSArray arrayWithObject:sortDescriptor];
			sortedArray = [leaderboard.Scores sortedArrayUsingDescriptors:sortDescriptors];
			
			scoreHigh = ((XPGLeaderboardScoreInfo*)[sortedArray objectAtIndex:0]).UserScore;
			
			sortDescriptor = [[[NSSortDescriptor alloc] initWithKey:@&quot;UserScore&quot; ascending:YES] autorelease];
			sortDescriptors = [NSArray arrayWithObject:sortDescriptor];
			sortedArray = [leaderboard.Scores sortedArrayUsingDescriptors:sortDescriptors];
			
			scoreLow = ((XPGLeaderboardScoreInfo*)[sortedArray objectAtIndex:0]).UserScore;
			
			
			switch (indexPath.row)
			{
				case 0:
					[XPGAPI submitScoreFor:leaderboard.LeaderboardTag withLong:(scoreHigh + 10) andCallback:self];
					break;
				case 1:
					[XPGAPI submitScoreFor:leaderboard.LeaderboardTag withLong:(scoreLow + (scoreHigh - scoreLow)) andCallback:self];
					break;
				case 2:
					[XPGAPI submitScoreFor:leaderboard.LeaderboardTag withLong:(scoreHigh - 10) andCallback:self];
					break;
				case 3:				
					[XPGAPI getScoresFor:leaderboard.LeaderboardTag atOffset:0 withCallback:self];
					break;				
				default:
					break;
			}
		}
	}
	
    [tableView deselectRowAtIndexPath:indexPath animated:true];
}

@end</pre><p></p>
<p>C# Code</p>
<p></p><pre class="crayon-plain-tag">using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using XPG;

namespace XPG.Demo.MT
{
	public partial class LeaderboardViewController : UITableViewController
	{
		public int BoardIndex { get; set; }

		//loads the LeaderboardViewController.xib file and connects it to this object
		public LeaderboardViewController() : base (&quot;LeaderboardViewController&quot;, null)
		{
		}

		public override void ViewDidLoad()
		{
			base.ViewDidLoad();

			this.Title = XPGAPI.Instance.CurrentGame.Leaderboards[BoardIndex].DisplayName;
			this.TableView.Source = new DataSource(this);
		}
		
		public override bool ShouldAutorotateToInterfaceOrientation(UIInterfaceOrientation toInterfaceOrientation)
		{
			return toInterfaceOrientation.Equals(UIInterfaceOrientation.Portrait);
		}

		public override void DidReceiveMemoryWarning()
		{
			base.DidReceiveMemoryWarning();
		}
		
		public override void ViewDidUnload()
		{
			base.ViewDidUnload();
		}
		
		class DataSource : UITableViewSource
		{
			LeaderboardViewController controller;

			public DataSource(LeaderboardViewController controller)
			{
				this.controller = controller;
			}
			
			// Customize the number of sections in the table view.
			public override int NumberOfSections(UITableView tableView)
			{
				return 2;
			}

			public override int RowsInSection(UITableView tableview, int section)
			{
				return (section == 1 ? 4 : XPGAPI.Instance.CurrentGame.Leaderboards[controller.BoardIndex].Scores.Count);
			}

			// Customize the appearance of table view cells.
			public override UITableViewCell GetCell(UITableView tableView, MonoTouch.Foundation.NSIndexPath indexPath)
			{
				string cellIdentifier = string.Format(&quot;CellForSection{0}&quot;, indexPath.Section);
				var cell = tableView.DequeueReusableCell(cellIdentifier);
				if(cell == null)
				{
					cell = new UITableViewCell(UITableViewCellStyle.Default, cellIdentifier);
				}

				if(indexPath.Section == 0)
				{
					XPGLeaderboardScoreInfo score = XPGAPI.Instance.CurrentGame.Leaderboards[controller.BoardIndex].Scores[indexPath.Row];

					UILabel scoreValLabel = new UILabel(new RectangleF(350f, 7f, 150f, 36f));
					scoreValLabel.Text = score.UserScore.ToString();
					scoreValLabel.TextAlignment = UITextAlignment.Right;
		
					cell.TextLabel.Text = string.Format(&quot;{0}. {1}&quot;, score.UserRank, score.UserNameDisplay);
					cell.AccessoryView = scoreValLabel;
				}
				else if(indexPath.Section == 1)
				{
					switch(indexPath.Row)
					{
						case 0:				
							cell.TextLabel.Text = &quot;Post High Score&quot;;
							break;
						case 1:				
							cell.TextLabel.Text = &quot;Post Medium Score&quot;;
							break;
						case 2:				
							cell.TextLabel.Text = &quot;Post Low Score&quot;;
							break;
						case 3:				
							cell.TextLabel.Text = &quot;Refresh Scores&quot;;
							break;				
						default:
							break;
					}
				}

				return cell;
			}
			
			public override void RowSelected(UITableView tableView, NSIndexPath indexPath)
			{
				if(indexPath.Section == 1)
				{
					double lowScore, highScore;
					XPGLeaderboardInfo leaderboard = XPGAPI.Instance.CurrentGame.Leaderboards[controller.BoardIndex];
					if(leaderboard != null)
					{
						lowScore = leaderboard.Scores.Min(x =&gt; x.UserScore);
						highScore = leaderboard.Scores.Max(x =&gt; x.UserScore);

						switch(indexPath.Row)
						{
							case 0:
								XPGAPI.Instance.SubmitScore(leaderboard.LeaderboardTag, (highScore + 10), HandleScoreSubmitted);
								break;
							case 1:
								XPGAPI.Instance.SubmitScore(leaderboard.LeaderboardTag, (lowScore + (highScore - lowScore)), HandleScoreSubmitted);
								break;
							case 2:
								XPGAPI.Instance.SubmitScore(leaderboard.LeaderboardTag, (highScore - 10), HandleScoreSubmitted);
								break;
							case 3:
								XPGAPI.Instance.GetScores(leaderboard.LeaderboardTag, 0, HandleScoresObtained);
								break;				
							default:
								break;
						}
					}
				}

				tableView.DeselectRow(indexPath, true);
			}

			private void HandleScoreSubmitted(XPGAPIResponse&lt;XPGScoreResultInfo&gt; response)
			{
				controller.TableView.ReloadData();
			}

			private void HandleScoresObtained(XPGAPIResponse&lt;XPGScoresResultInfo&gt; response)
			{
				controller.TableView.ReloadData();
			}
		}
	}
}</pre><p></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.xpglive.com/2012/01/25/how-to-use-leaderboards-on-ios-iphoneipad-with-xpg/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How To: Use leaderboards on Windows Phone with XPG</title>
		<link>http://blog.xpglive.com/2012/01/21/how-to-use-leaderboards-on-windows-phone-with-xpg/</link>
		<comments>http://blog.xpglive.com/2012/01/21/how-to-use-leaderboards-on-windows-phone-with-xpg/#comments</comments>
		<pubDate>Sat, 21 Jan 2012 16:30:24 +0000</pubDate>
		<dc:creator>Derik (XPG)</dc:creator>
				<category><![CDATA[CodeProject]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[XPG Games]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[Binding]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[cross-platform]]></category>
		<category><![CDATA[Dev]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Framework]]></category>
		<category><![CDATA[Game]]></category>
		<category><![CDATA[Generics]]></category>
		<category><![CDATA[GUI]]></category>
		<category><![CDATA[IDE]]></category>
		<category><![CDATA[Intermediate]]></category>
		<category><![CDATA[Leaderboard]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Posting]]></category>
		<category><![CDATA[Retrieving]]></category>
		<category><![CDATA[Score]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Silverlight4]]></category>
		<category><![CDATA[Silverrlight]]></category>
		<category><![CDATA[UI]]></category>
		<category><![CDATA[Visual-Studio]]></category>
		<category><![CDATA[VisualStudio]]></category>
		<category><![CDATA[VS2010]]></category>
		<category><![CDATA[Windows-Phone-7]]></category>
		<category><![CDATA[WP7]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[XAML]]></category>
		<category><![CDATA[XNA]]></category>
		<category><![CDATA[XPG]]></category>

		<guid isPermaLink="false">http://blog.xpglive.com/?p=267</guid>
		<description><![CDATA[This is a continuation of the How To series. This first post is here. This article will cover: Leaderboard types and setup Accessing leaderboards in game Posting a score to a leaderboard Retrieving scores from a leaderboard Prerequisites Windows Phone SDK 7.1 for Windows Phone XPG Live API for Windows Phone An existing project or [...]]]></description>
				<content:encoded><![CDATA[<p>This is a continuation of the How To series. This first post is <a href="http://blog.xpglive.com/2011/12/30/how-to-get-started-with-xpg/">here</a>.</p>
<p>This article will cover:</p>
<ul>
<li>Leaderboard types and setup</li>
<li>Accessing leaderboards in game </li>
<li>Posting a score to a leaderboard </li>
<li>Retrieving scores from a leaderboard </li>
</ul>
<p>Prerequisites</p>
<ul>
<li><a href="http://go.microsoft.com/?linkid=9772716">Windows Phone SDK 7.1 for Windows Phone</a> </li>
<li><a href="http://www.xpglive.com/en/downloads">XPG Live API for Windows Phone</a> </li>
<li>An existing project or <a href="http://www.xpglive.com/en/downloads">XPG Demo Source for Windows Phone</a></li>
</ul>
<h4>Leaderboard types and setup</h4>
<p>In order to setup a leaderboard you’ll need to have a free developer account with XPG and have registered a game in the management app. Assuming you’ve done these things, you can click on the leaderboards tab in the management app and begin defining your leaderboards.</p>
<p>&#160;</p>
<p align="center"><a href="http://blog.xpglive.com/wp-content/uploads/2012/01/image24.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blog.xpglive.com/wp-content/uploads/2012/01/image_thumb24.png" width="396" height="350" /></a></p>
<p>&#160;</p>
<p>In the above image you can see the leaderboard dialog. As with most display values in the XPG system, the leaderboard name is globalized to help you provide a local experience for the end user. A display image can be defined by clicking the icon in the top right corner. The XPG system allows you to define a game-unique identifier for your leaderboard which is particularly helpful when migrating from another system to XPG, or implementing XPG along side another system. The available score types are Float, Integer, Money, and Time and each can be used with a score order of Ascending or Descending. The score order indicates if the high scores take high ranks (Descending) or if the lower scores take high ranks (Ascending). You can also limit this leaderboard&#8217;s availability by game version. Game versions are defined on the Access Keys tab in the Games area of the management app. Each version gets a new access key (or secret key) which positively identifies your game and game version.</p>
<p>&#160;</p>
<p><a href="http://blog.xpglive.com/wp-content/uploads/2012/01/image25.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blog.xpglive.com/wp-content/uploads/2012/01/image_thumb25.png" width="420" height="214" /></a></p>
<p>&#160;</p>
<h4>Accessing leaderboards in game</h4>
<p>As with many things in XPG, accessing leaderboards within your game is very simple. When your game was initialized (<a title="How To: Initialize a game on Windows Phone with XPG" href="http://blog.xpglive.com/2012/01/05/how-to-initialize-a-game-on-windows-phone-with-xpg/" target="_blank">discussed in this post</a>) the leaderboards defined in the <a href="http://www.xpglive.com/manage" target="_blank">XPG Management App</a> were loaded in-game. Once these leaderboards were loaded the first page of scores for each of them was also retrieved and loaded. All the objects provided in the XPG API for Windows Phone implement the <a title="MSDN Library - INotifyPropertyChanged Interface" href="http://msdn.microsoft.com/en-us/library/system.componentmodel.inotifypropertychanged(v=vs.95).aspx" target="_blank">INotifyPropertyChanged</a> interface to provide UI binding support in XAML and to simplify your coding effort.</p>
<p>Here’s an example of binding to the leaderboard specified in a navigation parameter.</p>
<p>  </p><pre class="crayon-plain-tag">#region OnNavigatedTo
/// &lt;summary&gt;Handles the page being navigated to.&lt;/summary&gt;
/// &lt;param name=&quot;e&quot;&gt;The arguments.&lt;/param&gt;
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
	base.OnNavigatedTo(e);
	string lbTag = NavigationContext.QueryString[&quot;lbTag&quot;];
	if (string.IsNullOrWhiteSpace(lbTag)) { NavigationService.GoBack(); }

	if (XPGAPI.Instance.CurrentGame != null &amp;&amp; XPGAPI.Instance.CurrentGame.Leaderboards != null)
	{
		lb = XPGAPI.Instance.CurrentGame.Leaderboards.Where(x =&gt; x.LeaderboardTag.Equals(lbTag, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
		if (lb == null) { NavigationService.GoBack(); }

		SetBinding(DataContextProperty, new Binding() { Source = lb });
	}
}
#endregion OnNavigatedTo</pre><p></p>
<h4>Posting a score to a leaderboard</h4>
<p>There are overloads provided to work with each of the score types mentioned above. The API will perform local updates of the leaderboard data after posting a score to the server when it detects that no user data from other players has affected the ranking other than the local user. Alternatively, the API will also initiate a full update of the leaderboard local data if it detects that one or more users have affected the leaderboard ranking other than the local user. This is all handled auto-magically in order to conserve bandwidth, processor time, and device battery.</p>
<p>Here is an example of score posting simplicity.</p>
<p></p><pre class="crayon-plain-tag">#region mButtonScoreHigh_Click
/// &lt;summary&gt;Handles the high score button being clicked.&lt;/summary&gt;
/// &lt;param name=&quot;sender&quot;&gt;The sender of the event.&lt;/param&gt;
/// &lt;param name=&quot;e&quot;&gt;The arguments of the event.&lt;/param&gt;
private void mButtonScoreHigh_Click(object sender, RoutedEventArgs e)
{
	int scoreUpAmount = 10;
	XPGLeaderboardScoreInfo score = lb.Scores.FirstOrDefault();
	if (score != null)
	{
		XPGAPI.Instance.SubmitScore(lb.LeaderboardTag, score.UserScore + scoreUpAmount, SubmitScoreCompleted);
	}
	else
	{
		XPGAPI.Instance.SubmitScore(lb.LeaderboardTag, scoreUpAmount, SubmitScoreCompleted);
	}
}
#endregion mButtonScoreHigh_Click</pre><p></p>
<h4>Retrieving scores from a leaderboard</h4>
<p>Retrieving scores from XPG is equally simple. The scores are stored locally on the leaderboard instance of the initialized game instance, so there are no collections for you to keep up with and manage on your own. Also, leaderboards support paging, so you are not required to have all the ranked user scores in memory at once.</p>
<p></p><pre class="crayon-plain-tag">#region mButtonRefresh_Click
/// &lt;summary&gt;Handles the refresh button being clicked.&lt;/summary&gt;
/// &lt;param name=&quot;sender&quot;&gt;The sender of the event.&lt;/param&gt;
/// &lt;param name=&quot;e&quot;&gt;The arguments of the event.&lt;/param&gt;
private void mButtonRefresh_Click(object sender, RoutedEventArgs e)
{
	// On Windows Phone, this will invoke binding events that update the UI
	XPGAPI.Instance.GetScores(lb.LeaderboardTag, 0, GetScoresCompleted);
}
#endregion mButtonRefresh_Click</pre><p></p>
<h4>The full code</h4>
<p></p><pre class="crayon-plain-tag">&lt;phone:PhoneApplicationPage 
	x:Class=&quot;XPG.Demo.WinPhone.PageLeaderboard&quot;
	xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;
	xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;
	xmlns:phone=&quot;clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone&quot;
	xmlns:shell=&quot;clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone&quot;
	xmlns:d=&quot;http://schemas.microsoft.com/expression/blend/2008&quot;
	xmlns:mc=&quot;http://schemas.openxmlformats.org/markup-compatibility/2006&quot;
	FontFamily=&quot;{StaticResource PhoneFontFamilyNormal}&quot;
	FontSize=&quot;{StaticResource PhoneFontSizeNormal}&quot;
	Foreground=&quot;{StaticResource PhoneForegroundBrush}&quot;
	SupportedOrientations=&quot;Portrait&quot; Orientation=&quot;Portrait&quot;
	mc:Ignorable=&quot;d&quot; d:DesignHeight=&quot;768&quot; d:DesignWidth=&quot;480&quot;
	shell:SystemTray.IsVisible=&quot;True&quot;&gt;

	&lt;!--LayoutRoot is the root grid where all page content is placed--&gt;
	&lt;Grid x:Name=&quot;LayoutRoot&quot; Background=&quot;Transparent&quot;&gt;
		&lt;Grid.RowDefinitions&gt;
			&lt;RowDefinition Height=&quot;Auto&quot;/&gt;
			&lt;RowDefinition Height=&quot;*&quot;/&gt;
		&lt;/Grid.RowDefinitions&gt;

		&lt;!--TitlePanel contains the name of the application and page title--&gt;
		&lt;StackPanel x:Name=&quot;TitlePanel&quot; Grid.Row=&quot;0&quot; Margin=&quot;12,17,0,28&quot;&gt;
			&lt;TextBlock x:Name=&quot;PageTitle&quot; Text=&quot;XPG WP7 Demo&quot; Margin=&quot;9,-7,0,0&quot; Style=&quot;{StaticResource PhoneTextTitle2Style}&quot;/&gt;
		&lt;/StackPanel&gt;

		&lt;!--ContentPanel - place additional content here--&gt;
		&lt;Grid x:Name=&quot;ContentPanel&quot; Grid.Row=&quot;1&quot; Margin=&quot;12,0,12,0&quot;&gt;
			&lt;StackPanel&gt;
				&lt;TextBlock x:Name=&quot;mTextBlockTitle&quot; Text=&quot;{Binding DisplayName}&quot; Style=&quot;{StaticResource PhoneTextLargeStyle}&quot;/&gt;
				&lt;StackPanel Orientation=&quot;Horizontal&quot;&gt;
					&lt;Button x:Name=&quot;mButtonRefresh&quot; Click=&quot;mButtonRefresh_Click&quot; Content=&quot;Refresh&quot; /&gt;
					&lt;Button x:Name=&quot;mButtonScoreHigh&quot; Click=&quot;mButtonScoreHigh_Click&quot; Content=&quot;High&quot; /&gt;
					&lt;Button x:Name=&quot;mButtonScoreMed&quot; Click=&quot;mButtonScoreMed_Click&quot; Content=&quot;Med&quot; /&gt;
					&lt;Button x:Name=&quot;mButtonScoreLow&quot; Click=&quot;mButtonScoreLow_Click&quot; Content=&quot;Low&quot; /&gt;
				&lt;/StackPanel&gt;
				&lt;ListBox x:Name=&quot;mListBoxScores&quot; ItemsSource=&quot;{Binding Scores}&quot;&gt;
					&lt;ListBox.ItemTemplate&gt;
						&lt;DataTemplate&gt;
							&lt;StackPanel Orientation=&quot;Horizontal&quot; &gt;
								&lt;TextBlock Text=&quot;User: &quot; /&gt;
								&lt;TextBlock Text=&quot;{Binding UserNameDisplay}&quot; /&gt;
								&lt;TextBlock Margin=&quot;15, 0, 0, 0&quot; Text=&quot;Score: &quot;/&gt;
								&lt;TextBlock Text=&quot;{Binding UserScore}&quot; /&gt;
							&lt;/StackPanel&gt;
						&lt;/DataTemplate&gt;
					&lt;/ListBox.ItemTemplate&gt;
				&lt;/ListBox&gt;
			&lt;/StackPanel&gt;
		&lt;/Grid&gt;
	&lt;/Grid&gt;

&lt;/phone:PhoneApplicationPage&gt;</pre><p></p>
<p></p><pre class="crayon-plain-tag">using System;
using System.Linq;
using System.Windows;
using System.Windows.Data;
using Microsoft.Phone.Controls;

namespace XPG.Demo.WinPhone
{
	/// &lt;summary&gt;The leaderboard detail page.&lt;/summary&gt;
	public partial class PageLeaderboard : PhoneApplicationPage
	{
		#region Member Variables

		/// &lt;summary&gt;The selected leaderboard.&lt;/summary&gt;
		private XPGLeaderboardInfo lb;

		#endregion Member Variables

		#region Constructors

		/// &lt;summary&gt;Creates a new instance of &lt;see cref=&quot;PageLeaderboard&quot; /&gt;.&lt;/summary&gt;
		public PageLeaderboard()
		{
			InitializeComponent();
		}

		#endregion Constructors

		#region Event Handlers

		#region mButtonRefresh_Click
		/// &lt;summary&gt;Handles the refresh button being clicked.&lt;/summary&gt;
		/// &lt;param name=&quot;sender&quot;&gt;The sender of the event.&lt;/param&gt;
		/// &lt;param name=&quot;e&quot;&gt;The arguments of the event.&lt;/param&gt;
		private void mButtonRefresh_Click(object sender, RoutedEventArgs e)
		{
			XPGAPI.Instance.GetScores(lb.LeaderboardTag, 0, GetScoresCompleted);
		}
		#endregion mButtonRefresh_Click

		#region mButtonScoreHigh_Click
		/// &lt;summary&gt;Handles the high score button being clicked.&lt;/summary&gt;
		/// &lt;param name=&quot;sender&quot;&gt;The sender of the event.&lt;/param&gt;
		/// &lt;param name=&quot;e&quot;&gt;The arguments of the event.&lt;/param&gt;
		private void mButtonScoreHigh_Click(object sender, RoutedEventArgs e)
		{
			int scoreUpAmount = 10;
			XPGLeaderboardScoreInfo score = lb.Scores.FirstOrDefault();
			if (score != null)
			{
				XPGAPI.Instance.SubmitScore(lb.LeaderboardTag, score.UserScore + scoreUpAmount, SubmitScoreCompleted);
			}
			else
			{
				XPGAPI.Instance.SubmitScore(lb.LeaderboardTag, scoreUpAmount, SubmitScoreCompleted);
			}
		}
		#endregion mButtonScoreHigh_Click

		#region mButtonScoreLow_Click
		/// &lt;summary&gt;Handles the low score button being clicked.&lt;/summary&gt;
		/// &lt;param name=&quot;sender&quot;&gt;The sender of the event.&lt;/param&gt;
		/// &lt;param name=&quot;e&quot;&gt;The arguments of the event.&lt;/param&gt;
		private void mButtonScoreLow_Click(object sender, RoutedEventArgs e)
		{
			try
			{
				XPGLeaderboardScoreInfo score = lb.Scores[0];
				XPGAPI.Instance.SubmitScore(lb.LeaderboardTag, score.UserScore + 1, SubmitScoreCompleted);
			}
			catch
			{
				XPGAPI.Instance.SubmitScore(lb.LeaderboardTag, 1, SubmitScoreCompleted);
			}
		}
		#endregion mButtonScoreLow_Click

		#region mButtonScoreMed_Click
		/// &lt;summary&gt;Handles the medium score button being clicked.&lt;/summary&gt;
		/// &lt;param name=&quot;sender&quot;&gt;The sender of the event.&lt;/param&gt;
		/// &lt;param name=&quot;e&quot;&gt;The arguments of the event.&lt;/param&gt;
		private void mButtonScoreMed_Click(object sender, RoutedEventArgs e)
		{
			try
			{
				XPGLeaderboardScoreInfo score = lb.Scores[0];
				XPGAPI.Instance.SubmitScore(lb.LeaderboardTag, score.UserScore + 5, SubmitScoreCompleted);
			}
			catch
			{
				XPGAPI.Instance.SubmitScore(lb.LeaderboardTag, 5, SubmitScoreCompleted);
			}
		}
		#endregion mButtonScoreMed_Click

		#region OnNavigatedTo
		/// &lt;summary&gt;Handles the page being navigated to.&lt;/summary&gt;
		/// &lt;param name=&quot;e&quot;&gt;The arguments.&lt;/param&gt;
		protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
		{
			base.OnNavigatedTo(e);
			string lbTag = NavigationContext.QueryString[&quot;lbTag&quot;];
			if (string.IsNullOrWhiteSpace(lbTag)) { NavigationService.GoBack(); }

			if (XPGAPI.Instance.CurrentGame != null &amp;&amp; XPGAPI.Instance.CurrentGame.Leaderboards != null)
			{
				lb = XPGAPI.Instance.CurrentGame.Leaderboards.Where(x =&gt; x.LeaderboardTag.Equals(lbTag, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
				if (lb == null) { NavigationService.GoBack(); }

				SetBinding(DataContextProperty, new Binding() { Source = lb });
			}
		}
		#endregion OnNavigatedTo

		#endregion Event Handlers

		#region Methods

		#region GetScoresCompleted
		/// &lt;summary&gt;Invoked when the get scores call completes.&lt;/summary&gt;
		/// &lt;param name=&quot;response&quot;&gt;The servers response.&lt;/param&gt;
		public void GetScoresCompleted(XPGAPIResponse&lt;XPGScoresResultInfo&gt; response)
		{
			if (!response.Failed)
			{
				lb.Scores.Clear();
				foreach (XPGLeaderboardScoreInfo score in response.Body.Scores)
				{
					lb.Scores.Add(score);
				}
			}
			else
			{
				MessageBox.Show(&quot;Request failed: &quot; + response.Message + &quot;.&quot;, &quot;XPG Notification&quot;, MessageBoxButton.OK);
			}
		}
		#endregion GetScoresCompleted

		#region SubmitScoreCompleted
		/// &lt;summary&gt;Invoked when the submit score call completes.&lt;/summary&gt;
		/// &lt;param name=&quot;response&quot;&gt;The servers response.&lt;/param&gt;
		public void SubmitScoreCompleted(XPGAPIResponse&lt;XPGScoreResultInfo&gt; response)
		{
			if (!response.Failed)
			{
				// This is not required, but is shown here for posterity
				XPGAPI.Instance.GetScores(lb.LeaderboardTag, 0, null);
			}
			else
			{
				MessageBox.Show(&quot;Request failed. &quot; + response.Message + &quot;.&quot;, &quot;XPG Notification&quot;, MessageBoxButton.OK);
			}
		}
		#endregion SubmitScoreCompleted

		#endregion Methods
	}
}</pre><p></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.xpglive.com/2012/01/21/how-to-use-leaderboards-on-windows-phone-with-xpg/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How To: Initialize a game on iOS (iPhone/iPad) with XPG</title>
		<link>http://blog.xpglive.com/2012/01/11/how-to-initialize-a-game-on-ios-iphoneipad-with-xpg/</link>
		<comments>http://blog.xpglive.com/2012/01/11/how-to-initialize-a-game-on-ios-iphoneipad-with-xpg/#comments</comments>
		<pubDate>Wed, 11 Jan 2012 17:15:10 +0000</pubDate>
		<dc:creator>Derik (XPG)</dc:creator>
				<category><![CDATA[CodeProject]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[XPG Games]]></category>
		<category><![CDATA[Alert]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Delegate]]></category>
		<category><![CDATA[Game]]></category>
		<category><![CDATA[initialization]]></category>
		<category><![CDATA[iOS]]></category>
		<category><![CDATA[MonoTouch]]></category>
		<category><![CDATA[response]]></category>
		<category><![CDATA[XPG]]></category>

		<guid isPermaLink="false">http://blog.xpglive.com/?p=162</guid>
		<description><![CDATA[This is a continuation of the How To series. This first post is here. This article will cover: Adding the XPG Live API for iOS to your project’s as a framework in XCode Adding the XPG Live API for MonoTouch reference in MonoDevelop Initializing the XPG Live API in code Handling the initialization response Prerequisites [...]]]></description>
				<content:encoded><![CDATA[<p>This is a continuation of the How To series. This first post is <a href="http://blog.xpglive.com/2011/12/30/how-to-get-started-with-xpg/" target="_blank">here</a>.</p>
<p>This article will cover:</p>
<ul>
<li>Adding the XPG Live API for iOS to your project’s as a framework in XCode </li>
<li>Adding the XPG Live API for MonoTouch reference in MonoDevelop </li>
<li>Initializing the XPG Live API in code </li>
<li>Handling the initialization response </li>
</ul>
<p>Prerequisites</p>
<ul>
<li><a href="http://developer.apple.com/xcode/index.php" target="_blank">XCode 4</a> and the iOS SDK </li>
<li><a href="http://www.go-mono.com/mono-downloads/download.html" target="_blank">MonoFramework</a>, and <a href="http://monodevelop.com/Download" target="_blank">MonoDevelop</a> with <a href="http://xamarin.com/monotouch" target="_blank">MonoTouch</a> </li>
<li><a href="http://www.xpglive.com/downloads" target="_blank">XPG Live API for iOS or MonoTouch</a> </li>
<li>An existing project or <a href="http://www.xpglive.com/en/downloads" target="_blank">XPG Demo Source for iOS or MonoTouch</a> </li>
</ul>
<h4>Adding the XPG Live API for iOS as a framework to your project in XCode</h4>
<p>For simplicity sake, and because the source code is freely available, we’ll use the XPG Demo Source for iOS. We’ve also installed the stable release of the XPG Live API for iOS.</p>
<ol>
<li>In the XCode project navigator, select the top “Project” node </li>
<li>With your target selected in the editor, click the “Build Phases” tab at the top of the editor </li>
<li>Expand the “Link Binary With Libraries” section
<p><a href="http://blog.xpglive.com/wp-content/uploads/2012/01/image19.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blog.xpglive.com/wp-content/uploads/2012/01/image_thumb19.png" width="603" height="216" /></a>       </li>
<li>Click the “+” button under the list of libraries to open the library chooser
<p><a href="http://blog.xpglive.com/wp-content/uploads/2012/01/image20.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blog.xpglive.com/wp-content/uploads/2012/01/image_thumb20.png" width="360" height="392" /></a>       </li>
<li>Click the “Add Other…” button to open the finder browse dialog and navigate to “/Developer/XPG/APIs” and select “XPGLive.framework”
<p><a href="http://blog.xpglive.com/wp-content/uploads/2012/01/image21.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blog.xpglive.com/wp-content/uploads/2012/01/image_thumb21.png" width="603" height="269" /></a>      </li>
<li>Click “Open” to add the framework to your project</li>
</ol>
<p>Now your project is setup to use XPG Live.</p>
<p>XCode may show the framework in the project root. You can drag this down into the “Frameworks” group for better organization.</p>
<h4>Adding the XPG Live API for MonoTouch reference in MonoDevelop</h4>
<p>For simplicity sake, and because the source code is freely available, we’ll use the XPG Demo Source for MonoTouch. We’ve also installed the stable release of the XPG Live API for MonoTouch.</p>
<ol>
<li>Right click the “References” node in your project and select the “Edit References…” option     </p>
<p><a href="http://blog.xpglive.com/wp-content/uploads/2012/01/image22.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blog.xpglive.com/wp-content/uploads/2012/01/image_thumb22.png" width="260" height="125" /></a>      </li>
<li>Click the “.Net Assembly” tab and navigate to “/Developer/XPG/APIs”</li>
<li>Select “XPG.iOS.dll” and click “Add”
<p><a href="http://blog.xpglive.com/wp-content/uploads/2012/01/image23.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blog.xpglive.com/wp-content/uploads/2012/01/image_thumb23.png" width="603" height="343" /></a>      </li>
<li>Click “OK” to dismiss the window</li>
</ol>
<p>Now your project is setup to use XPG Live.</p>
<h4>Initializing the XPG Live API in code</h4>
<p>Game initialization is very simple, but does require that you’re registered a free developer account on <a href="http://www.xpglive.com">XPG Live</a>, create a game and activate your first access key. Since we’re using the demo app we’ve already completed those steps. The <a href="http://blog.xpglive.com/2011/12/30/how-to-get-started-with-xpg/">first post of this series</a> gives a walk through of the management app and covers games and access keys.</p>
<p>Objective-C Code</p>
<p>  </p><pre class="crayon-plain-tag">static NSString* _secretKey = @&quot;DEMOKEY000000001&quot;;

-(void)viewDidLoad
{
	[super viewDidLoad];

	[XPGAPI initializeWith:_secretKey andCallback:nil];
	// Could have also used...
	// [XPGAPI initializeWith:_secretKey andCallback:self];
}</pre><p></p>
<p>C# Code</p>
<p></p><pre class="crayon-plain-tag">private static string _secretKey = @&quot;DEMOKEY000000001&quot;;

public override void ViewDidLoad ()
{
	base.ViewDidLoad ();

	XPGAPI.Instance.Initialize (_secretKey, null);
}</pre><p></p>
<p>This will initialize your game locally unless you haven’t enabled iOS as a platform, you fat fingered the access key, or you forgot to activate the access key for your game. In one of these cases you’ll get back a localized failure response.</p>
<h4>Handling the initialization response</h4>
<p>The XPG Live API for iOS is pretty flexible when it comes to event handling. In .Net you can handle events on a per call basis with anonymous delegates, delegate method references, or you can wire up event handler to the API instance. In Objective-C you can implement the protocol on a single class and assign it as the API’s delegate, or you can implement the handled methods of the protocol in each class that needs to be notified and pass “self” as the callback parameter of the API methods. The Objective-C protocol defines all methods as optional, so implement what you need and don’t worry about the rest. The API will only invoke one callback per request. If a delegate was provided in the call then it will be invoked, if the delegate passed was null/nil then the API instance event will be raised if there is one.</p>
<p>Additionally, the API will raise events on the UI thread by default. This is done to protect against accidental cross thread access of UI components. The XPG Live API for iOS DOES NOT directly interact with UI components with the exception of social logins which will be discussed in a later post. You can choose to have your delegate raised on a background thread to keep your main thread free for drawing and updates with the following code:</p>
<p>Objective-C Code</p>
<p></p><pre class="crayon-plain-tag">[XPGAPI callbackOnUIThread:NO];</pre><p></p>
<p>C# Code</p>
<p></p><pre class="crayon-plain-tag">XPGAPI.Instance.UseUIThreadEvents = false;</pre><p></p>
<p>If you choose to handle callbacks on background threads it is your responsibility to manage your cross thread interactions appropriately.</p>
<p>Since this is the first callback you’ll always get, this is a great opportunity to mention that when the initialization call is made is when the server becomes aware of the clients locale. This response, and every response after it, will be sent in the clients locale if at all possible, which means that error messages are not only user friendly but in the users language as well. If you defined game titles and descriptions, etc. for your game in the users language they will also be used here.</p>
<p>Here’s a simple callback example for game initialization:</p>
<p>Objective-C Code</p>
<p></p><pre class="crayon-plain-tag">/** 
* Handle the API having been initialized.
*/
-(void)initializeCompletedWith:(XPGAPIResponse*)response
{
    if (!response.Failed)
    {
        UIAlertView* alert = [[UIAlertView alloc] initWithTitle:@&quot;XPG Notice&quot; message:@&quot;Initialized&quot; delegate:nil cancelButtonTitle:@&quot;OK&quot; otherButtonTitles:nil];
        [alert show];
    }
    else
    {
        UIAlertView* alert = [[UIAlertView alloc] initWithTitle:@&quot;XPG Error&quot; message:response.Message delegate:nil cancelButtonTitle:@&quot;OK&quot; otherButtonTitles:nil];
        [alert show];
    }
}</pre><p></p>
<p>C# Code</p>
<p></p><pre class="crayon-plain-tag">///&lt;summary&gt;Handle the API having been initialized.&lt;/summary&gt;
///&lt;param name=&quot;response&quot; /&gt;The server response to the initialization.&lt;/param&gt;
private void HandleXPGAPIInstanceInitializeCompleted (XPGAPIResponse&lt;XPGInitGameInfo&gt; response)
{
	if(!response.Failed)
	{
		UIAlertView alert = new UIAlertView (&quot;XPG Notice&quot;, &quot;Initialized&quot;, null, &quot;OK&quot;, null);
		alert.Show ();
	}
	else
	{
		UIAlertView alert = new UIAlertView (&quot;XPG Error&quot;, response.Message, null, &quot;OK&quot;, null);
		alert.Show ();
	}
}</pre><p></p>
<p>You’ll notice that not much is going on here. The XPG Live API for iOS handles it’s state so that your game only needs to be concerned with it’s own state.</p>
<p>During this initialization the background queue will also spin up to process any score postings, achievement awards, or friend requests which might not have made it to the server before the last shut down.</p>
<p>Announcements for your game are also brought down with initialization, so this callback could be useful for alerts or other user notifications. When this callback is raised, the leaderboards will be initializing their first page of the latest scores already, so there isn’t much for you to do other than handle your game logic.</p>
<h4>The complete Code</h4>
<p>Objective-C Code</p>
<p></p><pre class="crayon-plain-tag">//
//  RootViewController.h
//  XPGDemoObjC
//

#import &lt;UIKit/UIKit.h&gt;
#import &lt;XPGLive/XPGLive.h&gt;

@interface RootViewController : UITableViewController &lt;XPGAPIReceiver&gt;
{
}

@end</pre><p></p>
<p></p><pre class="crayon-plain-tag">//
//  RootViewController.m
//  XPGDemoObjC
//

#import &quot;RootViewController.h&quot;

@implementation RootViewController

static NSString* _secretKey = @&quot;DEMOKEY000000001&quot;;

- (void)viewDidLoad
{
	[super viewDidLoad];

	[XPGAPI setDelegate:self];
	[XPGAPI initializeWith:_secretKey andCallback:nil];
}

// Standard derived/protocol methods and such removed for brevity

-(void)initializeCompletedWith:(XPGAPIResponse*)response
{
	if (!response.Failed)
	{
		UIAlertView* alert = [[UIAlertView alloc] initWithTitle:@&quot;XPG Notice&quot; message:@&quot;Initialized&quot; delegate:nil cancelButtonTitle:@&quot;OK&quot; otherButtonTitles:nil];
		[alert show];
	}
	else
	{
		UIAlertView* alert = [[UIAlertView alloc] initWithTitle:@&quot;XPG Error&quot; message:response.Message delegate:nil cancelButtonTitle:@&quot;OK&quot; otherButtonTitles:nil];
		[alert show];
	}
}

@end</pre><p></p>
<p>C# Code</p>
<p></p><pre class="crayon-plain-tag">//
//  RootViewController.cs
//  
//  Author:
//       XPG Inc. &lt;support@xpglive.com&gt;
// 

using System;
using System.Linq;
using System.Drawing;
using MonoTouch.UIKit;
using MonoTouch.Foundation;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using XPG;

namespace XPG.Demo.MT
{
	public partial class RootViewController : UITableViewController
	{
		private static string _secretKey = @&quot;DEMOKEY000000001&quot;;

		public RootViewController (string nibName, NSBundle bundle) : base (nibName, bundle)
		{
		}

		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();

			XPGAPI.Instance.InitializeCompleted += HandleXPGAPIInstanceInitializeCompleted;
			XPGAPI.Instance.Initialize (_secretKey, null);
		}

		// Standard derived methods and such removed for brevity

		///&lt;summary&gt;Handle the API having been initialized.&lt;/summary&gt;
		///&lt;param name=&quot;response&quot; /&gt;The server response to the initialization.&lt;/param&gt;
		private void HandleXPGAPIInstanceInitializeCompleted (XPGAPIResponse&lt;XPGInitGameInfo&gt; response)
		{
			if(!response.Failed)
			{
				UIAlertView alert = new UIAlertView (&quot;XPG Notice&quot;, &quot;Initialized&quot;, null, &quot;OK&quot;, null);
				alert.Show ();
			}
			else
			{
				UIAlertView alert = new UIAlertView (&quot;XPG Error&quot;, response.Message, null, &quot;OK&quot;, null);
				alert.Show ();
			}
		}

		// Data source nested class implementation and such removed for brevity
	}
}</pre><p></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.xpglive.com/2012/01/11/how-to-initialize-a-game-on-ios-iphoneipad-with-xpg/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How To: Initialize a game on Android with XPG</title>
		<link>http://blog.xpglive.com/2012/01/10/how-to-initialize-a-game-on-android-with-xpg/</link>
		<comments>http://blog.xpglive.com/2012/01/10/how-to-initialize-a-game-on-android-with-xpg/#comments</comments>
		<pubDate>Tue, 10 Jan 2012 22:03:45 +0000</pubDate>
		<dc:creator>Troy (XPG)</dc:creator>
				<category><![CDATA[CodeProject]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[XPG Games]]></category>
		<category><![CDATA[access]]></category>
		<category><![CDATA[Android]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Game]]></category>
		<category><![CDATA[initialization]]></category>
		<category><![CDATA[JAR]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[MonoDroid]]></category>
		<category><![CDATA[XPG]]></category>

		<guid isPermaLink="false">http://blog.xpglive.com/?p=216</guid>
		<description><![CDATA[This is a continuation of the How To series. This first post is here. This article will cover: Adding the XPG Live API for Android to your project’s build path in Eclipse Adding the XPG Live API for Android reference in Visual Studio Initializing the XPG Live API in code Handling the initialization response Prerequisites [...]]]></description>
				<content:encoded><![CDATA[<p>This is a continuation of the How To series. This first post is <a href="http://blog.xpglive.com/2011/12/30/how-to-get-started-with-xpg/" target="_blank">here</a>.</p>
<p>This article will cover:</p>
<ul>
<li>Adding the XPG Live API for Android to your project’s build path in Eclipse </li>
<li>Adding the XPG Live API for Android reference in Visual Studio </li>
<li>Initializing the XPG Live API in code </li>
<li>Handling the initialization response </li>
</ul>
<p>Prerequisites</p>
<ul>
<li><a href="http://developer.android.com/sdk/index.html" target="_blank">Android SDK</a> </li>
<li><a href="http://www.eclipse.org/downloads/" target="_blank">Eclipse</a> or <a href="http://www.microsoft.com/visualstudio/en-us/products/2010-editions/express" target="_blank">Visual Studio</a> with <a href="http://xamarin.com/monoforandroid" target="_blank">MonoDroid</a> </li>
<li><a href="http://www.xpglive.com/downloads" target="_blank">XPG Live API for Android or MonoDroid</a> </li>
<li>An existing project or <a href="http://www.xpglive.com/en/downloads" target="_blank">XPG Demo Source for Android or MonoDroid</a> </li>
</ul>
<h4>Adding the XPG Live API for Android to your project’s build path in Eclipse</h4>
<p>Copy the XPG.Android_[VERSION].jar and XPG.Android.Doc_[VERSION].jar to your project’s “assets” folder.</p>
<p>In Eclipse, select your project and refresh it</p>
<p>Expand the “assets” folder in your project</p>
<p>Open the context menu on “XPG.Android_[VERSION].jar”</p>
<p>Point to “Build Path” and click “Add to Build Path”</p>
<p><a href="http://blog.xpglive.com/wp-content/uploads/2012/01/image9.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blog.xpglive.com/wp-content/uploads/2012/01/image_thumb9.png" width="414" height="518" /></a></p>
<p>You will see XPG.Android_[VERSION].jar under the “Referenced Libraries” node in your project</p>
<p><a href="http://blog.xpglive.com/wp-content/uploads/2012/01/image10.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blog.xpglive.com/wp-content/uploads/2012/01/image_thumb10.png" width="310" height="318" /></a></p>
<p>Open the context menu for the XPG.Android_[VERSION].jar from the “Referenced Libraries” node</p>
<p>Point to “Build Path” and click “Configure Build Path…”</p>
<p><a href="http://blog.xpglive.com/wp-content/uploads/2012/01/image11.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blog.xpglive.com/wp-content/uploads/2012/01/image_thumb11.png" width="400" height="528" /></a></p>
<p>On the “Libraries” tab, under “XPG.Android_[VERSION].jar, select “Javadoc Location” and click “Edit”</p>
<p><a href="http://blog.xpglive.com/wp-content/uploads/2012/01/image12.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blog.xpglive.com/wp-content/uploads/2012/01/image_thumb12.png" width="603" height="437" /></a></p>
<p>Select “Javadoc in Archive” and “Workspace File”, then click “Browse…”</p>
<p><a href="http://blog.xpglive.com/wp-content/uploads/2012/01/image13.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blog.xpglive.com/wp-content/uploads/2012/01/image_thumb13.png" width="444" height="258" /></a></p>
<p>Expand your project and the “assets” folder, then select “XPG.Android.Doc_[VERSION].jar and click “OK”</p>
<p><a href="http://blog.xpglive.com/wp-content/uploads/2012/01/image14.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blog.xpglive.com/wp-content/uploads/2012/01/image_thumb14.png" width="364" height="400" /></a></p>
<p>Click “OK” again</p>
<p><a href="http://blog.xpglive.com/wp-content/uploads/2012/01/image15.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blog.xpglive.com/wp-content/uploads/2012/01/image_thumb15.png" width="455" height="267" /></a></p>
<p>Now your project is setup to use XPG Live.</p>
<h4>Adding the XPG Live API for Android reference in Visual Studio</h4>
<p>For simplicity sake, and because the source code is freely available, we’ll use the XPG Demo Source for MonoDroid. We’ve also installed the stable release of the XPG Live API for MonoDroid. This reference dialog may look a bit different than yours because of other installed Visual Studio extensions.</p>
<p>Right click the “References” node in your solution and select the “Add Reference…” option</p>
<p><a href="http://blog.xpglive.com/wp-content/uploads/2012/01/image16.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blog.xpglive.com/wp-content/uploads/2012/01/image_thumb16.png" width="603" height="351" /></a></p>
<p>Click the “Browse…” button and navigate to “C:\Program Files (x86)\XPG\APIs” on 64-bit or “C:\Program Files\XPG\APIs” on 32-bit</p>
<p>Select “XPG.Android.dll” and click “Open”</p>
<p><a href="http://blog.xpglive.com/wp-content/uploads/2012/01/image17.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blog.xpglive.com/wp-content/uploads/2012/01/image_thumb17.png" width="511" height="387" /></a></p>
<p>Click “Add” then click “Close”</p>
<p><a href="http://blog.xpglive.com/wp-content/uploads/2012/01/image18.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blog.xpglive.com/wp-content/uploads/2012/01/image_thumb18.png" width="603" height="351" /></a></p>
<p>Now your project is setup to use XPG Live.</p>
<h4>Initializing the XPG Live API in code</h4>
<p>Game initialization is very simple, but does require that you’re registered a free developer account on <a href="http://www.xpglive.com">XPG Live</a>, create a game and activate your first access key. Since we’re using the demo app we’ve already completed those steps. The <a href="http://blog.xpglive.com/2011/12/30/how-to-get-started-with-xpg/">first post of this series</a> gives a walk through of the management app and covers games and access keys.</p>
<p>Java Code</p>
<p></p><pre class="crayon-plain-tag">XPGAPI.Instance.initialize(&quot;DEMOKEY000000001&quot;, AndroidGameActivity.this, new InitializeCompleted());</pre><p></p>
<p>C# Code</p>
<p></p><pre class="crayon-plain-tag">XPGAPI.Instance.Initialize(&quot;DEMOKEY000000001&quot;, this, InitializeCompleted);</pre><p></p>
<p>This will initialize your game locally unless you haven’t enabled Android as a platform, you fat fingered the access key, or you forgot to activate the access key for your game. In one of these cases you’ll get back a localized failure response.</p>
<h4>Handling the initialization response</h4>
<p>The XPG Live API for Android is pretty flexible when it comes to event handling. You can handle events on a per call basis with anonymous delegates, delegate method references, or you can wire up event handler to the API instance. The API will only invoke one callback per request. If a delegate was provided in the call then it will be invoked, if the delegate passed was null then the API instance event will be raised if there is one.</p>
<p>Additionally, the API will raise events on the UI thread by default. This is done to protect against accidental cross thread access of UI components. The XPG Live API for Android DOES NOT directly interact with UI components with the exception of social logins which will be discussed in a later post. You can choose to have your delegate raised on a background thread to keep your main thread free for drawing and updates with the following code:</p>
<p>Java Code</p>
<p></p><pre class="crayon-plain-tag">XPGAPI.Instance.setCallbackOnUiThread(false);</pre><p></p>
<p>C# Code</p>
<p></p><pre class="crayon-plain-tag">XPGAPI.Instance.UseUIThreadEvents = false;</pre><p></p>
<p>If you choose to handle callbacks on background threads it is your responsibility to manage your cross thread interactions appropriately.</p>
<p>Since this is the first callback you’ll always get, this is a great opportunity to mention that when the initialization call is made is when the server becomes aware of the clients locale. This response, and every response after it, will be sent in the clients locale if at all possible, which means that error messages are not only user friendly but in the users language as well. If you defined game titles and descriptions, etc. for your game in the users language they will also be used here.</p>
<p>Here’s a simple callback example for game initialization:</p>
<p>Java Code</p>
<p></p><pre class="crayon-plain-tag">/** 
* Handle the API having been initialized.
*/
private class InitializeCompleted extends
		XPGAPICallbackGeneric&lt;XPGInitGameInfo&gt; {
	@Override
	public void gotResponse(XPGAPIResponseGeneric&lt;XPGInitGameInfo&gt; response) {
		if (!response.getFailed()) {
			if (response.getBody() == null) {
				Toast.makeText(AndroidGameActivity.this, response.getMessage(), Toast.LENGTH_LONG);
			}
			else {
				/* Use response.getBody() or XPGAPI.Instance to access the game and user */
			}
		}
		else {
			Toast.makeText(AndroidGameActivity.this, response.getMessage(), Toast.LENGTH_LONG);
		}
	}
}</pre><p></p>
<p>C# Code</p>
<p></p><pre class="crayon-plain-tag">///&lt;summary&gt;Handle the API having been initialized.&lt;/summary&gt;
///&lt;param name=&quot;response&quot;&gt;The server response to the initialization.&lt;/param&gt;
public void InitializeCompleted(XPGAPIResponse&lt;XPGInitGameInfo&gt; response)
{
	if (!response.Failed)
	{
		if (response.Body == null)
		{
			Toast.MakeText(this, response.Message, ToastLength.Long).Show();
		}
		else
		{
			// Use response.Body or XPGAPI.Instance to access the game and user
		}
	}
	else
	{
		Toast.MakeText(this, response.Message, ToastLength.Long).Show();
	}
}</pre><p></p>
<p>You’ll notice that not much is going on here. The XPG Live API for Android handles it’s state so that your game only needs to be concerned with it’s own state.</p>
<p>During this initialization the background queue will also spin up to process any score postings, achievement awards, or friend requests which might not have made it to the server before the last shut down.</p>
<p>Announcements for your game are also brought down with initialization, so this callback could be useful for toasts or other user notifications. When this callback is raised, the leaderboards will be initializing their first page of the latest scores already, so there isn’t much for you to do other than handle your game logic.</p>
<h4>The complete Code</h4>
<p>Java Code</p>
<p></p><pre class="crayon-plain-tag">package com.android.game;

import com.xpglive.api.XPGAPI;
import com.xpglive.api.XPGAPICallbackGeneric;
import com.xpglive.api.XPGAPIResponseGeneric;
import com.xpglive.api.XPGInitGameInfo;

import android.app.Activity;
import android.os.Bundle;
import android.widget.Toast;

public class AndroidGameActivity extends Activity {
	/** 
	 * Called when the activity is first created.
	 */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
		XPGAPI.Instance.initialize(&quot;DEMOKEY000000001&quot;, AndroidGameActivity.this, new InitializeCompleted());
	}

	/** 
	 * Handle the API having been initialized.
	 */
	private class InitializeCompleted extends
			XPGAPICallbackGeneric&lt;XPGInitGameInfo&gt; {
		@Override
		public void gotResponse(XPGAPIResponseGeneric&lt;XPGInitGameInfo&gt; response) {
			if (!response.getFailed()) {
				if (response.getBody() == null) {
					Toast.makeText(AndroidGameActivity.this, response.getMessage(), Toast.LENGTH_LONG);
				}
				else {
					/* Use body or XPGAPI.Instance to access the game and user */
				}
			}
			else {
				Toast.makeText(AndroidGameActivity.this, response.getMessage(), Toast.LENGTH_LONG);
			}
		}
	}
}</pre><p></p>
<p>C# Code</p>
<p></p><pre class="crayon-plain-tag">using System;
using Android.App;
using Android.Content;
using Android.Graphics;
using Android.OS;
using Android.Widget;
using XPG.Demo.MonoDroid;

namespace XPG.Demo.Android
{
	[Activity(Label = &quot;XPG Demo MonoDroid&quot;, MainLauncher = true, Icon = &quot;@drawable/Main&quot;)]
	public class ActivityMain : Activity
	{
		///&lt;summary&gt;Called when the activity is first created.&lt;/summary&gt;
		///&lt;param name=&quot;bundle&quot;&gt;The saved instance state.&lt;/param&gt;
		protected override void OnCreate(Bundle bundle)
		{
			base.OnCreate(bundle);
			SetContentView(Resource.Layout.main);
			XPGAPI.Instance.Initialize(&quot;DEMOKEY000000001&quot;, this, InitializeCompleted);
		}

		///&lt;summary&gt;Handle the API having been initialized.&lt;/summary&gt;
		///&lt;param name=&quot;response&quot;&gt;The server response to the initialization.&lt;/param&gt;
		public void InitializeCompleted(XPGAPIResponse&lt;XPGInitGameInfo&gt; response)
		{
			if (!response.Failed)
			{
				if (response.Body == null)
				{
					Toast.MakeText(this, response.Message, ToastLength.Long).Show();
				}
				else
				{
					// Use response.Body or XPGAPI.Instance to access the game and user
				}
			}
			else
			{
				Toast.MakeText(this, response.Message, ToastLength.Long).Show();
			}
		}
	}
}</pre><p></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.xpglive.com/2012/01/10/how-to-initialize-a-game-on-android-with-xpg/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How To: Initialize a game on BlackBerry with XPG</title>
		<link>http://blog.xpglive.com/2012/01/08/how-to-initialize-a-game-on-blackberry-with-xpg/</link>
		<comments>http://blog.xpglive.com/2012/01/08/how-to-initialize-a-game-on-blackberry-with-xpg/#comments</comments>
		<pubDate>Sun, 08 Jan 2012 22:36:34 +0000</pubDate>
		<dc:creator>Troy (XPG)</dc:creator>
				<category><![CDATA[CodeProject]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[XPG Games]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[BlackBerry]]></category>
		<category><![CDATA[Game]]></category>
		<category><![CDATA[initialization]]></category>
		<category><![CDATA[JAR]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[response]]></category>
		<category><![CDATA[XPG]]></category>

		<guid isPermaLink="false">http://blog.xpglive.com/?p=191</guid>
		<description><![CDATA[This is a continuation of the How To series. The first post is here. This article will cover: Adding the XPG Live API for BlackBerry to your project’s build path in Eclipse Initializing the XPG Live API in code Handling the initialization response Prerequisites Eclipse with BlackBerry plugin XPG Live API for BlackBerry An existing [...]]]></description>
				<content:encoded><![CDATA[<p>This is a continuation of the How To series. The first post is <a href="http://blog.xpglive.com/2011/12/30/how-to-get-started-with-xpg/" target="_blank">here</a>.</p>
<p>This article will cover:</p>
<ul>
<li>Adding the XPG Live API for BlackBerry to your project’s build path in Eclipse </li>
<li>Initializing the XPG Live API in code </li>
<li>Handling the initialization response </li>
</ul>
<p>Prerequisites</p>
<ul>
<li><a href="http://us.blackberry.com/developers/javaappdev/javaplugin.jsp" target="_blank">Eclipse with BlackBerry plugin</a> </li>
<li><a href="http://www.xpglive.com/downloads" target="_blank">XPG Live API for BlackBerry</a> </li>
<li>An existing project or <a href="http://www.xpglive.com/downloads" target="_blank">XPG Demo Source for BlackBerry</a></li>
</ul>
<h4>Adding the XPG Live API for BlackBerry to your project’s build path in Eclipse</h4>
<p>Ensure you have a “lib” folder under your project’s root folder</p>
<p>Copy the XPG.BlackBerry_[VERSION].jar and XPG.BlackBerry.Doc_[VERSION].jar to your project’s “lib” folder.</p>
<p>In Eclipse, select your project and refresh it</p>
<p>Expand the “lib” folder in your project</p>
<p>Open the context menu on “XPG.BlackBerry_[VERSION].jar”</p>
<p>Point to “Build Path” and click “Add to Build Path”</p>
<p><a href="http://blog.xpglive.com/wp-content/uploads/2012/01/image1.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blog.xpglive.com/wp-content/uploads/2012/01/image_thumb1.png" width="355" height="466" /></a></p>
<p>You will see XPG.BlackBerry_[VERSION].jar under the “Referenced Assemblies” node in your project</p>
<p><a href="http://blog.xpglive.com/wp-content/uploads/2012/01/image2.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blog.xpglive.com/wp-content/uploads/2012/01/image_thumb2.png" width="286" height="231" /></a></p>
<p>Open the context menu for the XPG.BlackBerry_[VERSION].jar from the “Referenced Assemblies” node</p>
<p>Point to “Build Path” and click “Configure Build Path…”</p>
<p><a href="http://blog.xpglive.com/wp-content/uploads/2012/01/image3.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blog.xpglive.com/wp-content/uploads/2012/01/image_thumb3.png" width="370" height="485" /></a></p>
<p>On the “Libraries” tab, under “XPG.BlackBerry_[VERSION].jar, select “Javadoc Location” and click “Edit”</p>
<p><a href="http://blog.xpglive.com/wp-content/uploads/2012/01/image4.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blog.xpglive.com/wp-content/uploads/2012/01/image_thumb4.png" width="603" height="437" /></a></p>
<p>Select “Javadoc in Archive” and “Workspace File”, then click “Browse…”</p>
<p><a href="http://blog.xpglive.com/wp-content/uploads/2012/01/image5.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blog.xpglive.com/wp-content/uploads/2012/01/image_thumb5.png" width="405" height="236" /></a></p>
<p>Expand your project and the “lib” folder, then select “XPG.BlackBerry.Doc_[VERSION].jar and click “OK”</p>
<p><a href="http://blog.xpglive.com/wp-content/uploads/2012/01/image6.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blog.xpglive.com/wp-content/uploads/2012/01/image_thumb6.png" width="367" height="402" /></a></p>
<p>Click “OK” again</p>
<p><a href="http://blog.xpglive.com/wp-content/uploads/2012/01/image7.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blog.xpglive.com/wp-content/uploads/2012/01/image_thumb7.png" width="483" height="281" /></a></p>
<p>Select “Order and Export” tab, check the box for “XPG.BlackBerry_[VERSION].jar and click “OK”</p>
<p><a href="http://blog.xpglive.com/wp-content/uploads/2012/01/image8.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blog.xpglive.com/wp-content/uploads/2012/01/image_thumb8.png" width="603" height="437" /></a></p>
<p>Now your project is setup to use XPG Live.</p>
<h4>Initializing the XPG Live API in Java code</h4>
<p>Game initialization is very simple, but does require that you’re registered a free developer account on <a href="http://www.xpglive.com">XPG Live</a>, create a game and activate your first access key. Since we’re using the demo app we’ve already completed those steps. The <a href="http://blog.xpglive.com/2011/12/30/how-to-get-started-with-xpg/">first post of this series</a> gives a walk through of the management app and covers games and access keys.</p>
<p> </p><pre class="crayon-plain-tag">XPGAPI.Instance.initialize(&quot;DEMOKEY000000001&quot;, new InitializeCompleted());</pre><p></p>
<p>This will initialize your game locally unless you haven’t enabled BlackBerry as a platform, you fat fingered the access key, or you forgot to activate the access key for your game. In one of these cases you’ll get back a localized failure response.</p>
<h4>Handling the initialization response</h4>
<p>The XPG Live API for BlackBerry is pretty flexible when it comes to event handling. You can handle events on a per call basis with anonymous delegates of delegate method references, or you can wire up event handler to the API instance. The API will only invoke one callback per request. If a delegate was provided in the call then it will be invoked, if the delegate passed was null then the API instance event will be raised if there is one.</p>
<p>Additionally, the API will raise events on the UI thread by default. This is done to protect against accidental cross thread access of UI components. The XPG Live API for BlackBerry DOES NOT directly interact with UI components with the exception of social logins which will be discussed in a later post. You can choose to have your delegate raised on a background thread to keep your main thread free for drawing and updates with the following code:</p>
<p></p><pre class="crayon-plain-tag">XPGAPI.Instance.setCallbackOnUIThread(false);</pre><p></p>
<p>If you choose to handle callback on background threads it is your responsibility to manage your cross thread interactions appropriately.</p>
<p>Since this is the first callback you’ll always get, this is a great opportunity to mention that when the initialization call is made is when the server becomes aware of the clients locale. This response, and every response after it, will be sent in the clients locale if at all possible, which means that error messages are not only user friendly but in the users language as well. If you defined game titles and descriptions, etc. for your game in the users language they will also be used here.</p>
<p>Here’s a simple callback example for game initialization:</p>
<p></p><pre class="crayon-plain-tag">private class InitializeCompleted extends XPGAPICallbackInitialize {
	public void gotResponse(XPGAPIResponse response,
			XPGInitGameInfo body) {
		if(!response.getFailed().booleanValue()) {
			if (body == null) {
				Dialog.alert(response.getMessage());
			}
			else {
				/* Use body or XPGAPI.Instance to access the game and user */
			}
		}
		else {
			Dialog.alert(response.getMessage());
		}
	}
}</pre><p></p>
<p>You’ll notice that not much is going on here. The XPG Live API for BlackBerry handles it’s state so that you’re game only needs to be concerned with it’s own state.</p>
<p>During this initialization the background queue will also spin up to process any score postings, achievement awards, or friend requests which might not have made it to the server before the last shut down.</p>
<p>Announcements for your game are also brought down with initialization, so this callback could be useful for toasts or other user notifications. When this callback is raised, the leaderboards will be initializing their first page of the latest scores already, so there isn’t much for you to do other than handle your game logic.</p>
<h4>The complete Java Code</h4>
<p></p><pre class="crayon-plain-tag">package XPG.Demo.BlackBerry;

import com.xpglive.api.XPGAPI;
import com.xpglive.api.XPGAPICallbackInitialize;
import com.xpglive.api.XPGAPIResponse;
import com.xpglive.api.XPGInitGameInfo;

/**
 * A class extending the MainScreen class, which provides default standard
 * behavior for BlackBerry GUI applications.
 */
public final class ScreenMain extends MainScreen {

	/**
	 * Creates a new BlackBerry object
	 */
	public ScreenMain() {
		XPGAPI.Instance.initialize(&quot;DEMOKEY000000001&quot;, null);
	}

	/**
	 * Handle the API having been initialized.
	 */
	private class InitializeCompleted extends XPGAPICallbackInitialize {
		public void gotResponse(XPGAPIResponse response,
				XPGInitGameInfo body) {
			if(!response.getFailed().booleanValue()) {
				if (body == null) {
					Dialog.alert(response.getMessage());
				}
				else {
					/* Use body or XPGAPI.Instance to access the game and user */
				}
			}
			else {
				Dialog.alert(response.getMessage());
			}
		}
	}
}</pre><p></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.xpglive.com/2012/01/08/how-to-initialize-a-game-on-blackberry-with-xpg/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How To: Initialize a game on Windows Phone with XPG</title>
		<link>http://blog.xpglive.com/2012/01/05/how-to-initialize-a-game-on-windows-phone-with-xpg/</link>
		<comments>http://blog.xpglive.com/2012/01/05/how-to-initialize-a-game-on-windows-phone-with-xpg/#comments</comments>
		<pubDate>Thu, 05 Jan 2012 06:20:00 +0000</pubDate>
		<dc:creator>Derik (XPG)</dc:creator>
				<category><![CDATA[CodeProject]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[XPG Games]]></category>
		<category><![CDATA[access]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[callback]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[demo]]></category>
		<category><![CDATA[Game]]></category>
		<category><![CDATA[initialization]]></category>
		<category><![CDATA[reference]]></category>
		<category><![CDATA[response]]></category>
		<category><![CDATA[thread]]></category>
		<category><![CDATA[XPG]]></category>

		<guid isPermaLink="false">http://blog.xpglive.com/?p=171</guid>
		<description><![CDATA[This is a continuation of the How To series. This first post is here. This article will cover: Adding the XPG Live for Windows Phone reference in Visual Studio Initializing the XPG Live API in C# code Handling the initialization response Prerequisites Windows Phone SDK 7.1 for Windows Phone XPG Live API for Windows Phone [...]]]></description>
				<content:encoded><![CDATA[<p>This is a continuation of the How To series. This first post is <a href="http://blog.xpglive.com/2011/12/30/how-to-get-started-with-xpg/" target="_blank">here</a>.</p>
<p>This article will cover:</p>
<ul>
<li>Adding the XPG Live for Windows Phone reference in Visual Studio</li>
<li>Initializing the XPG Live API in C# code</li>
<li>Handling the initialization response</li>
</ul>
<p>Prerequisites</p>
<ul>
<li><a href="http://go.microsoft.com/?linkid=9772716" target="_blank">Windows Phone SDK 7.1 for Windows Phone</a></li>
<li><a href="http://www.xpglive.com/en/downloads" target="_blank">XPG Live API for Windows Phone</a></li>
<li>An existing project or <a href="http://www.xpglive.com/en/downloads" target="_blank">XPG Demo Source for Windows Phone</a></li>
</ul>
<h4>Adding the XPG Live for Windows Phone reference in Visual Studio</h4>
<p>For simplicity sake, and because the source code is freely available, we’ll use the XPG Demo Source for Windows Phone. We’ve also installed the stable release of the XPG Live API for Windows Phone which will list the assembly needed automatically in the reference dialog. This reference dialog may look a bit different than yours because of other installed Visual Studio extensions.</p>
<p><a href="http://blog.xpglive.com/wp-content/uploads/2012/01/image.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://blog.xpglive.com/wp-content/uploads/2012/01/image_thumb.png" alt="image" width="603" height="573" border="0" /></a></p>
<p>As with most Visual Studio assemblies, just right click the “References” node in your solution and select the “Add Reference…” option. The XPG.WinPhone assembly will be listed under “Extension” if you have the Productivity Tools installed. Double click the assembly to add it to your project as a reference and close the dialog if it doesn’t close itself.</p>
<h4>Initializing the XPG Live API in C# code</h4>
<p>Game initialization is very simple, but does require that you’re registered a free developer account on <a href="http://www.xpglive.com" target="_blank">XPG Live</a>, create a game and activate your first access key. Since we’re using the demo app we’ve already completed those steps. The <a href="http://blog.xpglive.com/2011/12/30/how-to-get-started-with-xpg/" target="_blank">first post of this series</a> gives a walk through of the management app and covers games and access keys.</p>
<p> </p><pre class="crayon-plain-tag">string _gameSecretKey = &quot;DEMOKEY000000001&quot;;
XPGAPI.Instance.Initialize(_gameSecretKey, Instance_InitializeCompleted);</pre><p></p>
<p>This will initialize your game locally unless you haven’t enabled Windows Phone as a platform, you fat fingered the access key, or you forgot to activate the access key for your game. In one of these cases you’ll get back a localized failure response.</p>
<h4>Handling the initialization response</h4>
<p>The XPG Live API for Windows Phone is pretty flexible when it comes to event handling. You can handle events on a per call basis with anonymous delegates of delegate method references, or you can wire up event handler to the API instance. The API will only invoke one callback per request. If a delegate was provided in the call then it will be invoked, if the delegate passed was null then the API instance event will be raised if there is one.</p>
<p>Additionally, the API will raise events on the UI thread by default. This is done to protect against accidental cross thread access of UI components. The XPG Live API for Windows Phone DOES NOT directly interact with UI components with the exception of social logins which will be discussed in a later post. You can choose to have your delegate raised on a background thread to keep your main thread free for drawing and updates with the following code:</p>
<p></p><pre class="crayon-plain-tag">XPGAPI.Instance.UseUIThreadEvents = false;</pre><p></p>
<p>If you choose to handle callback on background threads it is your responsibility to manage your cross thread interactions appropriately.</p>
<p>Since this is the first callback you’ll always get, this is a great opportunity to mention that when the initialization call is made is when the server becomes aware of the clients locale. This response, and every response after it, will be sent in the clients locale if at all possible, which means that error messages are not only user friendly but in the users language as well. If you defined game titles and descriptions, etc. for your game in the users language they will also be used here.</p>
<p>Here’s a simple callback example for game initialization:</p>
<p></p><pre class="crayon-plain-tag">///&lt;summary&gt;Handle the API having been initialized.&lt;/summary&gt;
///&lt;param name=&quot;response&quot;&gt;The server response to the initialization.&lt;/param&gt;
public void Instance_InitializeCompleted(XPGAPIResponse&lt;XPGInitGameInfo&gt; response)
{
	if (!response.Failed)
	{
		if (response.Body == null)
		{
			// Show a simple message so we know it returned successful without a body
			MessageBox.Show(response.Message, &quot;XPG Notification&quot;, MessageBoxButton.OK);
		}
	}
	else
	{
		// Show the localized error message
		MessageBox.Show(response.Message, &quot;XPG Notification&quot;, MessageBoxButton.OK);
	}
}</pre><p></p>
<p>You’ll notice that not much is going on here. The XPG Live API for Windows Phone handles it’s state so that you’re game only needs to be concerned with it’s own state.</p>
<p>During this initialization the background queue will also spin up to process any score postings, achievement awards, or friend requests which might not have made it to the server before the last shut down.</p>
<p>Announcements for your game are also brought down with initialization, so this callback could be useful for toasts or other user notifications. When this callback is raised, the leaderboards will be initializing their first page of the latest scores already, so there isn’t much for you to do other than handle your game logic.</p>
<h4>The complete C# Code</h4>
<p></p><pre class="crayon-plain-tag">using System.Windows;
using System.Windows.Data;
using Microsoft.Phone.Controls;

namespace XPG.Demo.WinPhone
{
	///&lt;summary&gt;The primary application page.&lt;/summary&gt;
	public partial class PageMain : PhoneApplicationPage
	{
		#region Member Variables

		///&lt;summary&gt;The Demo game secret key.&lt;/summary&gt;
		private string _gameSecretKey = &quot;DEMOKEY000000001&quot;;

		#endregion Member Variables

		#region Constructors

		///&lt;summary&gt;Creates a new instance of .&lt;/summary&gt;
		public PageMain()
		{
			InitializeComponent();

			XPGAPI.Instance.Initialize(_gameSecretKey, Instance_InitializeCompleted);
		}

		#endregion Constructors

		#region Methods

		#region Instance_InitializeCompleted
		///&lt;summary&gt;Handle the API having been initialized.&lt;/summary&gt;
		///&lt;param name=&quot;response&quot;&gt;The server response to the initialization.&lt;/param&gt;
		public void Instance_InitializeCompleted(XPGAPIResponse&lt;XPGInitGameInfo&gt; response)
		{
			if (!response.Failed)
			{
				if (response.Body == null)
				{
					MessageBox.Show(response.Message, &quot;XPG Notification&quot;, MessageBoxButton.OK);
				}
			}
			else
			{
				MessageBox.Show(response.Message, &quot;XPG Notification&quot;, MessageBoxButton.OK);
			}
		}
		#endregion Instance_InitializeCompleted

		#endregion Methods
	}
}</pre><p></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.xpglive.com/2012/01/05/how-to-initialize-a-game-on-windows-phone-with-xpg/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How To: Get started with XPG</title>
		<link>http://blog.xpglive.com/2011/12/30/how-to-get-started-with-xpg/</link>
		<comments>http://blog.xpglive.com/2011/12/30/how-to-get-started-with-xpg/#comments</comments>
		<pubDate>Fri, 30 Dec 2011 20:48:00 +0000</pubDate>
		<dc:creator>Troy (XPG)</dc:creator>
				<category><![CDATA[CodeProject]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[Account]]></category>
		<category><![CDATA[Achievement]]></category>
		<category><![CDATA[Announcement]]></category>
		<category><![CDATA[Create]]></category>
		<category><![CDATA[Edit]]></category>
		<category><![CDATA[Game]]></category>
		<category><![CDATA[Leaderboard]]></category>
		<category><![CDATA[Manage]]></category>
		<category><![CDATA[Profile]]></category>
		<category><![CDATA[Publisher]]></category>
		<category><![CDATA[XPG]]></category>

		<guid isPermaLink="false">http://blog.xpglive.com/?p=169</guid>
		<description><![CDATA[This is the first article in a series that will walk you through using all of the features XPG Live has to offer. Before you can begin using XPG you’ll need to have an XPG Live account. You’ll notice links in the upper right hand corner of the home page. You can get an XPG [...]]]></description>
				<content:encoded><![CDATA[<h4><span style="font-size: small">This is the first article in a series that will walk you through using all of the features XPG Live has to offer.</span></h4>
<p>Before you can begin using XPG you’ll need to have an XPG Live account.</p>
<p>You’ll notice links in the upper right hand corner of the home page.   <br /><a href="http://blog.xpglive.com/wp-content/uploads/2011/12/image.png"><img style="background-image: none; border-right-width: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blog.xpglive.com/wp-content/uploads/2011/12/image_thumb.png" width="186" height="39" /></a></p>
<p>You can get an XPG account either by completing our simple registration form or by logging in with you existing Facebook or Twitter account.   <br /><a href="http://blog.xpglive.com/wp-content/uploads/2011/12/image1.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blog.xpglive.com/wp-content/uploads/2011/12/image_thumb1.png" width="483" height="293" /></a></p>
<p>Once you’ve registered or logged in you will see your name and a “Log Off” option. XPG Live is Gravatar enabled, so if the email address used in registration is associated to a Gravatar account, there is no need to upload a profile image.   <br /><a href="http://blog.xpglive.com/wp-content/uploads/2011/12/image2.png"><img style="background-image: none; border-right-width: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blog.xpglive.com/wp-content/uploads/2011/12/image_thumb2.png" width="170" height="35" /></a></p>
<p>To get to the management area of XPG, you just click on your name or image. When you first arrive in the management section you will have the following tabs available to you “Profile”, “Relationships”, “Messages”, and “Settings”.</p>
<ul>
<li>The “Profile” page is where you can update basic information (i.e. email, password, name, location, etc.) </li>
<li>The “Relationships” page is where you can send a friend request or respond to incoming requests </li>
<li>The “Messages” page is how you can communicate with your friends on XPG Live. </li>
<li>The “Settings” page allows you to manage profile visibility, notifications, and social accounts. This is where you would go to link a social account if you did not use it to register. </li>
</ul>
<p>The following steps are intended for developers that are making an XPG Live enabled game.</p>
<p>You will find the “Become a Developer” button near the bottom of the screen on “Profile” page.    <br clear="all" /><a href="http://blog.xpglive.com/wp-content/uploads/2011/12/image3.png"><img style="background-image: none; border-right-width: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blog.xpglive.com/wp-content/uploads/2011/12/image_thumb3.png" width="170" height="42" /></a>     <br clear="all" />After you click this button, you will notice that several of the profile fields have been marked as required. Fill out the additional required information and click the “Save” button.     <br clear="all" /><a href="http://blog.xpglive.com/wp-content/uploads/2011/12/image4.png"><img style="background-image: none; border-right-width: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blog.xpglive.com/wp-content/uploads/2011/12/image_thumb4.png" width="92" height="42" /></a>     <br clear="all" />When the “Please wait…” indicator goes away, you will have the following additional tabs:</p>
<ul>
<li>The “Publish” page – Manage your publisher specific information </li>
<li>The “Games” page – Manage or create games </li>
<li>The “Leaderboards” page – manage or create leaderboards for your game </li>
<li>The “Achievements” page – manage or create achievements for your game </li>
<li>The “Announcements” page – manage or create announcements for your game </li>
</ul>
<p>Let’s take a closer look at these pages</p>
<h4>The Publish Page</h4>
<p>   <br clear="all" /><a href="http://blog.xpglive.com/wp-content/uploads/2011/12/image5.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blog.xpglive.com/wp-content/uploads/2011/12/image_thumb5.png" width="603" height="487" /></a></p>
<p>Highlighted in orange is the dropdown that lists all the publishers you own or have access to see. This dropdown also contains a “New Publisher” entry that will allow you to add a publisher.</p>
<p>Highlighted in red is a check box that will indicate the publisher is being created for testing purposes and data associated to it will not be mixed with live data.</p>
<h4>The Games Page</h4>
<p>   <br clear="all" /><a href="http://blog.xpglive.com/wp-content/uploads/2011/12/image61.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image6" border="0" alt="image6" src="http://blog.xpglive.com/wp-content/uploads/2011/12/image6_thumb.png" width="603" height="316" /></a></p>
<p>Use the “Publishers” dropdown to select the publisher you want to edit a game for</p>
<p>Highlighted in orange is a dropdown that lists all the games associated to the selected publisher. This dropdown also contains a “New Game” entry that will allow you to add a game to the selected publisher.</p>
<p>Highlighted in red is a check box that will indicate the game is being created for testing purposes and data associated to it will not be mixed with live data. This check box is checked and disabled if the publisher is a test only publisher.</p>
<p>Highlighted in green are the game features. Be sure that you check the box for each feature that your game will use.</p>
<p>Highlighted in yellow is the “Add Language” button. This button opens the language selection dialog (below). Check the check boxes next to each language you would like to provide a translation for and those tabs will be added to the property that the “Add Language” button was clicked from.    <br clear="all" /><a href="http://blog.xpglive.com/wp-content/uploads/2011/12/image7.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blog.xpglive.com/wp-content/uploads/2011/12/image_thumb7.png" width="426" height="271" /></a></p>
<p><a href="http://blog.xpglive.com/wp-content/uploads/2011/12/image8.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blog.xpglive.com/wp-content/uploads/2011/12/image_thumb8.png" width="431" height="180" /></a></p>
<p>Below are the additional views for each game</p>
<p>The “Access Key” tab – allows you to add versions of your game    <br clear="all" />The “Platforms” tab – manage the platforms that your game will be available on and enter your games id from the platform specific store and click “Refresh” button for that platform     <br clear="all" />The “Images” tab – shows the images that XPG Live automatically imports for you from the platform specific stores</p>
<p><a href="http://blog.xpglive.com/wp-content/uploads/2011/12/image9.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blog.xpglive.com/wp-content/uploads/2011/12/image_thumb9.png" width="603" height="541" /></a></p>
<h4>The Leaderboards Page</h4>
<p><a href="http://blog.xpglive.com/wp-content/uploads/2011/12/image67.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blog.xpglive.com/wp-content/uploads/2011/12/image67_thumb.png" width="603" height="319" /></a></p>
<p>Highlighted in red are the actions for leaderboard.</p>
<p>From the left:</p>
<ul>
<li>Edit Leaderboard – displays the leaderboard editing window (below) </li>
<li>Reset Leaderboard – clears scores posted to that leaderboard and cannot be undone </li>
<li>Delete Leaderboard – removes the leaderboard from the game </li>
</ul>
<p><a href="http://blog.xpglive.com/wp-content/uploads/2011/12/image11.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blog.xpglive.com/wp-content/uploads/2011/12/image_thumb11.png" width="397" height="352" /></a></p>
<h4>The Achievements Page</h4>
<p><a href="http://blog.xpglive.com/wp-content/uploads/2011/12/image12.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blog.xpglive.com/wp-content/uploads/2011/12/image_thumb12.png" width="603" height="316" /></a></p>
<p>Highlighted in red are the actions for achievement.</p>
<p>From the left:</p>
<ul>
<li>Edit Achievement – displays the achievement editing window (below) </li>
<li>Reset Achievement – clears all users from having earned the achievement and cannot be undone </li>
<li>Delete Achievement – removes the achievement from the game </li>
</ul>
<p><a href="http://blog.xpglive.com/wp-content/uploads/2011/12/image13.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blog.xpglive.com/wp-content/uploads/2011/12/image_thumb13.png" width="603" height="294" /></a></p>
<h4>The Announcements Page</h4>
<p><a href="http://blog.xpglive.com/wp-content/uploads/2011/12/image14.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blog.xpglive.com/wp-content/uploads/2011/12/image_thumb14.png" width="603" height="319" /></a></p>
<p>Highlighted in red are the actions for announcement.</p>
<p>From the left:</p>
<ul>
<li>Edit Announcement – displays the edit announcement dialog (below) </li>
<li>Delete Announcement – removes the announcement from the game </li>
</ul>
<p><a href="http://blog.xpglive.com/wp-content/uploads/2011/12/image15.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blog.xpglive.com/wp-content/uploads/2011/12/image_thumb15.png" width="447" height="245" /></a></p>
<p>&#160;</p>
<h3>Stay tuned for more in this How To series on XPG Live!</h3>
]]></content:encoded>
			<wfw:commentRss>http://blog.xpglive.com/2011/12/30/how-to-get-started-with-xpg/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>
