matterDemo_egret icon indicating copy to clipboard operation
matterDemo_egret copied to clipboard

请教在白鹭使用matter的问题

Open kenchelsea8 opened this issue 6 years ago • 3 comments

首先感谢大大的方法

在白鹭里使用matter的时候,如果我想使用例如bitmap这种对象,要如何加入到matter中呢? 因为考虑到要用egret的层叠操作,好像没法覆盖在matter画出的图形上方

kenchelsea8 avatar Jun 02 '18 05:06 kenchelsea8

@kenchelsea8 egret使用matter时,只用到了matter的物理计算,渲染是使用egret自己的,所以可以随便使用egret的任何一种容器。现在demo里用到的显示对像用就egret.bitmap。请查看EgretRender.ts文件。你只需要根据自己修改一下代码就好了。

如果你想直接new一个bitmap然后就加到matter里是不行的,首先你要理解matter只负责刚体运算,所以matter里只有刚体,你只能创建一个刚体,然后加入matter里,而刚体与显示对象需要你手动绑定,matter负责更新刚体的位置和角度以及其它信息,你根据刚体的这些信息去更新显示对象的位置角度以及其它。

guawoo avatar Jun 03 '18 02:06 guawoo

感谢,我现在对刚体施加较大的力时偶尔会出现穿过墙壁的情况,请问这种情况是检测频率的问题吗

kenchelsea8 avatar Jun 06 '18 11:06 kenchelsea8

这好像是matter.js的一个bug,具体请看https://github.com/liabru/matter-js/issues/5

guawoo avatar Jun 07 '18 02:06 guawoo