├── .gitattributes ├── .gitignore ├── apple-touch-icon.png ├── assets ├── large │ ├── bg.jpg │ └── playBtn.png ├── normal │ ├── bg.jpg │ └── playBtn.png ├── small │ ├── bg.jpg │ └── playBtn.png ├── xlarge │ ├── bg.jpg │ └── playBtn.png └── xxlarge │ ├── bg.jpg │ └── playBtn.png ├── css └── stylesheet.css ├── icons ├── app_icon_1024x1024.png ├── app_icon_114x114.png ├── app_icon_120x120.png ├── app_icon_144x144.png ├── app_icon_152x152.png ├── app_icon_256x256.png ├── app_icon_512x512.png ├── app_icon_57x57.png ├── app_icon_60x60.png ├── app_icon_72x72.png └── app_icon_76x76.png ├── images └── orientation.jpg ├── index.html └── src ├── game └── scene │ ├── Boot.js │ ├── Game.js │ ├── MainMenu.js │ └── Preloader.js └── lib ├── ScaleManager2.js └── phaser.js /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | *.sln merge=union 7 | *.csproj merge=union 8 | *.vbproj merge=union 9 | *.fsproj merge=union 10 | *.dbproj merge=union 11 | 12 | # Standard to msysgit 13 | *.doc diff=astextplain 14 | *.DOC diff=astextplain 15 | *.docx diff=astextplain 16 | *.DOCX diff=astextplain 17 | *.dot diff=astextplain 18 | *.DOT diff=astextplain 19 | *.pdf diff=astextplain 20 | *.PDF diff=astextplain 21 | *.rtf diff=astextplain 22 | *.RTF diff=astextplain 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ################# 2 | ## Eclipse 3 | ################# 4 | 5 | *.pydevproject 6 | .project 7 | .metadata 8 | bin/ 9 | tmp/ 10 | *.tmp 11 | *.bak 12 | *.swp 13 | *~.nib 14 | local.properties 15 | .classpath 16 | .settings/ 17 | .loadpath 18 | 19 | # External tool builders 20 | .externalToolBuilders/ 21 | 22 | # Locally stored "Eclipse launch configurations" 23 | *.launch 24 | 25 | # CDT-specific 26 | .cproject 27 | 28 | # PDT-specific 29 | .buildpath 30 | 31 | 32 | ################# 33 | ## Visual Studio 34 | ################# 35 | 36 | ## Ignore Visual Studio temporary files, build results, and 37 | ## files generated by popular Visual Studio add-ons. 38 | 39 | # User-specific files 40 | *.suo 41 | *.user 42 | *.sln.docstates 43 | 44 | # Build results 45 | [Dd]ebug/ 46 | [Rr]elease/ 47 | *_i.c 48 | *_p.c 49 | *.ilk 50 | *.meta 51 | *.obj 52 | *.pch 53 | *.pdb 54 | *.pgc 55 | *.pgd 56 | *.rsp 57 | *.sbr 58 | *.tlb 59 | *.tli 60 | *.tlh 61 | *.tmp 62 | *.vspscc 63 | .builds 64 | *.dotCover 65 | 66 | ## TODO: If you have NuGet Package Restore enabled, uncomment this 67 | #packages/ 68 | 69 | # Visual C++ cache files 70 | ipch/ 71 | *.aps 72 | *.ncb 73 | *.opensdf 74 | *.sdf 75 | 76 | # Visual Studio profiler 77 | *.psess 78 | *.vsp 79 | 80 | # ReSharper is a .NET coding add-in 81 | _ReSharper* 82 | 83 | # Installshield output folder 84 | [Ee]xpress 85 | 86 | # DocProject is a documentation generator add-in 87 | DocProject/buildhelp/ 88 | DocProject/Help/*.HxT 89 | DocProject/Help/*.HxC 90 | DocProject/Help/*.hhc 91 | DocProject/Help/*.hhk 92 | DocProject/Help/*.hhp 93 | DocProject/Help/Html2 94 | DocProject/Help/html 95 | 96 | # Click-Once directory 97 | publish 98 | 99 | # Others 100 | [Bb]in 101 | [Oo]bj 102 | sql 103 | TestResults 104 | *.Cache 105 | ClientBin 106 | stylecop.* 107 | ~$* 108 | *.dbmdl 109 | Generated_Code #added for RIA/Silverlight projects 110 | 111 | # Backup & report files from converting an old project file to a newer 112 | # Visual Studio version. Backup files are not needed, because we have git ;-) 113 | _UpgradeReport_Files/ 114 | Backup*/ 115 | UpgradeLog*.XML 116 | 117 | 118 | 119 | ############ 120 | ## Windows 121 | ############ 122 | 123 | # Windows image file caches 124 | Thumbs.db 125 | 126 | # Folder config file 127 | Desktop.ini 128 | 129 | 130 | ############# 131 | ## Python 132 | ############# 133 | 134 | *.py[co] 135 | 136 | # Packages 137 | *.egg 138 | *.egg-info 139 | dist 140 | build 141 | eggs 142 | parts 143 | bin 144 | var 145 | sdist 146 | develop-eggs 147 | .installed.cfg 148 | 149 | # Installer logs 150 | pip-log.txt 151 | 152 | # Unit test / coverage reports 153 | .coverage 154 | .tox 155 | 156 | #Translations 157 | *.mo 158 | 159 | #Mr Developer 160 | .mr.developer.cfg 161 | 162 | # Mac crap 163 | .DS_Store 164 | -------------------------------------------------------------------------------- /apple-touch-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vinod8990/Phaser_Multiscreen_Example/6d5baaf1dc18b205c095b2d2a1df73870e490ce9/apple-touch-icon.png -------------------------------------------------------------------------------- /assets/large/bg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vinod8990/Phaser_Multiscreen_Example/6d5baaf1dc18b205c095b2d2a1df73870e490ce9/assets/large/bg.jpg -------------------------------------------------------------------------------- /assets/large/playBtn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vinod8990/Phaser_Multiscreen_Example/6d5baaf1dc18b205c095b2d2a1df73870e490ce9/assets/large/playBtn.png -------------------------------------------------------------------------------- /assets/normal/bg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vinod8990/Phaser_Multiscreen_Example/6d5baaf1dc18b205c095b2d2a1df73870e490ce9/assets/normal/bg.jpg -------------------------------------------------------------------------------- /assets/normal/playBtn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vinod8990/Phaser_Multiscreen_Example/6d5baaf1dc18b205c095b2d2a1df73870e490ce9/assets/normal/playBtn.png -------------------------------------------------------------------------------- /assets/small/bg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vinod8990/Phaser_Multiscreen_Example/6d5baaf1dc18b205c095b2d2a1df73870e490ce9/assets/small/bg.jpg -------------------------------------------------------------------------------- /assets/small/playBtn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vinod8990/Phaser_Multiscreen_Example/6d5baaf1dc18b205c095b2d2a1df73870e490ce9/assets/small/playBtn.png -------------------------------------------------------------------------------- /assets/xlarge/bg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vinod8990/Phaser_Multiscreen_Example/6d5baaf1dc18b205c095b2d2a1df73870e490ce9/assets/xlarge/bg.jpg -------------------------------------------------------------------------------- /assets/xlarge/playBtn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vinod8990/Phaser_Multiscreen_Example/6d5baaf1dc18b205c095b2d2a1df73870e490ce9/assets/xlarge/playBtn.png -------------------------------------------------------------------------------- /assets/xxlarge/bg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vinod8990/Phaser_Multiscreen_Example/6d5baaf1dc18b205c095b2d2a1df73870e490ce9/assets/xxlarge/bg.jpg -------------------------------------------------------------------------------- /assets/xxlarge/playBtn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vinod8990/Phaser_Multiscreen_Example/6d5baaf1dc18b205c095b2d2a1df73870e490ce9/assets/xxlarge/playBtn.png -------------------------------------------------------------------------------- /css/stylesheet.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0px 0px 1px 0px; /* the extra 1px allows the iOS inner/outer check to work */ 3 | background: #000; 4 | } 5 | 6 | #game{ 7 | position: relative; 8 | margin: 0; 9 | padding: 0; 10 | } 11 | 12 | #orientation { 13 | margin: 0 auto; 14 | position: absolute; 15 | top: 0; 16 | left: 0; 17 | width: 100%; 18 | height: 100%; 19 | background-image: url(../images/orientation.jpg); 20 | background-repeat: no-repeat; 21 | background-position: center; 22 | background-color: rgb(0, 0, 0); 23 | z-index: 999; 24 | display: none; 25 | } 26 | -------------------------------------------------------------------------------- /icons/app_icon_1024x1024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vinod8990/Phaser_Multiscreen_Example/6d5baaf1dc18b205c095b2d2a1df73870e490ce9/icons/app_icon_1024x1024.png -------------------------------------------------------------------------------- /icons/app_icon_114x114.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vinod8990/Phaser_Multiscreen_Example/6d5baaf1dc18b205c095b2d2a1df73870e490ce9/icons/app_icon_114x114.png -------------------------------------------------------------------------------- /icons/app_icon_120x120.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vinod8990/Phaser_Multiscreen_Example/6d5baaf1dc18b205c095b2d2a1df73870e490ce9/icons/app_icon_120x120.png -------------------------------------------------------------------------------- /icons/app_icon_144x144.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vinod8990/Phaser_Multiscreen_Example/6d5baaf1dc18b205c095b2d2a1df73870e490ce9/icons/app_icon_144x144.png -------------------------------------------------------------------------------- /icons/app_icon_152x152.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vinod8990/Phaser_Multiscreen_Example/6d5baaf1dc18b205c095b2d2a1df73870e490ce9/icons/app_icon_152x152.png -------------------------------------------------------------------------------- /icons/app_icon_256x256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vinod8990/Phaser_Multiscreen_Example/6d5baaf1dc18b205c095b2d2a1df73870e490ce9/icons/app_icon_256x256.png -------------------------------------------------------------------------------- /icons/app_icon_512x512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vinod8990/Phaser_Multiscreen_Example/6d5baaf1dc18b205c095b2d2a1df73870e490ce9/icons/app_icon_512x512.png -------------------------------------------------------------------------------- /icons/app_icon_57x57.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vinod8990/Phaser_Multiscreen_Example/6d5baaf1dc18b205c095b2d2a1df73870e490ce9/icons/app_icon_57x57.png -------------------------------------------------------------------------------- /icons/app_icon_60x60.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vinod8990/Phaser_Multiscreen_Example/6d5baaf1dc18b205c095b2d2a1df73870e490ce9/icons/app_icon_60x60.png -------------------------------------------------------------------------------- /icons/app_icon_72x72.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vinod8990/Phaser_Multiscreen_Example/6d5baaf1dc18b205c095b2d2a1df73870e490ce9/icons/app_icon_72x72.png -------------------------------------------------------------------------------- /icons/app_icon_76x76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vinod8990/Phaser_Multiscreen_Example/6d5baaf1dc18b205c095b2d2a1df73870e490ce9/icons/app_icon_76x76.png -------------------------------------------------------------------------------- /images/orientation.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vinod8990/Phaser_Multiscreen_Example/6d5baaf1dc18b205c095b2d2a1df73870e490ce9/images/orientation.jpg -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Phaser Full Screen Mobile Example 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 | 47 |
48 |
49 | 50 | 115 | 116 | 117 | -------------------------------------------------------------------------------- /src/game/scene/Boot.js: -------------------------------------------------------------------------------- 1 | BasicGame = { 2 | 3 | /* Here we've just got some global level vars that persist regardless of State swaps */ 4 | score: 0, 5 | 6 | /* If the music in your game needs to play through-out a few State swaps, then you could reference it here */ 7 | music: null, 8 | 9 | /* Your game can check BasicGame.orientated in internal loops to know if it should pause or not */ 10 | orientated: false 11 | 12 | }; 13 | 14 | 15 | BasicGame.Boot = function (game) { 16 | }; 17 | 18 | 19 | BasicGame.Boot.prototype = { 20 | 21 | preload: function () { 22 | 23 | // Here we load the assets required for our preloader (in this case a background and a loading bar) 24 | //this.load.image('preloaderBackground', 'images/preloader_background.jpg'); 25 | //this.load.image('preloaderBar', 'images/preloadr_bar.png'); 26 | 27 | }, 28 | 29 | create: function () { 30 | 31 | this.input.maxPointers = 1; 32 | this.stage.disableVisibilityChange = true; 33 | this.scaleStage(); 34 | this.state.start('Preloader'); 35 | 36 | }, 37 | 38 | scaleStage:function(){ 39 | if (this.game.device.desktop) 40 | { 41 | this.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL; 42 | } 43 | else 44 | { 45 | this.scale.scaleMode = Phaser.ScaleManager.NO_BORDER; 46 | this.scale.forceOrientation(true, false); 47 | this.scale.hasResized.add(this.gameResized, this); 48 | this.scale.enterIncorrectOrientation.add(this.enterIncorrectOrientation, this); 49 | this.scale.leaveIncorrectOrientation.add(this.leaveIncorrectOrientation, this); 50 | this.scale.setScreenSize(true); 51 | } 52 | 53 | this.scale.minWidth = BasicGame.gameWidth/2; 54 | this.scale.minHeight = BasicGame.gameHeight/2; 55 | this.scale.maxWidth = BasicGame.gameWidth; 56 | this.scale.maxHeight = BasicGame.gameHeight; 57 | this.scale.pageAlignHorizontally = true; 58 | this.scale.pageAlignVertically = true; 59 | this.scale.setScreenSize(true); 60 | 61 | if(this.scale.scaleMode==Phaser.ScaleManager.NO_BORDER){ 62 | BasicGame.viewX = (this.scale.width/2 - window.innerWidth/2)*this.scale.scaleFactor.x; 63 | BasicGame.viewY = (this.scale.height/2 - window.innerHeight/2 - 1)*this.scale.scaleFactor.y; 64 | BasicGame.viewWidth = BasicGame.gameWidth-BasicGame.viewX; 65 | BasicGame.viewHeight = BasicGame.gameHeight-BasicGame.viewY; 66 | }else{ 67 | BasicGame.viewX = 0; 68 | BasicGame.viewY = 0; 69 | BasicGame.viewWidth = BasicGame.gameWidth; 70 | BasicGame.viewHeight = BasicGame.gameHeight; 71 | } 72 | 73 | document.getElementById("game").style.width = window.innerWidth+"px"; 74 | 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 75 | document.getElementById("game").style.overflow = "hidden"; 76 | }, 77 | 78 | gameResized: function (width, height) { 79 | 80 | // This could be handy if you need to do any extra processing if the game resizes. 81 | // A resize could happen if for example swapping orientation on a device. 82 | 83 | }, 84 | 85 | enterIncorrectOrientation: function () { 86 | 87 | BasicGame.orientated = false; 88 | 89 | document.getElementById('orientation').style.display = 'block'; 90 | 91 | }, 92 | 93 | leaveIncorrectOrientation: function () { 94 | 95 | BasicGame.orientated = true; 96 | 97 | document.getElementById('orientation').style.display = 'none'; 98 | this.scaleStage(); 99 | } 100 | 101 | }; -------------------------------------------------------------------------------- /src/game/scene/Game.js: -------------------------------------------------------------------------------- 1 | 2 | BasicGame.Game = function (game) { 3 | 4 | // When a State is added to Phaser it automatically has the following properties set on it, even if they already exist: 5 | 6 | this.game; // a reference to the currently running game 7 | this.add; // used to add sprites, text, groups, etc 8 | this.camera; // a reference to the game camera 9 | this.cache; // the game cache 10 | this.input; // the global input manager (you can access this.input.keyboard, this.input.mouse, as well from it) 11 | this.load; // for preloading assets 12 | this.math; // lots of useful common math operations 13 | this.sound; // the sound manager - add a sound, play one, set-up markers, etc 14 | this.stage; // the game stage 15 | this.time; // the clock 16 | this.tweens; // the tween manager 17 | this.world; // the game world 18 | this.particles; // the particle manager 19 | this.physics; // the physics manager 20 | this.rnd; // the repeatable random number generator 21 | 22 | // You can use any of these from any function within this State. 23 | // But do consider them as being 'reserved words', i.e. don't create a property for your own game called "world" or you'll over-write the world reference. 24 | 25 | }; 26 | 27 | BasicGame.Game.prototype = { 28 | 29 | create: function () { 30 | 31 | // Honestly, just about anything could go here. It's YOUR game after all. Eat your heart out! 32 | 33 | }, 34 | 35 | update: function () { 36 | 37 | // Honestly, just about anything could go here. It's YOUR game after all. Eat your heart out! 38 | 39 | }, 40 | 41 | quitGame: function (pointer) { 42 | 43 | // Here you should destroy anything you no longer need. 44 | // Stop music, delete sprites, purge caches, free resources, all that good stuff. 45 | 46 | // Then let's go back to the main menu. 47 | this.state.start('MainMenu'); 48 | 49 | } 50 | 51 | }; 52 | -------------------------------------------------------------------------------- /src/game/scene/MainMenu.js: -------------------------------------------------------------------------------- 1 | 2 | BasicGame.MainMenu = function (game) { 3 | 4 | this.music = null; 5 | this.playButton = null; 6 | 7 | }; 8 | 9 | BasicGame.MainMenu.prototype = { 10 | 11 | create: function () { 12 | 13 | // We've already preloaded our assets, so let's kick right into the Main Menu itself. 14 | // Here all we're doing is playing some music and adding a picture and button 15 | // Naturally I expect you to do something significantly better :) 16 | this.add.sprite(0,0,'bg'); 17 | 18 | //Aligning HUD to view edges 19 | //Align to left top edge 20 | var q = this.add.sprite(BasicGame.viewX,BasicGame.viewY,'playBtn'); 21 | 22 | //Align to bottom right edge 23 | q.position.x = BasicGame.viewWidth - q.width; 24 | q.position.y = BasicGame.viewHeight - q.height; 25 | q.inputEnabled = true; 26 | q.events.onInputDown.add(this.onClick,this); 27 | }, 28 | 29 | onClick:function(){ 30 | console.log("CLICKED"+Math.random()); 31 | }, 32 | 33 | update: function () { 34 | 35 | // Do some nice funky main menu effect here 36 | }, 37 | 38 | startGame: function (pointer) { 39 | 40 | 41 | 42 | // And start the actual game 43 | this.state.start('Game'); 44 | 45 | } 46 | 47 | }; 48 | -------------------------------------------------------------------------------- /src/game/scene/Preloader.js: -------------------------------------------------------------------------------- 1 | 2 | BasicGame.Preloader = function (game) { 3 | 4 | this.background = null; 5 | this.preloadBar = null; 6 | 7 | this.ready = false; 8 | 9 | }; 10 | 11 | BasicGame.Preloader.prototype = { 12 | 13 | preload: function () { 14 | 15 | 16 | //this.background = this.add.sprite(0, 0, 'preloaderBackground'); 17 | //this.preloadBar = this.add.sprite(300, 400, 'preloaderBar'); 18 | 19 | 20 | //this.load.setPreloadSprite(this.preloadBar); 21 | 22 | this.load.image('bg','assets/'+BasicGame.screen+"/bg.jpg"); 23 | this.load.image('playBtn','assets/'+BasicGame.screen+"/playBtn.png"); 24 | }, 25 | 26 | create: function () { 27 | //this.preloadBar.cropEnabled = false; 28 | this.ready = true; 29 | this.state.start('MainMenu'); 30 | }, 31 | 32 | update: function () { 33 | 34 | if (this.cache.isSoundDecoded('titleMusic') && this.ready == false) 35 | { 36 | this.ready = true; 37 | this.state.start('MainMenu'); 38 | } 39 | 40 | } 41 | 42 | }; 43 | -------------------------------------------------------------------------------- /src/lib/ScaleManager2.js: -------------------------------------------------------------------------------- 1 | /**Injecting no border code for Phaser.ScaleManager*/ 2 | Phaser.ScaleManager.prototype.NO_BORDER = 3; 3 | Phaser.ScaleManager.prototype.setScreenSize = function (force) { 4 | if (typeof force == 'undefined') 5 | { 6 | force = false; 7 | } 8 | 9 | if (this.game.device.iPad === false && this.game.device.webApp === false && this.game.device.desktop === false) 10 | { 11 | if (this.game.device.android && this.game.device.chrome === false) 12 | { 13 | window.scrollTo(0, 1); 14 | } 15 | else 16 | { 17 | window.scrollTo(0, 0); 18 | } 19 | } 20 | 21 | this._iterations--; 22 | 23 | if (force || window.innerHeight > this._startHeight || this._iterations < 0) 24 | { 25 | // Set minimum height of content to new window height 26 | document.documentElement['style'].minHeight = window.innerHeight + 'px'; 27 | 28 | if (this.incorrectOrientation === true) 29 | { 30 | this.setMaximum(); 31 | } 32 | else if (!this.isFullScreen) 33 | { 34 | if (this.scaleMode == Phaser.ScaleManager.EXACT_FIT) 35 | { 36 | this.setExactFit(); 37 | } 38 | else if (this.scaleMode == Phaser.ScaleManager.SHOW_ALL) 39 | { 40 | this.setShowAll(); 41 | } 42 | else if(this.scaleMode == Phaser.ScaleManager.NO_BORDER) 43 | { 44 | this.setNoBorder();//Don't call setSize 45 | clearInterval(this._check); 46 | this._check = null; 47 | return; 48 | } 49 | } 50 | else 51 | { 52 | if (this.fullScreenScaleMode == Phaser.ScaleManager.EXACT_FIT) 53 | { 54 | this.setExactFit(); 55 | } 56 | else if (this.fullScreenScaleMode == Phaser.ScaleManager.SHOW_ALL) 57 | { 58 | this.setShowAll(); 59 | } 60 | else if(this.scaleMode == Phaser.ScaleManager.NO_BORDER) 61 | { 62 | this.setNoBorder();//Don't call setSize 63 | clearInterval(this._check); 64 | this._check = null; 65 | return; 66 | } 67 | } 68 | this.setSize(); 69 | clearInterval(this._check); 70 | this._check = null; 71 | } 72 | 73 | } 74 | Phaser.ScaleManager.prototype.setNoBorder = function(){ 75 | this.setShowAll(); 76 | var ow = parseInt(this.width,10); 77 | var oh = parseInt(this.height,10); 78 | var r = Math.max(window.innerWidth/ow,window.innerHeight/oh); 79 | this.width = ow*r; 80 | this.height = oh*r; 81 | this.setSize2(); 82 | } 83 | Phaser.ScaleManager.prototype.setSize2 = function(){ 84 | this.game.canvas.style.width = this.width + 'px'; 85 | this.game.canvas.style.height = this.height + 'px'; 86 | this.game.input.scale.setTo(this.game.width / this.width, this.game.height / this.height); 87 | if (this.pageAlignHorizontally) 88 | { 89 | if (this.incorrectOrientation === false) 90 | { 91 | this.margin.x = Math.round((window.innerWidth - this.width) / 2); 92 | this.game.canvas.style.marginLeft = this.margin.x + 'px'; 93 | } 94 | else 95 | { 96 | this.margin.x = 0; 97 | this.game.canvas.style.marginLeft = '0px'; 98 | } 99 | } 100 | 101 | if (this.pageAlignVertically) 102 | { 103 | if (this.incorrectOrientation === false) 104 | { 105 | this.margin.y = Math.round((window.innerHeight - this.height) / 2); 106 | this.game.canvas.style.marginTop = this.margin.y + 'px'; 107 | } 108 | else 109 | { 110 | this.margin.y = 0; 111 | this.game.canvas.style.marginTop = '0px'; 112 | } 113 | } 114 | 115 | Phaser.Canvas.getOffset(this.game.canvas, this.game.stage.offset); 116 | this.aspectRatio = this.width / this.height; 117 | this.scaleFactor.x = this.game.width / this.width; 118 | this.scaleFactor.y = this.game.height / this.height; 119 | this.scaleFactorInversed.x = this.width / this.game.width; 120 | this.scaleFactorInversed.y = this.height / this.game.height; 121 | this.hasResized.dispatch(this.width, this.height); 122 | this.checkOrientationState(); 123 | } --------------------------------------------------------------------------------