0
0
Fork 0
mirror of https://github.com/liabru/matter-js.git synced 2024-11-27 09:50:52 -05:00

added Demo.compositeManipulation

This commit is contained in:
liabru 2014-07-30 17:27:42 +01:00
parent 4c4962fb4f
commit 4051823f5f
2 changed files with 43 additions and 0 deletions

View file

@ -38,6 +38,7 @@
<option value="views">Views</option>
<option value="timescale">Time Scaling</option>
<option value="manipulation">Body Manipulation</option>
<option value="compositeManipulation">Composite Manipulation</option>
<option value="sprites">Sprites</option>
<option value="pyramid">Pyramid</option>
<option value="raycasting">Raycasting</option>

View file

@ -293,6 +293,48 @@
renderOptions.showCollisions = true;
};
Demo.compositeManipulation = function() {
var _world = _engine.world;
Demo.reset();
var stack = Composites.stack(200, 200, 4, 4, 0, 0, function(x, y, column, row) {
return Bodies.rectangle(x, y, 40, 40);
});
World.add(_world, stack);
_world.gravity.y = 0;
_sceneEvents.push(
Events.on(_engine, 'tick', function(event) {
var time = _engine.timing.timestamp;
Composite.translate(stack, {
x: Math.sin(time * 0.001) * 2,
y: 0
});
Composite.rotate(stack, Math.sin(time * 0.001) * 0.01, {
x: 300,
y: 300
});
var scale = 1 + (Math.sin(time * 0.001) * 0.01);
Composite.scale(stack, scale, scale, {
x: 300,
y: 300
});
})
);
var renderOptions = _engine.render.options;
renderOptions.wireframes = false;
renderOptions.showAxes = true;
renderOptions.showCollisions = true;
};
Demo.views = function() {
var _world = _engine.world;