gpt4 book ai didi

javascript - Phaser 3 调整大小后图像质量低

转载 作者:行者123 更新时间:2023-11-30 13:48:20 24 4
gpt4 key购买 nike

Phaser 3(版本。3.20.1)我找不到在调整图像大小时不损失质量的方法。我尝试了不同的变体:在图像上 setDisplaySize 或 setScale 以及在相机上 setZoom,但图像看起来仍然像素化。

在游戏配置中,我将“类型”更改为 WebGl/Canvas,设置为渲染对象参数:抗锯齿、pixelArt、roundPixels。

我的游戏配置:

{
type: Phaser.AUTO,
disableContextMenu: true,
banner: false,
scale: {
height,
width,
parent: 'canvas',
mode: Phaser.Scale.NONE,
autoRound: true,
},
render: {
roundPixels: true,
},
}

Example

  1. 调整 html 中图像的大小
  2. 通过setScale调整图像大小
  3. 在相机上设置缩放

谢谢:)

最佳答案

我找到了另一种解决方案,对于移动设备,我调整 Canvas 大小而不是更改相机变焦:

this.scene.scale.parent.width = Math.round(width);
this.scene.scale.parent.height = Math.round(height);

this.scene.scale.canvas.style.width = Math.round(width) + 'px';
this.scene.scale.canvas.style.height = Math.round(height) + 'px';
game.canvas.style.width = width + 'px';
game.canvas.style.height = height + 'px';

我花了将近一周的时间来解决这个问题,希望有人能帮忙

关于javascript - Phaser 3 调整大小后图像质量低,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58839190/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com