diff --git a/demo/dev.html b/demo/dev.html index 63bcb67..a5654a0 100644 --- a/demo/dev.html +++ b/demo/dev.html @@ -38,6 +38,7 @@ + diff --git a/demo/js/Demo.js b/demo/js/Demo.js index fc0304d..e837b0a 100644 --- a/demo/js/Demo.js +++ b/demo/js/Demo.js @@ -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;