Skip to content

refactor into states, resize canvas, rename state js files #151

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jun 19, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<html>
<head>
<!-- Phaser -->
<script src="/components/com_battle/views/phaser/tmpl/_site/js/phaser.js"></script>
<script src="/components/com_battle/views/phaser/tmpl/_site/js/jquery-2.0.3.min.js"></script>
<!-- Phaser -->
<script src="/components/com_battle/includes/phaser.js"></script>
<style>
body {
margin: 0;
Expand Down Expand Up @@ -42,17 +43,18 @@
<body>

<a href="http://eclecticmeme.com/index.php?option=com_content&view=article&id=4:chapter-two&catid=9:2007&Itemid=348" title="The Chronicles">
<div id="world">
</div>
<div id="world">
</div>
</a>

<div class="toolbar">
<a class="pyramidCity"></a>
<a class="chronicles"></a>
</div>

<script src='http://eclecticmeme.com/components/com_battle/views/plate/tmpl/019_wolfman_vampire/script.js'></script>

<script src='state001.js'></script>
<script src='script.js'></script>

<script>
$(document).ready(function() {
$( ".pyramidCity" ).click(function() {
Expand All @@ -66,4 +68,3 @@
</body>
</html>


Original file line number Diff line number Diff line change
@@ -1,23 +1,11 @@
var game = new Phaser.Game(640, 480, Phaser.CANVAS, 'world', { preload: preload, create: create });
// we create the global game object, an instance of Phaser.Game

function preload () {
var game = new Phaser.Game(800, 500, Phaser.AUTO, 'world');

// You can fill the preloader with as many assets as your game requires
// the first parameter is the key you use to jump between stated
// the key must be unique within the state manager
// the second parameter is the object that contains the state code
// these come from the js files we included in the head tag in the html file
game.state.add('State001', wolfman_vampire.State001);

// Here we are loading an image. The first parameter is the unique
// string by which we'll identify the image later in our code.

// The second parameter is the URL of the image (relative)
game.load.image('plate', '019_wolfman_vampire.jpg');

}

function create() {

// This creates a simple sprite that is using our loaded image and
// displays it on-screen and assign it to a variable
var image = game.add.sprite(game.world.centerX, game.world.centerY, 'plate');

// Moves the image anchor to the middle, so it centers inside the game properly
image.anchor.set(0.5);
}
game.state.start('State001');
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// defining a single global object (wolfman_vampire) and adding some functions in to its prototype (eg preload, create functions)

var wolfman_vampire = {};


wolfman_vampire.State001 = function (game) {


};

wolfman_vampire.State001.prototype = {

preload: function () {

// You can fill the preloader with as many assets as your game requires

// Here we are loading an image. The first parameter is the unique
// string by which we'll identify the image later in our code.

// The second parameter is the URL of the image (relative)
this.load.image('plate', '019_wolfman_vampire.jpg');

},
create: function () {

// This creates a simple sprite that is using our loaded image and
// displays it on-screen and assign it to a variable
var image = this.add.sprite(game.world.centerX, game.world.centerY, 'plate');

// Moves the image anchor to the middle, so it centers inside the game properly
image.anchor.set(0.5);

}
}
Original file line number Diff line number Diff line change
@@ -1,24 +1,19 @@
<html>
<head>

<!-- Phaser -->
<script src="/components/com_battle/views/phaser/tmpl/_site/js/phaser.js"></script>

<style>
body {
margin: 0;
}
</style>
</head>

<body>

<div id="world">
</div>

<script src='/components/com_battle/views/plate/tmpl/021_highjacking_hotspot/script.js'></script>

</body>
<head>
<!-- Phaser -->
<script src="/components/com_battle/includes/phaser.js"></script>
<style>
body {
margin: 0;
}
</style>
</head>
<body>
<div id="world">
</div>
<script src='state001.js'></script>
<script src='script.js'></script>
</body>
</html>


Original file line number Diff line number Diff line change
@@ -1,23 +1,11 @@
var game = new Phaser.Game(640, 480, Phaser.CANVAS, 'world', { preload: preload, create: create });
// we create the global game object, an instance of Phaser.Game

function preload () {
var game = new Phaser.Game(800, 500, Phaser.AUTO, 'world');

// You can fill the preloader with as many assets as your game requires
// the first parameter is the key you use to jump between stated
// the key must be unique within the state manager
// the second parameter is the object that contains the state code
// these come from the js files we included in the head tag in the html file
game.state.add('State001', highjacking_hotspot.State001);

// Here we are loading an image. The first parameter is the unique
// string by which we'll identify the image later in our code.

// The second parameter is the URL of the image (relative)
game.load.image('plate', 'highjacking_hotspot.jpg');

}

function create() {

// This creates a simple sprite that is using our loaded image and
// displays it on-screen and assign it to a variable
var image = game.add.sprite(game.world.centerX, game.world.centerY, 'plate');

// Moves the image anchor to the middle, so it centers inside the game properly
image.anchor.set(0.5);
}
game.state.start('State001');
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// defining a single global object (highjacking_hotspot) and adding some functions in to its prototype (eg preload, create functions)

var highjacking_hotspot = {};


highjacking_hotspot.State001 = function (game) {


};

highjacking_hotspot.State001.prototype = {

preload: function () {

// You can fill the preloader with as many assets as your game requires

// Here we are loading an image. The first parameter is the unique
// string by which we'll identify the image later in our code.

// The second parameter is the URL of the image (relative)
this.load.image('plate', 'highjacking_hotspot.jpg');

},
create: function () {

// This creates a simple sprite that is using our loaded image and
// displays it on-screen and assign it to a variable
var image = this.add.sprite(game.world.centerX, game.world.centerY, 'plate');

// Moves the image anchor to the middle, so it centers inside the game properly
image.anchor.set(0.5);

}
}
37 changes: 17 additions & 20 deletions components/com_battle/views/plate/tmpl/022_dangerzone/default.php
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
<html>
<head>

<!-- Phaser -->
<script src="/components/com_battle/views/phaser/tmpl/_site/js/phaser.js"></script>

<style>
body {
margin: 0;
}
</style>
</head>

<body>

<div id="world">
</div>

<script src='/components/com_battle/views/plate/tmpl/022_dangerzone/script.js'></script>

</body>
<head>
<!-- Phaser -->
<script src="/components/com_battle/includes/phaser.js"></script>
<style>
body {
margin: 0;
}
</style>
</head>
<body>
<div id="world">
</div>
<script src='state001.js'></script>
<script src='script.js'></script>
</body>
</html>




28 changes: 8 additions & 20 deletions components/com_battle/views/plate/tmpl/022_dangerzone/script.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,11 @@
var game = new Phaser.Game(640, 480, Phaser.CANVAS, 'world', { preload: preload, create: create });
// we create the global game object, an instance of Phaser.Game

function preload () {
var game = new Phaser.Game(800, 500, Phaser.AUTO, 'world');

// You can fill the preloader with as many assets as your game requires
// the first parameter is the key you use to jump between stated
// the key must be unique within the state manager
// the second parameter is the object that contains the state code
// these come from the js files we included in the head tag in the html file
game.state.add('State001', dangerzone.State001);

// Here we are loading an image. The first parameter is the unique
// string by which we'll identify the image later in our code.

// The second parameter is the URL of the image (relative)
game.load.image('plate', 'cyberpunk_plate.jpg');

}

function create() {

// This creates a simple sprite that is using our loaded image and
// displays it on-screen and assign it to a variable
var image = game.add.sprite(game.world.centerX, game.world.centerY, 'plate');

// Moves the image anchor to the middle, so it centers inside the game properly
image.anchor.set(0.5);
}
game.state.start('State001');
34 changes: 34 additions & 0 deletions components/com_battle/views/plate/tmpl/022_dangerzone/state001.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// defining a single global object (dangerzone) and adding some functions in to its prototype (eg preload, create functions)

var dangerzone = {};


dangerzone.State001 = function (game) {


};

dangerzone.State001.prototype = {

preload: function () {

// You can fill the preloader with as many assets as your game requires

// Here we are loading an image. The first parameter is the unique
// string by which we'll identify the image later in our code.

// The second parameter is the URL of the image (relative)
this.load.image('plate', 'cyberpunk_plate.jpg');

},
create: function () {

// This creates a simple sprite that is using our loaded image and
// displays it on-screen and assign it to a variable
var image = this.add.sprite(game.world.centerX, game.world.centerY, 'plate');

// Moves the image anchor to the middle, so it centers inside the game properly
image.anchor.set(0.5);

}
}
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
<html>
<head>

<!-- Phaser -->
<script src="/components/com_battle/views/phaser/tmpl/_site/js/phaser.js"></script>

<style>
body {
margin: 0;
}
</style>
</head>

<body>

<div id="world">
</div>

<script src='/components/com_battle/views/plate/tmpl/023_american_dream/script.js'></script>

</body>
<head>
<!-- Phaser -->
<script src="/components/com_battle/includes/phaser.js"></script>
<style>
body {
margin: 0;
}
</style>
</head>
<body>
<div id="world">
</div>
<script src='state001.js'></script>
<script src='script.js'></script>
</body>
</html>



Loading