0
0
Fork 0
mirror of https://github.com/liabru/matter-js.git synced 2025-02-01 18:24:54 -05:00

added Common.nextId, removed Body.nextId, removed Constraint.nextId, removed Composite.nextId

This commit is contained in:
liabru 2014-04-29 17:34:28 +01:00
parent 23a0fce2c0
commit cb7cb9583a
4 changed files with 16 additions and 36 deletions

View file

@ -9,8 +9,7 @@ var Body = {};
(function() {
var _nextId = 0,
_nextGroupId = 1;
var _nextGroupId = 1;
/**
* Description to be written.
@ -20,7 +19,7 @@ var Body = {};
*/
Body.create = function(options) {
var defaults = {
id: Body.nextId(),
id: Common.nextId(),
type: 'body',
label: 'Body',
angle: 0,
@ -62,15 +61,6 @@ var Body = {};
return body;
};
/**
* Description
* @method nextId
* @return {Number} Unique bodyID
*/
Body.nextId = function() {
return _nextId++;
};
/**
* Description
* @method nextGroupId

View file

@ -11,8 +11,6 @@ var Composite = {};
(function() {
var _nextId = 0;
/**
* Description
* @method create
@ -21,7 +19,7 @@ var Composite = {};
*/
Composite.create = function(options) {
return Common.extend({
id: Composite.nextId(),
id: Common.nextId(),
type: 'composite',
parent: null,
isModified: false,
@ -32,15 +30,6 @@ var Composite = {};
}, options);
};
/**
* Returns the next unique compositeID
* @method nextId
* @return {Number} Unique compositeID
*/
Composite.nextId = function() {
return _nextId++;
};
/**
* Sets the composite's `isModified` flag.
* If `updateParents` is true, all parents will be set (default: false).

View file

@ -18,8 +18,7 @@ var Constraint = {};
(function() {
var _minLength = 0.000001,
_minDifference = 0.001,
_nextId = 0;
_minDifference = 0.001;
/**
* Description
@ -53,7 +52,7 @@ var Constraint = {};
constraint.render = Common.extend(render, constraint.render);
// option defaults
constraint.id = constraint.id || Constraint.nextId();
constraint.id = constraint.id || Common.nextId();
constraint.label = constraint.label || 'Constraint';
constraint.type = 'constraint';
constraint.stiffness = constraint.stiffness || 1;
@ -256,13 +255,4 @@ var Constraint = {};
}
};
/**
* Returns the next unique constraintId
* @method nextId
* @return {Number} Unique constraintId
*/
Constraint.nextId = function() {
return _nextId++;
};
})();

View file

@ -8,6 +8,8 @@ var Common = {};
(function() {
Common._nextId = 0;
/**
* Description
* @method extend
@ -267,4 +269,13 @@ var Common = {};
console.log('%c [Matter] ' + type + ': ' + message, style);
};
/**
* Returns the next unique sequential ID
* @method nextId
* @return {Number} Unique sequential ID
*/
Common.nextId = function() {
return Common._nextId++;
};
})();