【发布时间】:2019-11-14 12:13:37
【问题描述】:
一切都是不变的,但将 chrome 选项卡移动到另一台显示器会在某种程度上影响落球的物理特性
问题的视频:(在 Mac 上录制) https://www.youtube.com/watch?v=eNoVshieh08
据我了解,引擎 pixelRatio 被定义为 1:1,这意味着具有不同分辨率的更大/更小屏幕不应改变球的物理行为。
此外,最左边的监视器似乎总是具有相同的预期行为(从 1 点掉落的球经过相同的钉子路线并到达确切的结束位置。
我的其他显示器,中间的显示器(分辨率最高)和右侧的 macbook 视网膜显示器会导致球掉落并不时改变它的路线。
更新
将中间显示器更改为具有相同的分辨率和刷新率会使球的行为方式完全相同。 所以现在的问题是为什么刷新率会改变引擎物理的行为,我们如何控制它?
引擎创建:
// create an this.engine
this.engine = Engine.create()
// create a renderer
this.render = Render.create({
element: this.$refs.scene,
engine: this.engine,
options: {
wireframes: true,
showAngleIndicator: true,
showBroadphase: false,
showBounds: true,
// pixelRatio: 'auto',
background: 'transparent',
width: DEFS.WIDTH,
height: 930,
},
})
钉创建:
// Create a generic peg object
const peg = (x, y) => {
return Bodies.circle(x, y, DEFS.PEGS.RADIUS, {
isStatic: true,
collisionFilter: {
category: this.collisionCategories.default,
},
friction: 0,
frictionAir: 0,
frictionStatic: 0,
restitution: 0,
render: {
fillStyle: 'lightblue',
/* sprite: {
texture: require('~/assets/wall-pin.png'),
xScale: DEFS.PEGS.SCALE,
yScale: DEFS.PEGS.SCALE,
}, */
},
})
}
球创造:
Bodies.circle(350, DEFS.DROPPER.Y + 20, DEFS.BALL.RADIUS, {
density: 0.01,
friction: 0.1,
frictionAir: 0,
frictionStatic: 0,
restitution: 0.3,
collisionFilter: {
category: this.collisionCategories.ball,
mask: this.collisionCategories.default,
},
render: {
fillStyle: 'lightblue',
/* sprite: {
texture: require('~/assets/ball.png'),
xScale: DEFS.BALL.SCALE,
yScale: DEFS.BALL.SCALE,
}, */
},
})
【问题讨论】: