【发布时间】:2019-10-22 12:40:23
【问题描述】:
我正在尝试在 matte.js 中吸引眼球。我有一个瞳孔和一个虹膜,它们被约束在一起。我的问题是我需要让两个身体都忽略碰撞,这样我才能将一个放在另一个之上。
var defaultCategory = 0x0001
var iris = Bodies.circle(0, 0, 20);
var pupil = Bodies.circle(300, 200, 30)
var ground = Bodies.rectangle(400, 380, 810, 60, { isStatic: true });
var bodyA = Bodies.polygon(100, 100, 6, 20,{
collisionFilter: {
mask: defaultCategory
}
});
var bodyB = Bodies.polygon(200, 100, 10, 50,{
collisionFilter: {
category: defaultCategory
}
});
var constraint = Constraint.create({
bodyA: bodyA,
pointA: { x: -10, y: -10 },
bodyB: bodyB,
pointB: { x: -10, y: -10 },
length: 40
});
World.add(world, [pupil, iris, ground, constraint]);
【问题讨论】:
标签: matter.js