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

added offset property to Matter.Gui

This commit is contained in:
liabru 2014-04-30 22:37:46 +01:00
parent 7a8051b585
commit 3750bfc719

View file

@ -17,19 +17,6 @@ var Gui = {};
* @return {gui} A container for a configured dat.gui
*/
Gui.create = function(engine, options) {
var gui = {
engine: engine,
datGui: null,
amount: 1,
size: 40,
sides: 4,
density: 0.001,
restitution: 0,
friction: 0.1,
frictionAir: 0.01,
renderer: 'canvas'
};
var _datGuiSupported = window.dat && window.localStorage;
if (!_datGuiSupported) {
@ -37,13 +24,25 @@ var Gui = {};
return;
}
var datGui = gui.datGui = new dat.GUI(options);
var datGui = new dat.GUI(options);
var gui = {
engine: engine,
datGui: datGui,
amount: 1,
size: 40,
sides: 4,
density: 0.001,
restitution: 0,
friction: 0.1,
frictionAir: 0.01,
offset: { x: 0, y: 0 },
renderer: 'canvas'
};
if (Resurrect) {
gui.serializer = new Resurrect({ prefix: '$' });
gui.serializer = new Resurrect({ prefix: '$', cleanup: true });
gui.serializer.parse = gui.serializer.resurrect;
} else {
gui.serializer = JSON;
}
_initDatGui(gui);
@ -209,7 +208,7 @@ var Gui = {};
};
for (var i = 0; i < gui.amount; i++) {
World.add(engine.world, Bodies.polygon(120 + i * gui.size + i * 50, 200, gui.sides, gui.size, options));
World.add(engine.world, Bodies.polygon(gui.offset.x + 120 + i * gui.size + i * 50, gui.offset.y + 200, gui.sides, gui.size, options));
}
};