mirror of
https://github.com/photonstorm/phaser
synced 2024-12-01 00:49:41 +00:00
Fixed the FixedToCamera :)
This commit is contained in:
parent
c4b83a1394
commit
83adc51698
7 changed files with 40 additions and 7 deletions
|
@ -10,7 +10,7 @@
|
||||||
*/
|
*/
|
||||||
var Phaser = Phaser || {
|
var Phaser = Phaser || {
|
||||||
|
|
||||||
VERSION: '2.3.0-RC1',
|
VERSION: '2.3.0-RC2',
|
||||||
GAMES: [],
|
GAMES: [],
|
||||||
|
|
||||||
AUTO: 0,
|
AUTO: 0,
|
||||||
|
|
|
@ -81,6 +81,11 @@ Phaser.Component.Core.init = function (game, x, y, key, frame) {
|
||||||
this.loadTexture(key, frame);
|
this.loadTexture(key, frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.components.FixedToCamera)
|
||||||
|
{
|
||||||
|
this.cameraOffset = new Phaser.Point(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Phaser.Component.Core.preUpdate = function () {
|
Phaser.Component.Core.preUpdate = function () {
|
||||||
|
|
|
@ -30,6 +30,12 @@ Phaser.Component.FixedToCamera.postUpdate = function () {
|
||||||
|
|
||||||
Phaser.Component.FixedToCamera.prototype = {
|
Phaser.Component.FixedToCamera.prototype = {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @property {boolean} _fixedToCamera
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
_fixedToCamera: false,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Game Object that is "fixed" to the camera uses its x/y coordinates as offsets from the top left of the camera during rendering.
|
* A Game Object that is "fixed" to the camera uses its x/y coordinates as offsets from the top left of the camera during rendering.
|
||||||
*
|
*
|
||||||
|
@ -47,7 +53,29 @@ Phaser.Component.FixedToCamera.prototype = {
|
||||||
*
|
*
|
||||||
* @property {boolean} fixedToCamera
|
* @property {boolean} fixedToCamera
|
||||||
*/
|
*/
|
||||||
fixedToCamera: false,
|
fixedToCamera: {
|
||||||
|
|
||||||
|
get: function () {
|
||||||
|
|
||||||
|
return this._fixedToCamera;
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
set: function (value) {
|
||||||
|
|
||||||
|
if (value)
|
||||||
|
{
|
||||||
|
this._fixedToCamera = true;
|
||||||
|
this.cameraOffset.set(this.x, this.y);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this._fixedToCamera = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The x/y coordinate offset applied to the top-left of the camera that this Game Object will be drawn at if `fixedToCamera` is true.
|
* The x/y coordinate offset applied to the top-left of the camera that this Game Object will be drawn at if `fixedToCamera` is true.
|
||||||
|
|
|
@ -113,7 +113,7 @@ Phaser.Component.InWorld.prototype = {
|
||||||
*/
|
*/
|
||||||
inWorld: {
|
inWorld: {
|
||||||
|
|
||||||
get: function() {
|
get: function () {
|
||||||
|
|
||||||
return this.game.world.bounds.intersects(this.getBounds());
|
return this.game.world.bounds.intersects(this.getBounds());
|
||||||
|
|
||||||
|
|
|
@ -75,7 +75,7 @@ Phaser.Component.LifeSpan.prototype = {
|
||||||
* @param {number} [health=1] - The health to give the Game Object. Only set if the GameObject has the Health component.
|
* @param {number} [health=1] - The health to give the Game Object. Only set if the GameObject has the Health component.
|
||||||
* @return {PIXI.DisplayObject} This instance.
|
* @return {PIXI.DisplayObject} This instance.
|
||||||
*/
|
*/
|
||||||
revive: function(health) {
|
revive: function (health) {
|
||||||
|
|
||||||
if (typeof health === 'undefined') { health = 1; }
|
if (typeof health === 'undefined') { health = 1; }
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ Phaser.Component.LifeSpan.prototype = {
|
||||||
* @method
|
* @method
|
||||||
* @return {PIXI.DisplayObject} This instance.
|
* @return {PIXI.DisplayObject} This instance.
|
||||||
*/
|
*/
|
||||||
kill: function() {
|
kill: function () {
|
||||||
|
|
||||||
this.alive = false;
|
this.alive = false;
|
||||||
this.exists = false;
|
this.exists = false;
|
||||||
|
|
|
@ -171,7 +171,7 @@ Phaser.Component.LoadTexture.prototype = {
|
||||||
*
|
*
|
||||||
* @method
|
* @method
|
||||||
*/
|
*/
|
||||||
resetFrame: function() {
|
resetFrame: function () {
|
||||||
|
|
||||||
if (this._frame)
|
if (this._frame)
|
||||||
{
|
{
|
||||||
|
|
|
@ -27,7 +27,7 @@ Phaser.Component.Reset = function () {};
|
||||||
* @param {number} [health=1] - The health to give the Game Object if it has the Health component.
|
* @param {number} [health=1] - The health to give the Game Object if it has the Health component.
|
||||||
* @return {PIXI.DisplayObject} This instance.
|
* @return {PIXI.DisplayObject} This instance.
|
||||||
*/
|
*/
|
||||||
Phaser.Component.Reset.prototype.reset = function(x, y, health) {
|
Phaser.Component.Reset.prototype.reset = function (x, y, health) {
|
||||||
|
|
||||||
if (typeof health === 'undefined') { health = 1; }
|
if (typeof health === 'undefined') { health = 1; }
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue