mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 18:47:35 +00:00
added camera glide - juciness references #56
This commit is contained in:
parent
b65fbd9825
commit
28f71f49e1
2 changed files with 20 additions and 6 deletions
|
|
@ -13,7 +13,6 @@ function (Parent, DomController, PIXI, Settings, Nc) {
|
||||||
Parent.call(this);
|
Parent.call(this);
|
||||||
|
|
||||||
this.movableObjects = [];
|
this.movableObjects = [];
|
||||||
this.camera = null;
|
|
||||||
this.stage = null;
|
this.stage = null;
|
||||||
this.container = null;
|
this.container = null;
|
||||||
this.infoContainer = null;
|
this.infoContainer = null;
|
||||||
|
|
@ -124,12 +123,17 @@ function (Parent, DomController, PIXI, Settings, Nc) {
|
||||||
PixiView.prototype.calculateCameraPosition = function() {
|
PixiView.prototype.calculateCameraPosition = function() {
|
||||||
var zoom = this.container.scale.x;
|
var zoom = this.container.scale.x;
|
||||||
|
|
||||||
var pos = this.me.getHeadPosition();
|
var target = this.me.getHeadPosition();
|
||||||
pos.x *= -Settings.RATIO * zoom;
|
target.x *= -Settings.RATIO * zoom;
|
||||||
pos.y *= -Settings.RATIO * zoom;
|
target.y *= -Settings.RATIO * zoom;
|
||||||
|
|
||||||
pos.x -= this.me.playerController.xyInput.x * Settings.STAGE_WIDTH / 4;
|
target.x -= this.me.playerController.xyInput.x * Settings.STAGE_WIDTH / 4;
|
||||||
pos.y += this.me.playerController.xyInput.y * Settings.STAGE_HEIGHT / 4;
|
target.y += this.me.playerController.xyInput.y * Settings.STAGE_HEIGHT / 4;
|
||||||
|
|
||||||
|
var pos = this.getCameraPosition();
|
||||||
|
|
||||||
|
pos.x += (target.x -pos.x) * Settings.CAMERA_GLIDE / 100;
|
||||||
|
pos.y += (target.y -pos.y) * Settings.CAMERA_GLIDE / 100;
|
||||||
|
|
||||||
return pos;
|
return pos;
|
||||||
};
|
};
|
||||||
|
|
@ -141,6 +145,15 @@ function (Parent, DomController, PIXI, Settings, Nc) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
PixiView.prototype.getCameraPosition = function () {
|
||||||
|
var pos = this.container.position;
|
||||||
|
|
||||||
|
pos.x = pos.x - Settings.STAGE_WIDTH / 2;
|
||||||
|
pos.y = pos.y - Settings.STAGE_HEIGHT / 2;
|
||||||
|
|
||||||
|
return pos;
|
||||||
|
};
|
||||||
|
|
||||||
PixiView.prototype.setCameraZoom = function (z) {
|
PixiView.prototype.setCameraZoom = function (z) {
|
||||||
this.container.scale.x = z;
|
this.container.scale.x = z;
|
||||||
this.container.scale.y = z;
|
this.container.scale.y = z;
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ define(function() {
|
||||||
ORIGINAL_TILE_SIZE: 25,
|
ORIGINAL_TILE_SIZE: 25,
|
||||||
TILE_SIZE: 20,
|
TILE_SIZE: 20,
|
||||||
CAMERA_IS_ORTHOGRAPHIC: true,
|
CAMERA_IS_ORTHOGRAPHIC: true,
|
||||||
|
CAMERA_GLIDE: 12, // % of the way per frame
|
||||||
VIEW_CONTROLLER: 0 ? 'Three' : 'Pixi',
|
VIEW_CONTROLLER: 0 ? 'Three' : 'Pixi',
|
||||||
|
|
||||||
// GAME PLAY
|
// GAME PLAY
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue