Skip to content

Commit

Permalink
added Demo.compositeManipulation
Browse files Browse the repository at this point in the history
  • Loading branch information
liabru committed Jul 30, 2014
1 parent 4c4962f commit 4051823
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
1 change: 1 addition & 0 deletions demo/dev.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ <h1>Matter.js Demo (Dev. Build)</h1>
<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>
Expand Down
42 changes: 42 additions & 0 deletions demo/js/Demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 4051823

Please sign in to comment.