Permalink
Browse files

Updated SDK

  • Loading branch information...
1 parent c0927fa commit 00b0f69e76a0cee38a8b3da87f282ba2749e4412 @lannymcnie lannymcnie committed Nov 14, 2012
Showing with 700 additions and 331 deletions.
  1. +226 −0 scripts/BrowserDetect.js
  2. +1 −1 scripts/libs/atari/Atari.js
  3. +1 −1 scripts/libs/atari/Fonts.js
  4. +7 −6 scripts/libs/atari/GameBootstrap.js
  5. +35 −12 scripts/libs/atari/GameMediator.js
  6. +34 −16 scripts/libs/atari/GameShell.js
  7. +0 −83 scripts/libs/atari/HighScores.js
  8. +2 −2 scripts/libs/gamelibs/FPSMeter.js
  9. +1 −1 scripts/libs/gamelibs/GameDetails.js
  10. +1 −1 scripts/libs/gamelibs/GameLibs.js
  11. +114 −8 scripts/libs/gamelibs/GameUI.js
  12. +31 −5 scripts/libs/gamelibs/Math2.js
  13. +2 −2 scripts/libs/gamelibs/Parallax.js
  14. +1 −1 scripts/libs/gamelibs/ParticleEmitter.js
  15. +3 −1 scripts/libs/gamelibs/PerformanceMonitor.js
  16. +1 −1 scripts/libs/gamelibs/Point2.js
  17. +3 −1 scripts/libs/gamelibs/ScoreManager.js
  18. +2 −2 scripts/libs/gamelibs/SpriteSheetWrapper.js
  19. +1 −1 scripts/libs/gamelibs/StringUtils.js
  20. +1 −1 scripts/libs/gamelibs/TexturePackerUtils.js
  21. +4 −4 scripts/libs/gamelibs/input/ArcadeButton.js
  22. +2 −2 scripts/libs/gamelibs/input/GamePad.js
  23. +11 −9 scripts/libs/gamelibs/input/Joystick.js
  24. +13 −13 scripts/libs/gamelibs/input/Throttle.js
  25. +1 −1 scripts/libs/gamelibs/input/TouchBar.js
  26. +1 −1 scripts/libs/gamelibs/multiplayer/FramePacket.js
  27. +123 −4 scripts/libs/gamelibs/multiplayer/GameInfo.js
  28. +1 −1 scripts/libs/gamelibs/multiplayer/GamePacket.js
  29. +13 −8 scripts/libs/gamelibs/multiplayer/MultiPlayerGame.js
  30. +4 −4 scripts/libs/gamelibs/multiplayer/Player.js
  31. +3 −3 scripts/libs/gametemplate/manifest.json
  32. +0 −125 scripts/libs/gametemplate/src/scripts/Game-STUB.js
  33. +14 −6 scripts/libs/gametemplate/src/scripts/Game.js
  34. +1 −1 scripts/libs/gskinner/LocalStorage.js
  35. +1 −1 scripts/libs/gskinner/ProximityManager.js
  36. +1 −1 scripts/libs/gskinner/Rnd.js
  37. +1 −1 scripts/libs/gskinner/StringUtils.js
  38. +39 −0 scripts/libs/gskinner/VendorPrefixUtil.js
View
@@ -0,0 +1,226 @@
+(function(scope) {
+
+ /**
+ * BrowserDetect derived from http://www.quirksmode.org/js/detect.html
+ */
+ var s = {};
+
+// Public properties:
+
+ s.browser = null;
+ s.version = null;
+ s.os = null;
+
+ s.isIE = function () {
+ return s.browser == 'Explorer';
+ };
+
+ s.isVista = function() {
+ return navigator.userAgent.indexOf('Windows NT 6.0') != -1;
+ };
+
+ s.isXP = function() {
+ return navigator.userAgent.indexOf('Windows NT 5') != -1;
+ };
+
+ s.isWindows = function() {
+ return s.os == "Windows";
+ };
+
+ s.isWP8 = function () {
+ return navigator.userAgent.indexOf('Windows Phone 8') != -1;
+ };
+
+ s.isWP7 = function () {
+ return navigator.userAgent.indexOf('Windows Phone 7') != -1;
+ };
+
+ s.isAndroid = function() {
+ return navigator.userAgent.indexOf('Android') != -1;
+ };
+
+ s.isIE9 = function () {
+ return this.isIE() && this.getInternetExplorerVersion() == 9;
+ };
+
+ s.isMac = function() {
+ return s.os == "Mac" || s.isIOS();
+ };
+
+ s.isIOS = function() {
+ return s.os == "iPhone/iPod" || s.os == "iPad";
+ };
+
+ s.isIOSRetina = function () {
+ return s.isIOS() && window.devicePixelRatio > 1;
+ };
+
+ s.isMobileSafari = function() {
+ return s.isSafari() && s.isIOS();
+ };
+
+ s.isSafari = function() {
+ return s.browser == "Safari";
+ };
+
+ s.isChrome = function() {
+ return s.browser == "Chrome";
+ };
+
+ s.isFirefox = function() {
+ return s.browser == "Firefox" || s.browser == "Mozilla";
+ };
+
+ s.isOpera = function () {
+ return s.browser == "Opera";
+ };
+
+ s.getInternetExplorerVersion = function()
+ // Returns the version of Internet Explorer or a -1
+ // (indicating the use of another browser).
+ {
+ var rv = -1; // Return value assumes failure.
+ if (navigator.appName == 'Microsoft Internet Explorer')
+ {
+ var ua = navigator.userAgent;
+ var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
+ if (re.exec(ua) != null)
+ rv = parseFloat( RegExp.$1 );
+ }
+ return rv;
+ }
+
+// Protected properties:
+
+ s._dataBrowser = [
+ {
+ string: navigator.userAgent,
+ subString: "Chrome",
+ identity: "Chrome"
+ },
+ { string: navigator.userAgent,
+ subString: "OmniWeb",
+ versionSearch: "OmniWeb/",
+ identity: "OmniWeb"
+ },
+ {
+ string: navigator.vendor,
+ subString: "Apple",
+ identity: "Safari",
+ versionSearch: "Version"
+ },
+ {
+ prop: window.opera,
+ identity: "Opera",
+ versionSearch: "Version"
+ },
+ {
+ string: navigator.vendor,
+ subString: "iCab",
+ identity: "iCab"
+ },
+ {
+ string: navigator.vendor,
+ subString: "KDE",
+ identity: "Konqueror"
+ },
+ {
+ string: navigator.userAgent,
+ subString: "Firefox",
+ identity: "Firefox"
+ },
+ {
+ string: navigator.vendor,
+ subString: "Camino",
+ identity: "Camino"
+ },
+ { // for newer Netscapes (6+)
+ string: navigator.userAgent,
+ subString: "Netscape",
+ identity: "Netscape"
+ },
+ {
+ string: navigator.userAgent,
+ subString: "MSIE",
+ identity: "Explorer",
+ versionSearch: "MSIE"
+ },
+ {
+ string: navigator.userAgent,
+ subString: "Gecko",
+ identity: "Mozilla",
+ versionSearch: "rv"
+ },
+ { // for older Netscapes (4-)
+ string: navigator.userAgent,
+ subString: "Mozilla",
+ identity: "Netscape",
+ versionSearch: "Mozilla"
+ }
+ ];
+
+ s._dataOS = [
+ {
+ string: navigator.platform,
+ subString: "Win",
+ identity: "Windows"
+ },
+ {
+ string: navigator.platform,
+ subString: "Mac",
+ identity: "Mac"
+ },
+ {
+ string: navigator.userAgent,
+ subString: "iPhone",
+ identity: "iPhone/iPod"
+ },
+ {
+ string: navigator.userAgent,
+ subString: "iPad",
+ identity: "iPad"
+ },
+ {
+ string: navigator.platform,
+ subString: "Linux",
+ identity: "Linux"
+ }
+ ];
+
+ s._versionSearchString = null;
+
+// Public methods:
+
+ s.init = function () {
+ s.browser = s._searchString(s._dataBrowser) || "An unknown browser";
+ s.version = s._searchVersion(navigator.userAgent) || s._searchVersion(navigator.appVersion) || "An unknown version";
+ s.os = s._searchString(s._dataOS) || "An unknown OS";
+ };
+
+// Protected methods:
+
+ s._searchString = function (data) {
+ for (var i = 0, l = data.length; i < l; i++) {
+ var dataString = data[i].string;
+ var dataProp = data[i].prop;
+
+ s._versionSearchString = data[i].versionSearch || data[i].identity;
+ if (dataString) {
+ if (dataString.indexOf(data[i].subString) != -1) { return data[i].identity; }
+ } else if (dataProp) {
+ return data[i].identity;
+ }
+ }
+ };
+
+ s._searchVersion = function (dataString) {
+ var index = dataString.indexOf(s._versionSearchString);
+ if (index == -1) { return; }
+ return parseFloat(dataString.substring(index + s._versionSearchString.length + 1));
+ };
+
+scope.BrowserDetect = s;
+
+s.init(); // Auto init class.
+
+}(window.AtariSite!=null?window.AtariSite:window));
@@ -3,7 +3,7 @@
* Developed by gskinner.com in partnership with Atari
* Visit http://atari.com/arcade/developers for documentation, updates and examples.
*
-* ©Atari Interactive, Inc. All Rights Reserved. Atari and the Atari logo are trademarks owned by Atari Interactive, Inc.
+* Copyright (c) (c) Atari Interactive, Inc. All Rights Reserved. Atari and the Atari logo are trademarks owned by Atari Interactive, Inc.
*
* Distributed under the terms of the MIT license.
* http://www.opensource.org/licenses/mit-license.html
@@ -3,7 +3,7 @@
* Developed by gskinner.com in partnership with Atari
* Visit http://atari.com/arcade/developers for documentation, updates and examples.
*
-* ©Atari Interactive, Inc. All Rights Reserved. Atari and the Atari logo are trademarks owned by Atari Interactive, Inc.
+* Copyright (c) Atari Interactive, Inc. All Rights Reserved. Atari and the Atari logo are trademarks owned by Atari Interactive, Inc.
*
* Distributed under the terms of the MIT license.
* http://www.opensource.org/licenses/mit-license.html
@@ -3,7 +3,7 @@
* Developed by gskinner.com in partnership with Atari
* Visit http://atari.com/arcade/developers for documentation, updates and examples.
*
-* ©Atari Interactive, Inc. All Rights Reserved. Atari and the Atari logo are trademarks owned by Atari Interactive, Inc.
+* Copyright (c) Atari Interactive, Inc. All Rights Reserved. Atari and the Atari logo are trademarks owned by Atari Interactive, Inc.
*
* Distributed under the terms of the MIT license.
* http://www.opensource.org/licenses/mit-license.html
@@ -109,10 +109,10 @@
*/
s.initialize = function() {
// Selectively set the plugins
- /*createjs.FlashPlugin.BASE_PATH = window.BASE_PATH + "scripts/soundjs/";
- if (AtariSite.BrowserDetect.isSafari()) {
+ createjs.FlashPlugin.BASE_PATH = window.BASE_PATH + "scripts/soundjs/";
+ if (createjs.PreloadJS.BrowserDetect.isIOS) {
createjs.SoundJS.registerPlugin(createjs.FlashPlugin);
- }*/
+ }
}
/**
@@ -143,8 +143,9 @@
var manifest = s.manifest = this.owner.currentGameManifest;
s.canvas = canvas;
- canvas.width = manifest.width;
- canvas.height = manifest.height;
+ // LM: DEPRECATED FOR NOW
+ //canvas.width = manifest.width;
+ //canvas.height = manifest.height;
// Append base to each path
var assets = [];
@@ -3,7 +3,7 @@
* Developed by gskinner.com in partnership with Atari
* Visit http://atari.com/arcade/developers for documentation, updates and examples.
*
-* ©Atari Interactive, Inc. All Rights Reserved. Atari and the Atari logo are trademarks owned by Atari Interactive, Inc.
+* Copyright (c) Atari Interactive, Inc. All Rights Reserved. Atari and the Atari logo are trademarks owned by Atari Interactive, Inc.
*
* Distributed under the terms of the MIT license.
* http://www.opensource.org/licenses/mit-license.html
@@ -51,6 +51,7 @@
s.RESTART_GAME = "restartGame";
s.DESTROY_GAME = "destroyGame";
s.REDUCE_FRAMERATE = "reduceFrameRate";
+ s.REMOVE_PLAYER = "removePlayer";
/**
* Defines the constant for a notify-level error, which can usually be ignored.
@@ -243,6 +244,11 @@
}
},
+ toggleVisibility: function(visible) {
+ // Consider throttling Tick...
+ GameLibs.GamePad.reset();
+ },
+
/**
* Register the game instance with the GameMediator. This ensures that all the game has all the
* required methods and event handlers defined, and adds handlers for events. Note that the
@@ -305,34 +311,42 @@
this.shell = shell;
this.multiPlayerGame = mpg;
+ // Scale the canvas to fit the GameInfo.
+ var canvas = this.stage.canvas;
+ var gameInfo = this.shell.gameInfo;
+
+ // Set the Canvas size
+ canvas.width = gameInfo.width;
+ canvas.height = gameInfo.height;
+
+ // On hi-resolution platforms, we need to counter-scale.
+ canvas.style.width = gameInfo.width * gameInfo.scaleFactor + "px";
+ canvas.style.height = gameInfo.height * gameInfo.scaleFactor + "px";
+
// Initialize the game itself.
- if (true || Atari.developerMode) {
- this.gameInstance.initialize(this.currentAssets, this.stage, this.shell.gameInfo);
- } else {
- try {
- this.gameInstance.initialize(this.currentAssets, this.stage, this.shell.gameInfo);
- } catch (error) {
- this.showError(error, "Unable to initialize game.");
- }
- }
+ this.gameInstance.initialize(this.currentAssets, this.stage, gameInfo);
},
/**
* Start the game. This sets up the tick, and calls startGame on the game instance.
* @method startGame
*/
startGame: function() {
+ var gameInfo = this.shell.gameInfo;
+
var fps = this.shell.currentGameManifest.fps;
if (fps == null || isNaN(fps)) { fps = 30; }
createjs.Ticker.setFPS(fps);
this.targetFPS = fps;
this.targetMS = 1000 / fps;
- //Ticker.useRAF = true;
+ if (gameInfo.platform != GameLibs.GameInfo.PLATFORM_IPHONE) {
+ createjs.Ticker.useRAF = true;
+ }
createjs.Ticker.addListener(this, false);
- Atari.trace("[GameMediator] Staring game. Total players: " + this.shell.gameInfo.players.length);
+ Atari.trace("[GameMediator] Staring game. Total players: " + gameInfo.players.length);
this.gameInstance.startGame();
},
@@ -356,6 +370,9 @@
* @param {String} message A verbose message for the logs.
*/
logError: function(error, message) {
+ if(Atari.developerMode){
+ throw(error);
+ }
Atari.trace(error);
},
@@ -585,6 +602,12 @@
}
break;
+ case s.REMOVE_PLAYER:
+ if(game.removePlayer){
+ game.removePlayer(args);
+ }
+ break;
+
case s.CONTINUE_GAME:
createjs.Ticker.addListener(this, false);
if (dev) {
Oops, something went wrong.

0 comments on commit 00b0f69

Please sign in to comment.