cleanup debug canvas #36

This commit is contained in:
Jeena 2015-03-01 15:09:14 +01:00
parent 8dacc83f7a
commit f4c7d9edeb
4 changed files with 21 additions and 60 deletions

View file

@ -13,7 +13,6 @@ function (Settings, Nc, Stats, Screenfull, Graph, PointerLockManager) {
function DomController() {
this.canvas = document.getElementById("canvas");
this.debugCanvas = null;
this.stats = null;
this.ping = null;
this.nickContainer = null;
@ -89,7 +88,6 @@ function (Settings, Nc, Stats, Screenfull, Graph, PointerLockManager) {
checkbox.type = "checkbox";
checkbox.onclick = function(e) {
Nc.trigger(Nc.ns.client.view.debugMode.toggle, e.target.checked);
//self.getDebugCanvas().style.display = e.target.checked ? "" : "none";
}
label.appendChild(checkbox);
label.appendChild(document.createTextNode("Debug"));
@ -122,21 +120,8 @@ function (Settings, Nc, Stats, Screenfull, Graph, PointerLockManager) {
this.nickContainer.innerHTML = nick
}
DomController.prototype.statsBegin = function() {
/*
if(this.stats) {
this.stats.begin();
}
*/
};
DomController.prototype.statsEnd = function() {
/*
if(this.stats) {
this.stats.end();
}
*/
DomController.prototype.fpsStep = function() {
this.fpsGraph.step();
};
@ -162,20 +147,6 @@ function (Settings, Nc, Stats, Screenfull, Graph, PointerLockManager) {
Nc.trigger(Nc.ns.client.view.display.change, Screenfull.isFullscreen);
}
DomController.prototype.getDebugCanvas = function () {
if(!this.debugCanvas) {
var canvas = document.createElement('canvas');
canvas.width = Settings.STAGE_WIDTH;
canvas.height = Settings.STAGE_HEIGHT;
this.debugCanvas = canvas;
this.getCanvasContainer().appendChild(canvas);
this.debugCanvas.style.display = "none";
}
return this.debugCanvas;
}
DomController.prototype.setConnected = function(connected) {
if(connected) {
document.body.style.backgroundColor = '';

View file

@ -11,21 +11,7 @@ function (Box2D, Debug) {
function DebugDraw() {
Parent.call(this);
this.m_drawScale = 1;
this.m_sprite = {
graphics: {
clear: function () {
Debug.graphics.clear();
Debug.graphics.lineStyle(1, 0x00ff00 , 0.8);
//__this.m_ctx.clearRect(0, 0, __this.m_ctx.canvas.width, __this.m_ctx.canvas.height)
}
}
};
}
DebugDraw.prototype = Object.create(Parent.prototype);
@ -33,18 +19,27 @@ function (Box2D, Debug) {
DebugDraw.prototype.setColor = function(color) {
this.m_ctx.debugColor = color.color;
this.m_ctx.debugFillAlpha = this.m_fillAlpha;
Debug.graphics.lineStyle(1, this.m_ctx.debugColor, this.m_alpha);
this.m_ctx.lineStyle(1, this.m_ctx.debugColor, this.m_alpha);
};
DebugDraw.prototype.SetSprite = function(sprite) {
this.m_ctx = Debug.graphics;
this.m_ctx = sprite;
this.m_sprite = {
graphics: {
clear: function () {
sprite.clear();
sprite.lineStyle(1, 0xffffff, 0.8);
}
}
};
this.m_ctx.beginPath = function() {
Debug.graphics.beginFill(this.debugColor, this.debugFillAlpha);
this.beginFill(this.debugColor, this.debugFillAlpha);
};
this.m_ctx.closePath = function() {
Debug.graphics.endFill();
this.endFill();
};
this.m_ctx.fill = function() {
@ -52,11 +47,11 @@ function (Box2D, Debug) {
};
this.m_ctx.stroke = function() {
//console.log('customStroke');
// do nothing
};
this.m_ctx.arc = function(x, y, radius, startingAngle, endingAngle, counterClockwise) {
Debug.graphics.drawCircle(x, y, radius);
this.drawCircle(x, y, radius);
}
};