phaser/wip/core/FlexLayer.js

116 lines
3 KiB
JavaScript
Raw Normal View History

2014-09-05 14:46:10 +00:00
/**
* @author Richard Davey <rich@photonstorm.com>
2016-04-04 21:15:01 +00:00
* @copyright 2016 Photon Storm Ltd.
2014-09-05 14:46:10 +00:00
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
2014-09-09 11:47:39 +00:00
* WARNING: This is an EXPERIMENTAL class. The API will change significantly in the coming versions and is incomplete.
* Please try to avoid using in production games with a long time to build.
* This is also why the documentation is incomplete.
*
2014-09-05 14:46:10 +00:00
* A responsive grid layer.
*
* @class Phaser.FlexLayer
* @extends Phaser.Group
* @constructor
2014-11-25 00:20:41 +00:00
* @param {Phaser.FlexGrid} manager - The FlexGrid that owns this FlexLayer.
2014-09-09 11:47:39 +00:00
* @param {Phaser.Point} position - A reference to the Point object used for positioning.
* @param {Phaser.Rectangle} bounds - A reference to the Rectangle used for the layer bounds.
* @param {Phaser.Point} scale - A reference to the Point object used for layer scaling.
2014-09-05 14:46:10 +00:00
*/
Phaser.FlexLayer = function (manager, position, bounds, scale) {
Phaser.Group.call(this, manager.game, null, '__flexLayer' + manager.game.rnd.uuid(), false);
/**
* @property {Phaser.ScaleManager} scale - A reference to the ScaleManager.
*/
this.manager = manager.manager;
2014-09-05 14:46:10 +00:00
/**
* @property {Phaser.FlexGrid} grid - A reference to the FlexGrid that owns this layer.
*/
this.grid = manager;
/**
* Should the FlexLayer remain through a State swap?
*
* @type {boolean}
*/
this.persist = false;
2014-09-05 14:46:10 +00:00
2014-11-25 00:20:41 +00:00
/**
* @property {Phaser.Point} position
*/
2014-09-05 14:46:10 +00:00
this.position = position;
2014-11-25 00:20:41 +00:00
/**
* @property {Phaser.Rectangle} bounds
*/
2014-09-05 14:46:10 +00:00
this.bounds = bounds;
2014-11-25 00:20:41 +00:00
/**
* @property {Phaser.Point} scale
*/
2014-09-05 14:46:10 +00:00
this.scale = scale;
2014-11-25 00:20:41 +00:00
/**
* @property {Phaser.Point} topLeft
*/
2014-09-05 14:46:10 +00:00
this.topLeft = bounds.topLeft;
2014-11-25 00:20:41 +00:00
/**
* @property {Phaser.Point} topMiddle
*/
2014-09-05 14:46:10 +00:00
this.topMiddle = new Phaser.Point(bounds.halfWidth, 0);
2014-11-25 00:20:41 +00:00
/**
* @property {Phaser.Point} topRight
*/
2014-09-05 14:46:10 +00:00
this.topRight = bounds.topRight;
2014-11-25 00:20:41 +00:00
/**
* @property {Phaser.Point} bottomLeft
*/
2014-09-05 14:46:10 +00:00
this.bottomLeft = bounds.bottomLeft;
2014-11-25 00:20:41 +00:00
/**
* @property {Phaser.Point} bottomMiddle
*/
2014-09-05 14:46:10 +00:00
this.bottomMiddle = new Phaser.Point(bounds.halfWidth, bounds.bottom);
2014-11-25 00:20:41 +00:00
/**
* @property {Phaser.Point} bottomRight
*/
2014-09-05 14:46:10 +00:00
this.bottomRight = bounds.bottomRight;
};
Phaser.FlexLayer.prototype = Object.create(Phaser.Group.prototype);
Phaser.FlexLayer.prototype.constructor = Phaser.FlexLayer;
2014-11-25 00:20:41 +00:00
/**
* Resize.
*
* @method Phaser.FlexLayer#resize
*/
2014-09-05 14:46:10 +00:00
Phaser.FlexLayer.prototype.resize = function () {
};
2014-11-25 00:20:41 +00:00
/**
* Debug.
*
* @method Phaser.FlexLayer#debug
*/
2014-09-05 14:46:10 +00:00
Phaser.FlexLayer.prototype.debug = function () {
this.game.debug.text(this.bounds.width + ' x ' + this.bounds.height, this.bounds.x + 4, this.bounds.y + 16);
this.game.debug.geom(this.bounds, 'rgba(0,0,255,0.9', false);
this.game.debug.geom(this.topLeft, 'rgba(255,255,255,0.9');
this.game.debug.geom(this.topMiddle, 'rgba(255,255,255,0.9');
this.game.debug.geom(this.topRight, 'rgba(255,255,255,0.9');
};