clone numbers for components

beta.r3js.org
-=yb4f310 2017-10-27 10:00:45 +02:00
parent b042b797d0
commit aa574574a6
1 changed files with 9 additions and 11 deletions

View File

@ -32,6 +32,8 @@ GameLib.Component = function(
this.linked = false;
this.cloneNumber = 0;
if (GameLib.Utils.UndefinedOrNull(delayed)) {
delayed = false;
}
@ -403,20 +405,13 @@ GameLib.Component.prototype.clone = function() {
var apiObject = this.toApiObject();
this.cloneNumber += 1;
apiObject.id = GameLib.Utils.RandomId();
var matches = apiObject.name.match(/Clone \((\d+)\)/);
apiObject.name = this.name + ' Clone (' + this.cloneNumber + ')';
if (matches && matches.length > 1) {
if (matches.length === 2) {
var number = Number(matches[1]);
apiObject.name = apiObject.name.replace(/Clone \(\d*\)/, 'Clone (' + (number+1) + ')');
}
} else {
apiObject.name = apiObject.name + ' Clone (1)'
}
var runtimeObject = null;
var runtimeObject = null;
try {
runtimeObject = new this.constructor(this.graphics, apiObject);
@ -436,6 +431,9 @@ GameLib.Component.prototype.clone = function() {
}
}
/**
* TODO check below event emit
*/
GameLib.Event.Emit(
GameLib.Event.COMPONENT_CREATED,
{