diff --git a/src/game-lib-a-component-a.js b/src/game-lib-a-component-a.js index 4ba69c9..5214825 100644 --- a/src/game-lib-a-component-a.js +++ b/src/game-lib-a-component-a.js @@ -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, {