本文整理汇总了TypeScript中matter-js.Composite类的典型用法代码示例。如果您正苦于以下问题:TypeScript Composite类的具体用法?TypeScript Composite怎么用?TypeScript Composite使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Composite类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: setGameState
const checkGameOver = () => {
const bodies = Matter.Composite.allBodies(engine.world);
bodies.forEach(body => {
if (body.position.y < 0 && !body.alive) {
setGameState(GameState.GAME_OVER);
return;
}
})
};
示例2:
const removeAllTetronimos = (engine: Matter.Engine) => {
if (isRemoving) return;
const bodies = Matter.Composite.allBodies(engine.world);
const tetronimos = bodies.filter(body => body.label === LABEL.TETRONIMO);
if (tetronimos.length === 0) return;
isRemoving = true;
for (let i = 0; i < tetronimos.length; i++) {
Matter.World.remove(engine.world, tetronimos[i]);
}
}
示例3: setInterval
const gameOver = (engine: Matter.Engine) => {
const bodies = Matter.Composite.allBodies(engine.world);
const floor = bodies.filter(body => body.label === LABEL.FLOOR);
if (bodies.length === 0) return;
for (let i = 0; i < floor.length; i++) {
Matter.World.remove(engine.world, floor[i]);
}
setInterval(() => {
removeAllTetronimos(engine);
}, 2000);
};