INNER CODE UNIT · JavaScript

targetW

shixiangxi0/Cobweb · clients/phaser/src/main.js:102

  const targetW = Math.round(cssW * dpr);
  const targetH = Math.round(cssH * dpr);

  if (canvas.width !== targetW || canvas.height !== targetH) {
    canvas.width = targetW;
    canvas.height = targetH;
    if (game.renderer && typeof game.renderer.resize === 'function') {
      game.renderer.resize(targetW, targetH);
    }
  }
}

// prestep 在 Phaser 每帧逻辑更新之前触发,确保渲染前 viewport 已修正
if (game.events) {
  game.events.on('prestep', fixCanvasDpr);
}

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…