mirror of
https://github.com/wassname/phaser.git
synced 2026-08-03 13:10:25 +08:00
Testing some new Camera tricks.
This commit is contained in:
+2
-1
@@ -29,7 +29,8 @@ PIXI.CanvasRenderer.prototype.renderDisplayObject = function(displayObject)
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!displayObject.renderable || displayObject.alpha == 0)
|
||||
// if(!displayObject.renderable || displayObject.alpha == 0)
|
||||
if(!displayObject.renderable)
|
||||
{
|
||||
displayObject = displayObject._iNext;
|
||||
continue;
|
||||
|
||||
@@ -78,6 +78,8 @@ Phaser.Camera = function (game, id, x, y, width, height) {
|
||||
* @default
|
||||
*/
|
||||
this._edge = 0;
|
||||
|
||||
this.displayObject = null;
|
||||
|
||||
};
|
||||
|
||||
@@ -166,6 +168,8 @@ Phaser.Camera.prototype = {
|
||||
*/
|
||||
update: function () {
|
||||
|
||||
return;
|
||||
|
||||
// Add dirty flag
|
||||
|
||||
if (this.target !== null)
|
||||
@@ -216,6 +220,8 @@ Phaser.Camera.prototype = {
|
||||
*/
|
||||
checkWorldBounds: function () {
|
||||
|
||||
return;
|
||||
|
||||
this.atLimit.x = false;
|
||||
this.atLimit.y = false;
|
||||
|
||||
@@ -293,6 +299,7 @@ Object.defineProperty(Phaser.Camera.prototype, "x", {
|
||||
|
||||
set: function (value) {
|
||||
this.view.x = value;
|
||||
this.displayObject.x = -value;
|
||||
this.checkWorldBounds();
|
||||
}
|
||||
|
||||
@@ -311,6 +318,7 @@ Object.defineProperty(Phaser.Camera.prototype, "y", {
|
||||
|
||||
set: function (value) {
|
||||
this.view.y = value;
|
||||
this.displayObject.y = -value;
|
||||
this.checkWorldBounds();
|
||||
}
|
||||
|
||||
|
||||
+4
-3
@@ -54,12 +54,13 @@ Phaser.World.prototype = {
|
||||
*/
|
||||
boot: function () {
|
||||
|
||||
this.group = new Phaser.Group(this.game, null, '__world', false);
|
||||
|
||||
this.camera = new Phaser.Camera(this.game, 0, 0, 0, this.game.width, this.game.height);
|
||||
this.camera.displayObject = this.group;
|
||||
|
||||
this.game.camera = this.camera;
|
||||
|
||||
this.group = new Phaser.Group(this.game, null, '__world', true);
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -77,7 +78,7 @@ Phaser.World.prototype = {
|
||||
{
|
||||
var currentNode = this.game.stage._stage.first._iNext;
|
||||
|
||||
do
|
||||
do
|
||||
{
|
||||
if (currentNode['preUpdate'])
|
||||
{
|
||||
|
||||
@@ -419,16 +419,16 @@ Phaser.Sprite.prototype.postUpdate = function() {
|
||||
if (this.exists)
|
||||
{
|
||||
// The sprite is positioned in this call, after taking into consideration motion updates and collision
|
||||
this.body.postUpdate();
|
||||
// this.body.postUpdate();
|
||||
|
||||
this._cache.x = this.x - (this.game.world.camera.x * this.scrollFactor.x);
|
||||
this._cache.y = this.y - (this.game.world.camera.y * this.scrollFactor.y);
|
||||
// this._cache.x = this.x - (this.game.world.camera.x * this.scrollFactor.x);
|
||||
// this._cache.y = this.y - (this.game.world.camera.y * this.scrollFactor.y);
|
||||
|
||||
if (this.position.x != this._cache.x || this.position.y != this._cache.y)
|
||||
{
|
||||
this.position.x = this._cache.x;
|
||||
this.position.y = this._cache.y;
|
||||
}
|
||||
// if (this.position.x != this._cache.x || this.position.y != this._cache.y)
|
||||
// {
|
||||
// this.position.x = this._cache.x;
|
||||
// this.position.y = this._cache.y;
|
||||
// }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -123,6 +123,23 @@ Phaser.Keyboard.prototype = {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Creates and returns an object containing 4 hotkeys for Up, Down, Left and Right.
|
||||
*
|
||||
* @method Phaser.Keyboard#createCursorKeys
|
||||
* @return {object} An object containing properties: up, down, left and right. Which can be polled like any other Phaser.Key object.
|
||||
*/
|
||||
createCursorKeys: function () {
|
||||
|
||||
return {
|
||||
up: this.addKey(Phaser.Keyboard.UP),
|
||||
down: this.addKey(Phaser.Keyboard.DOWN),
|
||||
left: this.addKey(Phaser.Keyboard.LEFT),
|
||||
right: this.addKey(Phaser.Keyboard.RIGHT)
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Starts the Keyboard event listeners running (keydown and keyup). They are attached to the document.body.
|
||||
* This is called automatically by Phaser.Input and should not normally be invoked directly.
|
||||
|
||||
+6
-8
@@ -197,16 +197,14 @@ Phaser.Cache.prototype = {
|
||||
*/
|
||||
addDefaultImage: function () {
|
||||
|
||||
this._images['__default'] = { url: null, data: null, spriteSheet: false };
|
||||
var img = new Image();
|
||||
img.src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAIAAAD8GO2jAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJ9JREFUeNq01ssOwyAMRFG46v//Mt1ESmgh+DFmE2GPOBARKb2NVjo+17PXLD8a1+pl5+A+wSgFygymWYHBb0FtsKhJDdZlncG2IzJ4ayoMDv20wTmSMzClEgbWYNTAkQ0Z+OJ+A/eWnAaR9+oxCF4Os0H8htsMUp+pwcgBBiMNnAwF8GqIgL2hAzaGFFgZauDPKABmowZ4GL369/0rwACp2yA/ttmvsQAAAABJRU5ErkJggg==";
|
||||
|
||||
this._images['__default'] = { url: null, data: img, spriteSheet: false };
|
||||
this._images['__default'].frame = new Phaser.Frame(0, 0, 0, 32, 32, '', '');
|
||||
|
||||
var base = new PIXI.BaseTexture();
|
||||
base.width = 32;
|
||||
base.height = 32;
|
||||
base.hasLoaded = true; // avoids a hanging event listener
|
||||
|
||||
PIXI.BaseTextureCache['__default'] = base;
|
||||
PIXI.TextureCache['__default'] = new PIXI.Texture(base);
|
||||
PIXI.BaseTextureCache['__default'] = new PIXI.BaseTexture(img);
|
||||
PIXI.TextureCache['__default'] = new PIXI.Texture(PIXI.BaseTextureCache['__default']);
|
||||
|
||||
},
|
||||
|
||||
|
||||
@@ -733,7 +733,7 @@ Phaser.Loader.prototype = {
|
||||
|
||||
this.onFileError.dispatch(key);
|
||||
|
||||
console.warn("Phaser.Loader error loading file: " + key);
|
||||
console.warn("Phaser.Loader error loading file: " + key + ' from URL ' + this._fileList[key].url);
|
||||
|
||||
this.nextFile(key, false);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user