mirror of
https://github.com/unanmed/HumanBreak.git
synced 2025-01-19 12:49:25 +08:00
feat: 渲染根元素取消画布的alpha通道,提高性能
This commit is contained in:
parent
fc8e666c3a
commit
8d7ca27bb4
@ -29,11 +29,11 @@ export class MotaOffscreenCanvas2D extends EventEmitter<OffscreenCanvasEvent> {
|
||||
/** 更新标识符,如果发生变化则说明画布被动清空 */
|
||||
symbol: number = 0;
|
||||
|
||||
constructor() {
|
||||
constructor(alpha: boolean = true) {
|
||||
super();
|
||||
|
||||
this.canvas = document.createElement('canvas');
|
||||
this.ctx = this.canvas.getContext('2d')!;
|
||||
this.ctx = this.canvas.getContext('2d', { alpha })!;
|
||||
this.width = this.canvas.width / devicePixelRatio;
|
||||
this.height = this.canvas.height / devicePixelRatio;
|
||||
|
||||
@ -203,14 +203,18 @@ export class MotaCanvas2D extends MotaOffscreenCanvas2D {
|
||||
/** 是否是高清画布 */
|
||||
highResolution: boolean = true;
|
||||
|
||||
constructor(id: string = '', setTarget: boolean = true) {
|
||||
constructor(
|
||||
id: string = '',
|
||||
setTarget: boolean = true,
|
||||
alpha: boolean = true
|
||||
) {
|
||||
super();
|
||||
|
||||
this.id = id;
|
||||
if (setTarget) this.target = core.dom.gameDraw;
|
||||
this.canvas = document.createElement('canvas');
|
||||
this.canvas.id = id;
|
||||
this.ctx = this.canvas.getContext('2d')!;
|
||||
this.ctx = this.canvas.getContext('2d', { alpha })!;
|
||||
this.width = this.canvas.width / devicePixelRatio;
|
||||
this.height = this.canvas.height / devicePixelRatio;
|
||||
|
||||
|
@ -13,7 +13,7 @@ export class MotaRenderer extends Container {
|
||||
constructor(id: string = 'render-main') {
|
||||
super('static', false);
|
||||
|
||||
this.target = new MotaCanvas2D(id);
|
||||
this.target = new MotaCanvas2D(id, true, false);
|
||||
this.size(core._PX_, core._PY_);
|
||||
this.target.withGameScale(true);
|
||||
this.target.size(core._PX_, core._PY_);
|
||||
|
Loading…
Reference in New Issue
Block a user