forked from phaserjs/phaser
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a new Full Screen Mobile template example.
- Loading branch information
1 parent
428e331
commit bd9b964
Showing
21 changed files
with
423 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
|
||
var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update, render: render }); | ||
|
||
function preload() { | ||
|
||
game.load.image('wizball', 'assets/sprites/wizball.png'); | ||
game.load.image('platform', 'assets/sprites/interference_tunnel.png'); | ||
|
||
} | ||
|
||
var ball; | ||
var circle; | ||
var platform; | ||
|
||
function create() { | ||
|
||
// Our ball sprite | ||
ball = game.add.sprite(420, 100, 'wizball'); | ||
ball.anchor.setTo(0.5, 0.5); | ||
|
||
ball.body.customSeparateX = true; | ||
ball.body.customSeparateY = true; | ||
|
||
ball.body.velocity.y = 150; | ||
ball.body.bounce.y = 0.9; | ||
|
||
// Our collision circle | ||
circle = new Phaser.Circle(200, 100, 188); | ||
|
||
// Our platform | ||
platform = game.add.sprite(200, 450, 'platform'); | ||
platform.body.immovable = true; | ||
|
||
} | ||
|
||
function update() { | ||
|
||
// ball.x = game.input.x; | ||
// ball.y = game.input.y; | ||
|
||
circle.x = ball.x; | ||
circle.y = ball.y; | ||
|
||
// This is a rect vs. rect collision. The callback will check the circle. | ||
game.physics.overlap(ball, platform, null, processCallback, this); | ||
|
||
} | ||
|
||
function processCallback(a, b) { | ||
|
||
// console.log('p', a.y, b.y); | ||
|
||
if (Phaser.Circle.intersectsRectangle(circle, platform.body)) | ||
{ | ||
console.log('boom', ball.body.overlapX, ball.body.overlapY); | ||
// ball.body.x = ball.body.x - ball.body.overlapX; | ||
// ball.body.velocity.x = platform.body.velocity.x - ball.body.velocity.x * ball.body.bounce.x; | ||
|
||
ball.body.y -= 10; | ||
ball.body.velocity.y *= -1 * ball.body.bounce.y; | ||
} | ||
|
||
return true; | ||
|
||
} | ||
|
||
function render() { | ||
|
||
game.debug.renderText(Phaser.Circle.intersectsRectangle(circle, platform.body), 32, 32); | ||
game.debug.renderText(ball.body.velocity.y, 32, 64); | ||
// game.debug.renderText(ball.body.overlapY, 64, 64); | ||
game.debug.renderCircle(circle); | ||
game.debug.renderRectangle(platform.body); | ||
|
||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions
19
resources/Project Templates/Full Screen Mobile/css/stylesheet.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
body { | ||
margin: 0px 0px 1px 0px; /* the extra 1px allows the iOS inner/outer check to work */ | ||
background: #000; | ||
} | ||
|
||
#orientation { | ||
margin: 0 auto; | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
width: 100%; | ||
height: 100%; | ||
background-image: url(../images/orientation.jpg); | ||
background-repeat: no-repeat; | ||
background-position: center; | ||
background-color: rgb(0, 0, 0); | ||
z-index: 999; | ||
display: none; | ||
} |
Binary file added
BIN
+72.5 KB
resources/Project Templates/Full Screen Mobile/icons/app_icon_1024x1024.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+4.31 KB
resources/Project Templates/Full Screen Mobile/icons/app_icon_114x114.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+4.57 KB
resources/Project Templates/Full Screen Mobile/icons/app_icon_120x120.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+5.79 KB
resources/Project Templates/Full Screen Mobile/icons/app_icon_144x144.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+6.29 KB
resources/Project Templates/Full Screen Mobile/icons/app_icon_152x152.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+12.6 KB
resources/Project Templates/Full Screen Mobile/icons/app_icon_256x256.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+30 KB
resources/Project Templates/Full Screen Mobile/icons/app_icon_512x512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.63 KB
resources/Project Templates/Full Screen Mobile/icons/app_icon_57x57.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.79 KB
resources/Project Templates/Full Screen Mobile/icons/app_icon_60x60.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.27 KB
resources/Project Templates/Full Screen Mobile/icons/app_icon_72x72.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.44 KB
resources/Project Templates/Full Screen Mobile/icons/app_icon_76x76.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+7.57 KB
resources/Project Templates/Full Screen Mobile/images/orientation.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<!DOCTYPE HTML> | ||
<html> | ||
<head> | ||
<title>Phaser Full Screen Mobile Example</title> | ||
<meta charset="utf-8"> | ||
<meta http-equiv="X-UA-Compatible" content="chrome=1, IE=9"> | ||
<meta name="format-detection" content="telephone=no"> | ||
<meta name="HandheldFriendly" content="true" /> | ||
<meta name="apple-mobile-web-app-capable" content="yes"> | ||
<meta name="apple-mobile-web-app-status-bar-style" content="black"> | ||
<meta name="format-detection" content="telephone=no"> | ||
<meta name="HandheldFriendly" content="true" /> | ||
<meta name="robots" content="noindex,nofollow" /> | ||
<meta name="apple-mobile-web-app-capable" content="yes" /> | ||
<meta name="apple-mobile-web-app-status-bar-style" content="black" /> | ||
<meta name="apple-mobile-web-app-title" content="Phaser App"> | ||
<meta name="viewport" content="initial-scale=1 maximum-scale=1 user-scalable=0 minimal-ui" /> | ||
<link rel="apple-touch-icon" href="/apple-touch-icon.png"> | ||
<link rel="apple-touch-icon" sizes="57x57" href="icons/app_icon_57x57.png"> | ||
<link rel="apple-touch-icon" sizes="60x60" href="icons/app_icon_60x60.png"> | ||
<link rel="apple-touch-icon" sizes="72x72" href="icons/app_icon_72x72.png"> | ||
<link rel="apple-touch-icon" sizes="76x76" href="icons/app_icon_76x76.png"> | ||
<link rel="apple-touch-icon" sizes="114x114" href="icons/app_icon_114x114.png"> | ||
<link rel="apple-touch-icon" sizes="120x120" href="icons/app_icon_120x120.png"> | ||
<link rel="apple-touch-icon" sizes="144x144" href="icons/app_icon_144x144.png"> | ||
<link rel="apple-touch-icon" sizes="152x152" href="icons/app_icon_152x152.png"> | ||
<link rel="apple-touch-icon" sizes="256x256" href="icons/app_icon_256x256.png"> | ||
<link rel="apple-touch-icon" sizes="512x512" href="icons/app_icon_512x512.png"> | ||
<link rel="apple-touch-icon" sizes="1024x1024" href="icons/app_icon_1024x1024.png"> | ||
<link rel="stylesheet" href="css/stylesheet.css" type="text/css" charset="utf-8" /> | ||
<script src="js/phaser.min.js"></script> | ||
<script src="src/Boot.js"></script> | ||
<script src="src/Preloader.js"></script> | ||
<script src="src/MainMenu.js"></script> | ||
<script src="src/Game.js"></script> | ||
</head> | ||
<body> | ||
|
||
<div id="game"></div> | ||
<div id="orientation"></div> | ||
|
||
<script type="text/javascript"> | ||
|
||
(function () { | ||
|
||
// Create your Phaser game and inject it into the game div. | ||
// We did it in a window.onload event, but you can do it anywhere (requireJS load, anonymous function, jQuery dom ready, - whatever floats your boat) | ||
// We're using a game size of 1024 x 768 here, but you can use whatever you feel makes sense for your game of course. | ||
var game = new Phaser.Game(1024, 768, Phaser.AUTO, 'game'); | ||
|
||
// Add the States your game has. | ||
// You don't have to do this in the html, it could be done in your Boot state too, but for simplicity I'll keep it here. | ||
game.state.add('Boot', BasicGame.Boot); | ||
game.state.add('Preloader', BasicGame.Preloader); | ||
game.state.add('MainMenu', BasicGame.MainMenu); | ||
game.state.add('Game', BasicGame.Game); | ||
|
||
// Now start the Boot state. | ||
game.state.start('Boot'); | ||
|
||
})(); | ||
</script> | ||
|
||
</body> | ||
</html> |
86 changes: 86 additions & 0 deletions
86
resources/Project Templates/Full Screen Mobile/src/Boot.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
BasicGame = { | ||
|
||
/* Here we've just got some global level vars that persist regardless of State swaps */ | ||
score: 0, | ||
|
||
/* If the music in your game needs to play through-out a few State swaps, then you could reference it here */ | ||
music: null, | ||
|
||
/* Your game can check BasicGame.orientated in internal loops to know if it should pause or not */ | ||
orientated: false | ||
|
||
}; | ||
|
||
BasicGame.Boot = function (game) { | ||
}; | ||
|
||
BasicGame.Boot.prototype = { | ||
|
||
preload: function () { | ||
|
||
// Here we load the assets required for our preloader (in this case a background and a loading bar) | ||
this.load.image('preloaderBackground', 'images/preloader_background.jpg'); | ||
this.load.image('preloaderBar', 'images/preloadr_bar.png'); | ||
|
||
}, | ||
|
||
create: function () { | ||
|
||
this.game.input.maxPointers = 1; | ||
this.game.stage.disableVisibilityChange = true; | ||
|
||
if (this.game.device.desktop) | ||
{ | ||
this.game.stage.scaleMode = Phaser.StageScaleMode.SHOW_ALL; | ||
this.game.stage.scale.minWidth = 480; | ||
this.game.stage.scale.minHeight = 260; | ||
this.game.stage.scale.maxWidth = 1024; | ||
this.game.stage.scale.maxHeight = 768; | ||
this.game.stage.scale.pageAlignHorizontally = true; | ||
this.game.stage.scale.pageAlignVertically = true; | ||
this.game.stage.scale.setScreenSize(true); | ||
} | ||
else | ||
{ | ||
this.game.stage.scaleMode = Phaser.StageScaleMode.SHOW_ALL; | ||
this.game.stage.scale.minWidth = 480; | ||
this.game.stage.scale.minHeight = 260; | ||
this.game.stage.scale.maxWidth = 1024; | ||
this.game.stage.scale.maxHeight = 768; | ||
this.game.stage.scale.pageAlignHorizontally = true; | ||
this.game.stage.scale.pageAlignVertically = true; | ||
this.game.stage.scale.forceOrientation(true, false); | ||
this.game.stage.scale.hasResized.add(this.gameResized, this); | ||
this.game.stage.scale.enterIncorrectOrientation.add(this.enterIncorrectOrientation, this); | ||
this.game.stage.scale.leaveIncorrectOrientation.add(this.leaveIncorrectOrientation, this); | ||
this.game.stage.scale.setScreenSize(true); | ||
} | ||
|
||
this.game.state.start('Preloader'); | ||
|
||
}, | ||
|
||
gameResized: function (width, height) { | ||
|
||
// This could be handy if you need to do any extra processing if the game resizes. | ||
// A resize could happen if for example swapping orientation on a device. | ||
|
||
}, | ||
|
||
enterIncorrectOrientation: function () { | ||
|
||
BasicGame.orientated = false; | ||
|
||
document.getElementById('orientation').style.display = 'block'; | ||
|
||
}, | ||
|
||
leaveIncorrectOrientation: function () { | ||
|
||
BasicGame.orientated = true; | ||
|
||
document.getElementById('orientation').style.display = 'none'; | ||
|
||
} | ||
|
||
}; |
51 changes: 51 additions & 0 deletions
51
resources/Project Templates/Full Screen Mobile/src/Game.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
|
||
BasicGame.Game = function (game) { | ||
|
||
// When a State is added to Phaser it automatically has the following properties set on it, even if they already exist: | ||
|
||
this.game; // a reference to the currently running game | ||
this.add; // used to add sprites, text, groups, etc | ||
this.camera; // a reference to the game camera | ||
this.cache; // the game cache | ||
this.input; // the global input manager (you can access this.input.keyboard, this.input.mouse, as well from it) | ||
this.load; // for preloading assets | ||
this.math; // lots of useful common math operations | ||
this.sound; // the sound manager - add a sound, play one, set-up markers, etc | ||
this.stage; // the game stage | ||
this.time; // the clock | ||
this.tweens; // the tween manager | ||
this.world; // the game world | ||
this.particles; // the particle manager | ||
this.physics; // the physics manager | ||
this.rnd; // the repeatable random number generator | ||
|
||
// You can use any of these from any function within this State. | ||
// 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. | ||
|
||
}; | ||
|
||
BasicGame.Game.prototype = { | ||
|
||
create: function () { | ||
|
||
// Honestly, just about anything could go here. It's YOUR game after all. Eat your heart out! | ||
|
||
}, | ||
|
||
update: function () { | ||
|
||
// Honestly, just about anything could go here. It's YOUR game after all. Eat your heart out! | ||
|
||
}, | ||
|
||
quitGame: function (pointer) { | ||
|
||
// Here you should destroy anything you no longer need. | ||
// Stop music, delete sprites, purge caches, free resources, all that good stuff. | ||
|
||
// Then let's go back to the main menu. | ||
this.game.state.start('MainMenu'); | ||
|
||
} | ||
|
||
}; |
Oops, something went wrong.