mirror of
https://github.com/liabru/matter-js.git
synced 2024-11-30 10:20:52 -05:00
added Demo.compositeManipulation
This commit is contained in:
parent
4c4962fb4f
commit
4051823f5f
2 changed files with 43 additions and 0 deletions
|
@ -38,6 +38,7 @@
|
||||||
<option value="views">Views</option>
|
<option value="views">Views</option>
|
||||||
<option value="timescale">Time Scaling</option>
|
<option value="timescale">Time Scaling</option>
|
||||||
<option value="manipulation">Body Manipulation</option>
|
<option value="manipulation">Body Manipulation</option>
|
||||||
|
<option value="compositeManipulation">Composite Manipulation</option>
|
||||||
<option value="sprites">Sprites</option>
|
<option value="sprites">Sprites</option>
|
||||||
<option value="pyramid">Pyramid</option>
|
<option value="pyramid">Pyramid</option>
|
||||||
<option value="raycasting">Raycasting</option>
|
<option value="raycasting">Raycasting</option>
|
||||||
|
|
|
@ -293,6 +293,48 @@
|
||||||
renderOptions.showCollisions = true;
|
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() {
|
Demo.views = function() {
|
||||||
var _world = _engine.world;
|
var _world = _engine.world;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue