本文整理汇总了TypeScript中matter-js.World.remove方法的典型用法代码示例。如果您正苦于以下问题:TypeScript World.remove方法的具体用法?TypeScript World.remove怎么用?TypeScript World.remove使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matter-js.World
的用法示例。
在下文中一共展示了World.remove方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: switch
const loop = () => {
switch (currentState) {
case GameState.TITLE:
break;
case GameState.PLAYING:
hidePausedTitle();
hideGameOverTitle();
Matter.Events.on(engine, 'collisionStart', onCollisionCallback);
break;
case GameState.GAME_OVER:
Matter.World.remove(engine.world, currentPiece);
Matter.Events.off(engine, 'collisionStart', onCollisionCallback);
gameOver(engine);
showGameOverTitle();
break;
case GameState.PAUSED:
runner.enabled = !runner.enabled;
showPausedTitle();
break;
case GameState.FROZEN:
runner.enabled = !runner.enabled;
break;
default:
break;
};
};
示例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);
};