MatterJS新手。
在示例中,theres是绘制圆形,矩形等的选项。 这些选项就像使用Sprite,FillStyle ......
我在文档中看不到与之相关的选项和值列表。
任何人都可以提供帮助吗?
感谢。
答案 0 :(得分:0)
http://brm.io/matter-js/docs/classes/Bodies.html
在这里你可以看到一些多边形和梯形等的例子
答案 1 :(得分:0)
这些选项是正文的属性,在Matter.Body
模块中描述:http://brm.io/matter-js/docs/classes/Body.html#properties
答案 2 :(得分:0)
我认为在这些示例中, matter.js 正在通过Render.bodies
(在something.js文件中)和相关功能来处理物体本身的形状。>
如果有人想绘制线条,圆形或矩形,我想他们可以访问实质.js使用的画布,并通过lineTo(画布的弧函数)进行绘制。
答案 3 :(得分:0)
通过阅读what.js的source code,我发现了选项的默认设置。不解释每种功能,但至少这里是它们的列表:
var defaults = {
id: Common.nextId(),
type: 'body',
label: 'Body',
parts: [],
plugin: {},
angle: 0,
vertices: Vertices.fromPath('L 0 0 L 40 0 L 40 40 L 0 40'),
position: { x: 0, y: 0 },
force: { x: 0, y: 0 },
torque: 0,
positionImpulse: { x: 0, y: 0 },
constraintImpulse: { x: 0, y: 0, angle: 0 },
totalContacts: 0,
speed: 0,
angularSpeed: 0,
velocity: { x: 0, y: 0 },
angularVelocity: 0,
isSensor: false,
isStatic: false,
isSleeping: false,
motion: 0,
sleepThreshold: 60,
density: 0.001,
restitution: 0,
friction: 0.1,
frictionStatic: 0.5,
frictionAir: 0.01,
collisionFilter: {
category: 0x0001,
mask: 0xFFFFFFFF,
group: 0
},
slop: 0.05,
timeScale: 1,
render: {
visible: true,
opacity: 1,
sprite: {
xScale: 1,
yScale: 1,
xOffset: 0,
yOffset: 0
},
lineWidth: 0
}
};
正如taras指出的那样,从这些选项中初始化了对象的properties。