Matter.js 精灵大小

7

我正在使用matter.js进行物理模拟。

我的问题是,是否可以更改精灵的大小?或者仅使用matter.js是否不可能实现?

这是我目前的代码:

Bodies.circle(x, y, 46, {
  render: {
    sprite: {
      texture: 'images/stone.png'
      //Is there a 'width:' or 'height' property?  
    }
  }
});
1个回答

18

试试这个:

Bodies.circle(x, y, 46, {
  render: {
    sprite: {
      texture: 'images/stone.png',
      xScale: 2,
      yScale: 2
    }
  }
});

文档中还可以看到这里。


如果有一种方法可以精确地以像素为单位设置大小,甚至更好的是匹配形状的边界框的大小,那将是很酷的,这样我们就不必手动计算了。相关问题:https://github.com/liabru/matter-js/issues/120 - Ciro Santilli OurBigBook.com

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接