-
Notifications
You must be signed in to change notification settings - Fork 22
/
GameCenterPlugin.js
46 lines (37 loc) · 1.15 KB
/
GameCenterPlugin.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
function GameCenter() {
if(localStorage.getItem('GameCenterLoggedin')) {
PhoneGap.exec("GameCenterPlugin.authenticateLocalPlayer");
}
}
GameCenter.prototype.authenticate = function() {
PhoneGap.exec("GameCenterPlugin.authenticateLocalPlayer");
};
GameCenter.prototype.showLeaderboard = function(category) {
PhoneGap.exec("GameCenterPlugin.showLeaderboard",category);
};
GameCenter.prototype.reportScore = function(category,score) {
PhoneGap.exec("GameCenterPlugin.reportScore",category,score);
};
GameCenter.prototype.showAchievements = function() {
PhoneGap.exec("GameCenterPlugin.showAchievements");
};
GameCenter.prototype.getAchievement = function(category) {
PhoneGap.exec("GameCenterPlugin.reportAchievementIdentifier",category,100);
};
GameCenter._userDidLogin = function() {
localStorage.setItem('GameCenterLoggedin', 'true');
};
GameCenter._userDidSubmitScore = function() {
alert('score submitted');
};
GameCenter._userDidFailSubmitScore = function() {
alert('score error');
};
PhoneGap.addConstructor(function()
{
if(!window.plugins)
{
window.plugins = {};
}
window.plugins.gamecenter = new GameCenter();
});