Advertisement
lokhmakov

Untitled

May 25th, 2014
366
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.05 KB | None | 0 0
  1. /// <reference path='../bower_components/phaser-official/build/phaser.d.ts' />
  2. /// <reference path='jquery.d.ts' />
  3. /// <reference path='game.ts' />
  4.  
  5. module SlashSystem {
  6. export class Boot extends Phaser.State {
  7. preload() {
  8. this.load.image('preloader', 'assets/loader.png');
  9. this.load.image('splash', 'http://www.picshare.ru/uploads/140522/hXB9JoQi17.png');
  10. }
  11.  
  12. create() {
  13. this.stage.disableVisibilityChange = true;
  14. this.scaleStage();
  15. this.game.state.start('preloader');
  16. }
  17.  
  18. scaleStage() {
  19. if (this.game.device.desktop) {
  20. this.scale.scaleMode = Phaser.ScaleManager.NO_SCALE;
  21. //this.scale.hasResized.add(this.gameResized, this);
  22. } else {
  23. this.scale.scaleMode = Phaser.ScaleManager.NO_BORDER;;
  24. this.scale.forceOrientation(true, false);
  25. this.scale.hasResized.add(this.gameResized, this);
  26. this.scale.enterIncorrectOrientation.add(this.enterIncorrectOrientation, this);
  27. this.scale.leaveIncorrectOrientation.add(this.leaveIncorrectOrientation, this);
  28. this.scale.setScreenSize(true);
  29. }
  30.  
  31. this.scale.minWidth = SlashSystem.Game.gameWidth/2;
  32. this.scale.minHeight = SlashSystem.Game.gameHeight/2;
  33. this.scale.maxWidth = SlashSystem.Game.gameWidth;
  34. this.scale.maxHeight = SlashSystem.Game.gameHeight;
  35. this.scale.pageAlignHorizontally = true;
  36. this.scale.pageAlignVertically = true;
  37. this.scale.setScreenSize(true);
  38.  
  39. if (this.scale.scaleMode == Phaser.ScaleManager.NO_BORDER) {
  40. SlashSystem.Game.viewX = (this.scale.width/2 - window.innerWidth/2)*this.scale.scaleFactor.x;
  41. SlashSystem.Game.viewY = (this.scale.height/2 - window.innerHeight/2 - 1)*this.scale.scaleFactor.y;
  42. SlashSystem.Game.viewWidth = SlashSystem.Game.gameWidth-SlashSystem.Game.viewX;
  43. SlashSystem.Game.viewHeight = SlashSystem.Game.gameHeight-SlashSystem.Game.viewY;
  44. } else {
  45. SlashSystem.Game.viewX = 0;
  46. SlashSystem.Game.viewY = 0;
  47. SlashSystem.Game.viewWidth = SlashSystem.Game.gameWidth;
  48. SlashSystem.Game.viewHeight = SlashSystem.Game.gameHeight;
  49. }
  50.  
  51. document.getElementById('game').style.width = window.innerWidth+'px';
  52. document.getElementById('game').style.height = window.innerHeight-1+'px';//The css for body includes 1px top margin, I believe this is the cause for this -1
  53. document.getElementById('game').style.overflow = "hidden";
  54. }
  55.  
  56. gameResized(width, height) {
  57.  
  58. }
  59.  
  60. enterIncorrectOrientation() {
  61. document.getElementById('orientation').style.display = 'block';
  62. }
  63.  
  64. leaveIncorrectOrientation() {
  65. document.getElementById('orientation').style.display = 'none';
  66. }
  67. }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement