mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
debug draw overlay, fullscreen
This commit is contained in:
parent
383eaa93bf
commit
4afc39081d
13 changed files with 247 additions and 93 deletions
|
|
@ -10,12 +10,16 @@ function (DomController, Settings, Exception, NotificationCenter) {
|
|||
function AbstractView () {
|
||||
this.me = null;
|
||||
this.canvas = null;
|
||||
this.debugMode = false;
|
||||
|
||||
NotificationCenter.on("view/createMesh", this.createMesh, this);
|
||||
NotificationCenter.on("view/createAnimatedMesh", this.createAnimatedMesh, this);
|
||||
NotificationCenter.on("view/addMesh", this.addMesh, this);
|
||||
NotificationCenter.on("view/removeMesh", this.removeMesh, this);
|
||||
NotificationCenter.on("view/updateMesh", this.updateMesh, this);
|
||||
|
||||
NotificationCenter.on("view/fullscreenChange", this.onFullscreenChange, this);
|
||||
NotificationCenter.on("view/toggleDebugMode", this.onToggleDebugMode, this);
|
||||
}
|
||||
|
||||
AbstractView.prototype.isWebGlEnabled = function () {
|
||||
|
|
@ -30,10 +34,6 @@ function (DomController, Settings, Exception, NotificationCenter) {
|
|||
|
||||
this.canvas = canvas;
|
||||
DomController.setCanvas(canvas);
|
||||
|
||||
if(Settings.DEBUG_MODE) {
|
||||
DomController.createDebugCanvas();
|
||||
}
|
||||
}
|
||||
|
||||
AbstractView.prototype.loadPlayerMesh = function(player) {
|
||||
|
|
@ -102,7 +102,28 @@ function (DomController, Settings, Exception, NotificationCenter) {
|
|||
|
||||
AbstractView.prototype.setCameraZoom = function (z) {
|
||||
throw new Exception('Abstract Function setCameraZoom not overwritten ');
|
||||
}
|
||||
};
|
||||
|
||||
AbstractView.prototype.onFullscreenChange = function(isFullScreen) {
|
||||
|
||||
if (!isFullScreen) {
|
||||
Settings.STAGE_WIDTH = 600;
|
||||
Settings.STAGE_HEIGHT = 400;
|
||||
} else {
|
||||
// FIXME: Create FIXME meme (dumb and dumber)
|
||||
// FIXME: don't overwrite Settings
|
||||
Settings.STAGE_WIDTH = window.innerWidth;
|
||||
Settings.STAGE_HEIGHT = window.innerHeight;
|
||||
}
|
||||
};
|
||||
|
||||
AbstractView.prototype.onToggleDebugMode = function(debugMode) {
|
||||
if(debugMode) {
|
||||
this.setCameraPosition(-Settings.STAGE_WIDTH / 2, -Settings.STAGE_HEIGHT / 2);
|
||||
}
|
||||
|
||||
this.debugMode = debugMode;
|
||||
};
|
||||
|
||||
return AbstractView;
|
||||
});
|
||||
|
|
@ -2,10 +2,11 @@ define([
|
|||
"Game/Client/View/Views/AbstractView",
|
||||
"Game/Client/View/DomController",
|
||||
"Lib/Vendor/Pixi",
|
||||
"Game/Config/Settings"
|
||||
"Game/Config/Settings",
|
||||
"Lib/Utilities/NotificationCenter"
|
||||
],
|
||||
|
||||
function (Parent, DomController, PIXI, Settings) {
|
||||
function (Parent, DomController, PIXI, Settings, NotificationCenter) {
|
||||
|
||||
function PixiView () {
|
||||
|
||||
|
|
@ -104,14 +105,16 @@ function (Parent, DomController, PIXI, Settings) {
|
|||
}
|
||||
|
||||
PixiView.prototype.calculateCameraPosition = function() {
|
||||
|
||||
var reference = this.me.getPosition();
|
||||
var pos = {};
|
||||
|
||||
pos.x = -reference.x;
|
||||
pos.y = reference.y;
|
||||
|
||||
pos.x = pos.x * Settings.RATIO;
|
||||
pos.y = -(pos.y * Settings.RATIO);
|
||||
var zoom = this.container.scale.x;
|
||||
pos.x = pos.x * Settings.RATIO * zoom;
|
||||
pos.y = -(pos.y * Settings.RATIO) * zoom;
|
||||
|
||||
pos.x -= this.me.playerController.xyInput.x * Settings.STAGE_WIDTH / 4;
|
||||
pos.y += this.me.playerController.xyInput.y * Settings.STAGE_HEIGHT / 4;
|
||||
|
|
@ -120,13 +123,30 @@ function (Parent, DomController, PIXI, Settings) {
|
|||
};
|
||||
|
||||
PixiView.prototype.setCameraPosition = function (x, y) {
|
||||
this.container.position.x = x + Settings.STAGE_WIDTH / 2;
|
||||
this.container.position.y = y + Settings.STAGE_HEIGHT / 2;
|
||||
if(!this.debugMode) {
|
||||
this.container.position.x = x + Settings.STAGE_WIDTH / 2;
|
||||
this.container.position.y = y + Settings.STAGE_HEIGHT / 2;
|
||||
}
|
||||
};
|
||||
|
||||
PixiView.prototype.setCameraZoom = function (z) {
|
||||
//this.container.position.x = x;
|
||||
//this.container.position.y = y;
|
||||
//this.container.position.y = y;
|
||||
this.container.scale.x = z;
|
||||
this.container.scale.y = z;
|
||||
|
||||
};
|
||||
|
||||
PixiView.prototype.onFullscreenChange = function(isFullScreen) {
|
||||
Parent.prototype.onFullscreenChange.call(this, isFullScreen);
|
||||
|
||||
if(isFullScreen) {
|
||||
this.renderer.resize(window.innerWidth, window.innerHeight);
|
||||
this.setCameraZoom(window.innerWidth / 600);
|
||||
} else {
|
||||
this.renderer.resize(600, 400);
|
||||
this.setCameraZoom(1);
|
||||
}
|
||||
};
|
||||
|
||||
return PixiView;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue