mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 18:47:35 +00:00
Fix Planck debug draw: add camera sync and hide sensors like Box2D
This commit is contained in:
parent
955179eec9
commit
d584065757
6 changed files with 109 additions and 18 deletions
|
|
@ -52,15 +52,59 @@ function (Parent, Settings, domController, Box2D, nc, PlanckDebugDraw, debugLaye
|
|||
Engine.prototype.renderDebug = function () {
|
||||
if (this.debugDraw) {
|
||||
this.debugDraw.clear();
|
||||
|
||||
// Get camera position from the game view
|
||||
var cameraPos = this.getCameraPosition();
|
||||
var zoom = this.getCameraZoom();
|
||||
|
||||
// Apply camera transformations to debug draw
|
||||
this.debugDraw.setTransform(cameraPos, zoom);
|
||||
this.debugDraw.drawWorld(this.world);
|
||||
}
|
||||
};
|
||||
|
||||
Engine.prototype.getCameraPosition = function() {
|
||||
// Get camera position from the view system
|
||||
// This needs to match the layer positioning logic
|
||||
if (this.gameController && this.gameController.view && this.gameController.view.layerManager) {
|
||||
var layerManager = this.gameController.view.layerManager;
|
||||
var tileLayer = layerManager.getLayerById('tile'); // Use tile layer as reference
|
||||
|
||||
if (tileLayer) {
|
||||
return {
|
||||
x: tileLayer.position.current.x,
|
||||
y: tileLayer.position.current.y,
|
||||
zoom: tileLayer.zoom.current
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback to default position
|
||||
return { x: 0, y: 0, zoom: 1 };
|
||||
};
|
||||
|
||||
Engine.prototype.getCameraZoom = function() {
|
||||
if (this.gameController && this.gameController.view && this.gameController.view.layerManager) {
|
||||
var layerManager = this.gameController.view.layerManager;
|
||||
var tileLayer = layerManager.getLayerById('tile');
|
||||
|
||||
if (tileLayer) {
|
||||
return tileLayer.zoom.current;
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
};
|
||||
|
||||
Engine.prototype.setGameController = function(gameController) {
|
||||
this.gameController = gameController;
|
||||
};
|
||||
|
||||
Engine.prototype.update = function () {
|
||||
Parent.prototype.update.call(this);
|
||||
|
||||
if(this.debugMode) {
|
||||
this.world.DrawDebugData();
|
||||
if(this.debugMode && this.debugDraw) {
|
||||
this.debugDraw.drawWorld(this.world);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue