Skip to content

Commit ff07317

Browse files
committed
First version of the FlexLayer class.
1 parent 4903e47 commit ff07317

3 files changed

Lines changed: 64 additions & 0 deletions

File tree

build/config.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@
9292
<script src="$path/src/core/World.js"></script>
9393
<script src="$path/src/core/Game.js"></script>
9494
<script src="$path/src/core/FlexGrid.js"></script>
95+
<script src="$path/src/core/FlexLayer.js"></script>
9596
<script src="$path/src/core/ScaleManager.js"></script>
9697
9798
<script src="$path/src/input/Input.js"></script>

src/core/FlexLayer.js

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/**
2+
* @author Richard Davey <rich@photonstorm.com>
3+
* @copyright 2014 Photon Storm Ltd.
4+
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
5+
*/
6+
7+
/**
8+
* A responsive grid layer.
9+
*
10+
* @class Phaser.FlexLayer
11+
* @extends Phaser.Group
12+
* @constructor
13+
* @param {Phaser.ScaleManager} manager - The ScaleManager.
14+
*/
15+
Phaser.FlexLayer = function (manager, position, bounds, scale) {
16+
17+
Phaser.Group.call(this, manager.game, null, '__flexLayer' + manager.game.rnd.uuid(), false);
18+
19+
/**
20+
* @property {Phaser.ScaleManager} scale - A reference to the ScaleManager.
21+
*/
22+
this.manager = manager;
23+
24+
/**
25+
* @property {Phaser.FlexGrid} grid - A reference to the FlexGrid that owns this layer.
26+
*/
27+
this.grid = manager.grid;
28+
29+
// Bound to the grid
30+
this.position = position;
31+
this.bounds = bounds;
32+
this.scale = scale;
33+
34+
this.topLeft = bounds.topLeft;
35+
this.topMiddle = new Phaser.Point(bounds.halfWidth, 0);
36+
this.topRight = bounds.topRight;
37+
38+
this.bottomLeft = bounds.bottomLeft;
39+
this.bottomMiddle = new Phaser.Point(bounds.halfWidth, bounds.bottom);
40+
this.bottomRight = bounds.bottomRight;
41+
42+
};
43+
44+
Phaser.FlexLayer.prototype = Object.create(Phaser.Group.prototype);
45+
Phaser.FlexLayer.prototype.constructor = Phaser.FlexLayer;
46+
47+
Phaser.FlexLayer.prototype.resize = function () {
48+
49+
};
50+
51+
Phaser.FlexLayer.prototype.debug = function () {
52+
53+
this.game.debug.text(this.bounds.width + ' x ' + this.bounds.height, this.bounds.x + 4, this.bounds.y + 16);
54+
this.game.debug.geom(this.bounds, 'rgba(0,0,255,0.9', false);
55+
56+
this.game.debug.geom(this.topLeft, 'rgba(255,255,255,0.9');
57+
this.game.debug.geom(this.topMiddle, 'rgba(255,255,255,0.9');
58+
this.game.debug.geom(this.topRight, 'rgba(255,255,255,0.9');
59+
60+
61+
};
62+

tasks/manifests/phaser.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"src/core/Group.js",
2525
"src/core/World.js",
2626
"src/core/FlexGrid.js",
27+
"src/core/FlexLayer.js",
2728
"src/core/ScaleManager.js",
2829
"src/core/Game.js",
2930

0 commit comments

Comments
 (0)