game.js 2.0 KB

123456789101112131415161718192021222324252627282930
  1. /// <reference path="../vs-doc.js" />
  2. // 定义游戏对象
  3. var game; // 基础路径
  4. var baseUrl = "";
  5. var currentSelectPerson = 0;
  6. // 分数
  7. var score = 0;
  8. var textures = { title: new Jyo.Texture(), startTips: new Jyo.Texture(), ranklistBg: new Jyo.Texture(), items: new Jyo.Texture(), faces: new Jyo.Texture(), btnStart: new Jyo.Texture(), btnStart1: new Jyo.Texture(), btnRanklist: new Jyo.Texture(), body: new Jyo.Texture(), box: new Jyo.Texture(), gameOverTitle: new Jyo.Texture(), gameOverBg: new Jyo.Texture(), gameOverSubTitle: new Jyo.Texture(), btnGameOver: new Jyo.Texture(), bang: new Jyo.Texture(), dialog: new Jyo.Texture(), ranklistElement: new Jyo.Texture() }; var backgroundMusic = document.createElement("audio"); backgroundMusic.addEventListener("ended", function () { this.play(); }, false); backgroundMusic.addEventListener("canplaythrough", function () { if (this.canPlay) { this.play(); } }, false); backgroundMusic.src = baseUrl + "#"; var isInit = false; try { game = new Jyo.Game(); } catch (e) { } window.onload = function () {
  9. //IE6-9
  10. document.body.onselectstart = document.body.ondrag = function () { return false; }
  11. document.getElementById("score").onselectstart = document.getElementById("score").onselect = function (e) {
  12. e = e || event; e.returnValue = false; e.stopPropagation(); e.preventDefault();
  13. document.getElementById("game").focus();
  14. };
  15. document.getElementById("game").onselectstart = document.getElementById("game").onselect = function (e) {
  16. e = e || event; e.returnValue = false;
  17. e.stopPropagation();
  18. e.preventDefault();
  19. document.getElementById("game").focus(); };
  20. // 实例化游戏对象
  21. game = game = new Jyo.Game("game", "Canvas");
  22. // 运行游戏
  23. game.run();
  24. // updateShare(0);
  25. // 设置资源根目录
  26. game.content.rootDirectory = "content";
  27. // 设置画布为同比缩放模式
  28. game.renderer.enableAutoSize("ratio"); // 加载开始屏幕
  29. Jyo.importScript(baseUrl + "scripts/status/startScreen.js"); };
  30. window.onunload = function () { backgroundMusic.src = "#"; };