[英]Heaps.io: h2d.Scene.setFixedMode has no effect
In the following code, s2d.setFixedSize()
has no effect. 在以下代码中,
s2d.setFixedSize()
无效。 The scene's size does not get changed, and resizing the screen still changes it. 场景的大小不会改变,调整屏幕大小仍然会改变它。
class Main extends hxd.App {
var bgTile : h2d.Tile;
override function init() {
s2d.setFixedSize(500, 500);
bgTile = h2d.Tile.fromColor(0xFFFFFF, s2d.width, s2d.height);
new h2d.Bitmap(bgTile, s2d);
}
override function update(dt:Float) {
}
static function main() {
new Main();
}
}
Most likely you misunderstood what this function does. 很可能你误解了这个功能的作用。 (But that's understandable due to documentation being written in ambiguous way)
(但由于文档以模糊的方式编写,这是可以理解的)
When you call setFixedSize
you do 2 things: 当你调用
setFixedSize
你会做两件事:
s2d.width
and s2d.height
to be a static value you set in function call. s2d.width
和s2d.height
设置为您在函数调用中设置的静态值。 RenderContext
operates, if s2d
size does not match the window size, it gets stretched to fill entire screen. RenderContext
操作方式,如果s2d
大小与窗口大小不匹配,它会被拉伸以填满整个屏幕。 Most likely you expected it to not scale and remain of static size even when window gets resized. 很可能你预计它不会缩放并保持静态大小,即使窗口调整大小。 It's not possible currently.
目前不可能。 Documentation of
setFixedSize
states that it prevents automatic scene resizing, and it indeed does that, by stretching scene instead of resizing it to match the window size. setFixedSize
文档声明它可以防止自动场景调整大小,它确实通过拉伸场景而不是调整大小以匹配窗口大小来实现。 (And yes, while it does what it says, it's easy to misunderstand) (是的,虽然它做了它所说的,但很容易误解)
There is a PR pending that reworks scaling of s2d, which would deprecate setFixedSize
and will provide better solution for scaling in general. 有一个PR暂挂 ,重新缩放s2d,这将弃用
setFixedSize
,并将提供更好的扩展解决方案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.