2016-06-29 13:48:30 -04:00
|
|
|
var util = require('util');
|
2016-06-29 23:07:34 -04:00
|
|
|
var MathUtil = require('../util/math-util');
|
2016-06-29 13:48:30 -04:00
|
|
|
var Target = require('../engine/target');
|
|
|
|
|
2016-07-06 14:09:06 -04:00
|
|
|
/**
|
2016-07-13 16:52:46 -04:00
|
|
|
* Clone (instance) of a sprite.
|
2016-08-31 11:21:32 -04:00
|
|
|
* @param {!Sprite} sprite Reference to the sprite.
|
2016-09-15 19:37:12 -04:00
|
|
|
* @param {Runtime} runtime Reference to the runtime.
|
2016-07-06 14:09:06 -04:00
|
|
|
* @constructor
|
|
|
|
*/
|
2016-09-15 19:37:12 -04:00
|
|
|
function Clone(sprite, runtime) {
|
2016-08-31 11:21:32 -04:00
|
|
|
Target.call(this, sprite.blocks);
|
2016-09-15 19:37:12 -04:00
|
|
|
this.runtime = runtime;
|
2016-08-31 11:21:32 -04:00
|
|
|
/**
|
|
|
|
* Reference to the sprite that this is a clone of.
|
|
|
|
* @type {!Sprite}
|
|
|
|
*/
|
|
|
|
this.sprite = sprite;
|
2016-08-08 18:29:44 -04:00
|
|
|
/**
|
|
|
|
* Reference to the global renderer for this VM, if one exists.
|
|
|
|
* @type {?RenderWebGLWorker}
|
|
|
|
*/
|
|
|
|
this.renderer = null;
|
2016-09-20 02:42:05 -04:00
|
|
|
if (this.runtime) {
|
|
|
|
this.renderer = this.runtime.renderer;
|
2016-08-08 18:29:44 -04:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* ID of the drawable for this clone returned by the renderer, if rendered.
|
|
|
|
* @type {?Number}
|
|
|
|
*/
|
2016-06-29 20:56:55 -04:00
|
|
|
this.drawableID = null;
|
2016-06-29 13:48:30 -04:00
|
|
|
}
|
|
|
|
util.inherits(Clone, Target);
|
|
|
|
|
2016-07-06 13:57:58 -04:00
|
|
|
/**
|
2016-08-08 18:29:44 -04:00
|
|
|
* Create a clone's drawable with the this.renderer.
|
2016-07-06 13:57:58 -04:00
|
|
|
*/
|
2016-06-29 20:56:55 -04:00
|
|
|
Clone.prototype.initDrawable = function () {
|
2016-08-08 18:29:44 -04:00
|
|
|
if (this.renderer) {
|
2016-09-15 19:02:03 -04:00
|
|
|
this.drawableID = this.renderer.createDrawable();
|
2016-08-08 18:29:44 -04:00
|
|
|
}
|
2016-09-15 19:37:12 -04:00
|
|
|
// If we're a clone, start the hats.
|
|
|
|
if (!this.isOriginal) {
|
|
|
|
this.runtime.startHats(
|
|
|
|
'control_start_as_clone', null, this
|
|
|
|
);
|
|
|
|
}
|
2016-06-29 20:56:55 -04:00
|
|
|
};
|
|
|
|
|
2016-07-06 13:57:58 -04:00
|
|
|
// Clone-level properties.
|
2016-09-15 19:37:12 -04:00
|
|
|
/**
|
|
|
|
* Whether this represents an "original" clone, i.e., created by the editor
|
|
|
|
* and not clone blocks. In interface terms, this true for a "sprite."
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
|
|
|
Clone.prototype.isOriginal = true;
|
|
|
|
|
2016-09-08 09:40:27 -04:00
|
|
|
/**
|
|
|
|
* Whether this clone represents the Scratch stage.
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
|
|
|
Clone.prototype.isStage = false;
|
|
|
|
|
2016-07-06 13:57:58 -04:00
|
|
|
/**
|
|
|
|
* Scratch X coordinate. Currently should range from -240 to 240.
|
2016-08-31 11:21:32 -04:00
|
|
|
* @type {Number}
|
2016-07-06 13:57:58 -04:00
|
|
|
*/
|
2016-06-29 13:48:30 -04:00
|
|
|
Clone.prototype.x = 0;
|
|
|
|
|
2016-07-06 13:57:58 -04:00
|
|
|
/**
|
|
|
|
* Scratch Y coordinate. Currently should range from -180 to 180.
|
2016-08-31 11:21:32 -04:00
|
|
|
* @type {number}
|
2016-07-06 13:57:58 -04:00
|
|
|
*/
|
2016-06-29 13:48:30 -04:00
|
|
|
Clone.prototype.y = 0;
|
|
|
|
|
2016-07-06 13:57:58 -04:00
|
|
|
/**
|
|
|
|
* Scratch direction. Currently should range from -179 to 180.
|
2016-08-31 11:21:32 -04:00
|
|
|
* @type {number}
|
2016-07-06 13:57:58 -04:00
|
|
|
*/
|
2016-06-29 13:48:30 -04:00
|
|
|
Clone.prototype.direction = 90;
|
|
|
|
|
2016-07-06 13:57:58 -04:00
|
|
|
/**
|
|
|
|
* Whether the clone is currently visible.
|
2016-08-31 11:21:32 -04:00
|
|
|
* @type {boolean}
|
2016-07-06 13:57:58 -04:00
|
|
|
*/
|
2016-07-01 12:56:59 -04:00
|
|
|
Clone.prototype.visible = true;
|
|
|
|
|
2016-07-06 13:57:58 -04:00
|
|
|
/**
|
|
|
|
* Size of clone as a percent of costume size. Ranges from 5% to 535%.
|
2016-08-31 11:21:32 -04:00
|
|
|
* @type {number}
|
2016-07-06 13:57:58 -04:00
|
|
|
*/
|
2016-06-30 00:11:47 -04:00
|
|
|
Clone.prototype.size = 100;
|
|
|
|
|
2016-08-31 11:21:32 -04:00
|
|
|
/**
|
|
|
|
* Currently selected costume index.
|
|
|
|
* @type {number}
|
|
|
|
*/
|
|
|
|
Clone.prototype.currentCostume = 0;
|
|
|
|
|
2016-09-28 17:09:04 -04:00
|
|
|
/**
|
|
|
|
* Rotation style for "all around"/spinning.
|
|
|
|
* @enum
|
|
|
|
*/
|
|
|
|
Clone.ROTATION_STYLE_ALL_AROUND = 'all around';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Rotation style for "left-right"/flipping.
|
|
|
|
* @enum
|
|
|
|
*/
|
|
|
|
Clone.ROTATION_STYLE_LEFT_RIGHT = 'left-right';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Rotation style for "no rotation."
|
|
|
|
* @enum
|
|
|
|
*/
|
|
|
|
Clone.ROTATION_STYLE_NONE = 'don\'t rotate';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Current rotation style.
|
|
|
|
* @type {!string}
|
|
|
|
*/
|
|
|
|
Clone.prototype.rotationStyle = Clone.ROTATION_STYLE_ALL_AROUND;
|
|
|
|
|
2016-07-06 13:57:58 -04:00
|
|
|
/**
|
|
|
|
* Map of current graphic effect values.
|
|
|
|
* @type {!Object.<string, number>}
|
|
|
|
*/
|
2016-06-30 00:11:47 -04:00
|
|
|
Clone.prototype.effects = {
|
|
|
|
'color': 0,
|
|
|
|
'fisheye': 0,
|
|
|
|
'whirl': 0,
|
|
|
|
'pixelate': 0,
|
|
|
|
'mosaic': 0,
|
|
|
|
'brightness': 0,
|
|
|
|
'ghost': 0
|
|
|
|
};
|
2016-07-06 13:57:58 -04:00
|
|
|
// End clone-level properties.
|
2016-06-30 00:11:47 -04:00
|
|
|
|
2016-07-06 13:57:58 -04:00
|
|
|
/**
|
|
|
|
* Set the X and Y coordinates of a clone.
|
|
|
|
* @param {!number} x New X coordinate of clone, in Scratch coordinates.
|
|
|
|
* @param {!number} y New Y coordinate of clone, in Scratch coordinates.
|
|
|
|
*/
|
2016-06-29 20:56:55 -04:00
|
|
|
Clone.prototype.setXY = function (x, y) {
|
2016-09-08 09:40:27 -04:00
|
|
|
if (this.isStage) {
|
|
|
|
return;
|
|
|
|
}
|
2016-06-29 20:56:55 -04:00
|
|
|
this.x = x;
|
|
|
|
this.y = y;
|
2016-08-08 18:29:44 -04:00
|
|
|
if (this.renderer) {
|
|
|
|
this.renderer.updateDrawableProperties(this.drawableID, {
|
|
|
|
position: [this.x, this.y]
|
|
|
|
});
|
|
|
|
}
|
2016-06-29 20:56:55 -04:00
|
|
|
};
|
|
|
|
|
2016-09-28 17:09:04 -04:00
|
|
|
/**
|
|
|
|
* Get the rendered direction and scale, after applying rotation style.
|
|
|
|
* @return {Object<string, number>} Direction and scale to render.
|
|
|
|
*/
|
|
|
|
Clone.prototype._getRenderedDirectionAndScale = function () {
|
|
|
|
// Default: no changes to `this.direction` or `this.scale`.
|
|
|
|
var finalDirection = this.direction;
|
|
|
|
var finalScale = [this.size, this.size];
|
|
|
|
if (this.rotationStyle == Clone.ROTATION_STYLE_NONE) {
|
|
|
|
// Force rendered direction to be 90.
|
|
|
|
finalDirection = 90;
|
|
|
|
} else if (this.rotationStyle === Clone.ROTATION_STYLE_LEFT_RIGHT) {
|
|
|
|
// Force rendered direction to be 90, and flip drawable if needed.
|
|
|
|
finalDirection = 90;
|
|
|
|
var scaleFlip = (this.direction < 0) ? -1 : 1;
|
|
|
|
finalScale = [scaleFlip * this.size, this.size];
|
|
|
|
}
|
|
|
|
return {direction: finalDirection, scale: finalScale};
|
|
|
|
};
|
|
|
|
|
2016-07-06 13:57:58 -04:00
|
|
|
/**
|
|
|
|
* Set the direction of a clone.
|
|
|
|
* @param {!number} direction New direction of clone.
|
|
|
|
*/
|
2016-06-29 20:56:55 -04:00
|
|
|
Clone.prototype.setDirection = function (direction) {
|
2016-09-08 09:40:27 -04:00
|
|
|
if (this.isStage) {
|
|
|
|
return;
|
|
|
|
}
|
2016-07-06 13:57:58 -04:00
|
|
|
// Keep direction between -179 and +180.
|
2016-06-29 23:07:34 -04:00
|
|
|
this.direction = MathUtil.wrapClamp(direction, -179, 180);
|
2016-08-08 18:29:44 -04:00
|
|
|
if (this.renderer) {
|
2016-09-28 17:09:04 -04:00
|
|
|
var renderedDirectionScale = this._getRenderedDirectionAndScale();
|
2016-08-08 18:29:44 -04:00
|
|
|
this.renderer.updateDrawableProperties(this.drawableID, {
|
2016-09-28 17:09:04 -04:00
|
|
|
direction: renderedDirectionScale.direction,
|
|
|
|
scale: renderedDirectionScale.scale
|
2016-08-08 18:29:44 -04:00
|
|
|
});
|
|
|
|
}
|
2016-06-29 20:56:55 -04:00
|
|
|
};
|
|
|
|
|
2016-07-06 13:47:32 -04:00
|
|
|
/**
|
|
|
|
* Set a say bubble on this clone.
|
|
|
|
* @param {?string} type Type of say bubble: "say", "think", or null.
|
|
|
|
* @param {?string} message Message to put in say bubble.
|
|
|
|
*/
|
|
|
|
Clone.prototype.setSay = function (type, message) {
|
2016-09-08 09:40:27 -04:00
|
|
|
if (this.isStage) {
|
|
|
|
return;
|
|
|
|
}
|
2016-07-06 13:47:32 -04:00
|
|
|
// @todo: Render to stage.
|
|
|
|
if (!type || !message) {
|
|
|
|
console.log('Clearing say bubble');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
console.log('Setting say bubble:', type, message);
|
|
|
|
};
|
|
|
|
|
2016-07-06 13:57:58 -04:00
|
|
|
/**
|
|
|
|
* Set visibility of the clone; i.e., whether it's shown or hidden.
|
|
|
|
* @param {!boolean} visible True if the sprite should be shown.
|
|
|
|
*/
|
2016-07-01 12:56:59 -04:00
|
|
|
Clone.prototype.setVisible = function (visible) {
|
2016-09-08 09:40:27 -04:00
|
|
|
if (this.isStage) {
|
|
|
|
return;
|
|
|
|
}
|
2016-07-01 12:56:59 -04:00
|
|
|
this.visible = visible;
|
2016-08-08 18:29:44 -04:00
|
|
|
if (this.renderer) {
|
|
|
|
this.renderer.updateDrawableProperties(this.drawableID, {
|
|
|
|
visible: this.visible
|
|
|
|
});
|
|
|
|
}
|
2016-07-01 12:56:59 -04:00
|
|
|
};
|
|
|
|
|
2016-07-06 13:57:58 -04:00
|
|
|
/**
|
|
|
|
* Set size of the clone, as a percentage of the costume size.
|
|
|
|
* @param {!number} size Size of clone, from 5 to 535.
|
|
|
|
*/
|
2016-06-30 00:11:47 -04:00
|
|
|
Clone.prototype.setSize = function (size) {
|
2016-09-08 09:40:27 -04:00
|
|
|
if (this.isStage) {
|
|
|
|
return;
|
|
|
|
}
|
2016-07-06 13:57:58 -04:00
|
|
|
// Keep size between 5% and 535%.
|
2016-06-30 00:11:47 -04:00
|
|
|
this.size = MathUtil.clamp(size, 5, 535);
|
2016-08-08 18:29:44 -04:00
|
|
|
if (this.renderer) {
|
2016-09-28 17:09:04 -04:00
|
|
|
var renderedDirectionScale = this._getRenderedDirectionAndScale();
|
2016-08-08 18:29:44 -04:00
|
|
|
this.renderer.updateDrawableProperties(this.drawableID, {
|
2016-09-28 17:09:04 -04:00
|
|
|
direction: renderedDirectionScale.direction,
|
|
|
|
scale: renderedDirectionScale.scale
|
2016-08-08 18:29:44 -04:00
|
|
|
});
|
|
|
|
}
|
2016-06-30 00:11:47 -04:00
|
|
|
};
|
|
|
|
|
2016-07-06 13:57:58 -04:00
|
|
|
/**
|
|
|
|
* Set a particular graphic effect on this clone.
|
|
|
|
* @param {!string} effectName Name of effect (see `Clone.prototype.effects`).
|
|
|
|
* @param {!number} value Numerical magnitude of effect.
|
|
|
|
*/
|
2016-06-30 00:11:47 -04:00
|
|
|
Clone.prototype.setEffect = function (effectName, value) {
|
2016-09-12 13:14:16 -04:00
|
|
|
if (!this.effects.hasOwnProperty(effectName)) return;
|
2016-06-30 00:11:47 -04:00
|
|
|
this.effects[effectName] = value;
|
2016-08-08 18:29:44 -04:00
|
|
|
if (this.renderer) {
|
|
|
|
var props = {};
|
|
|
|
props[effectName] = this.effects[effectName];
|
|
|
|
this.renderer.updateDrawableProperties(this.drawableID, props);
|
|
|
|
}
|
2016-06-30 00:11:47 -04:00
|
|
|
};
|
|
|
|
|
2016-07-06 13:57:58 -04:00
|
|
|
/**
|
|
|
|
* Clear all graphic effects on this clone.
|
|
|
|
*/
|
2016-06-30 00:11:47 -04:00
|
|
|
Clone.prototype.clearEffects = function () {
|
|
|
|
for (var effectName in this.effects) {
|
|
|
|
this.effects[effectName] = 0;
|
|
|
|
}
|
2016-08-08 18:29:44 -04:00
|
|
|
if (this.renderer) {
|
|
|
|
this.renderer.updateDrawableProperties(this.drawableID, this.effects);
|
|
|
|
}
|
2016-06-30 00:11:47 -04:00
|
|
|
};
|
|
|
|
|
2016-08-31 11:21:32 -04:00
|
|
|
/**
|
|
|
|
* Set the current costume of this clone.
|
|
|
|
* @param {number} index New index of costume.
|
|
|
|
*/
|
|
|
|
Clone.prototype.setCostume = function (index) {
|
2016-09-08 09:40:27 -04:00
|
|
|
// Keep the costume index within possible values.
|
2016-09-28 16:43:12 -04:00
|
|
|
index = Math.round(index);
|
2016-09-08 09:40:27 -04:00
|
|
|
this.currentCostume = MathUtil.wrapClamp(
|
|
|
|
index, 0, this.sprite.costumes.length - 1
|
|
|
|
);
|
2016-08-31 11:21:32 -04:00
|
|
|
if (this.renderer) {
|
|
|
|
this.renderer.updateDrawableProperties(this.drawableID, {
|
2016-08-31 11:30:09 -04:00
|
|
|
skin: this.sprite.costumes[this.currentCostume].skin
|
2016-08-31 11:21:32 -04:00
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2016-09-28 17:09:04 -04:00
|
|
|
/**
|
|
|
|
* Update the rotation style for this clone.
|
|
|
|
* @param {!string} rotationStyle New rotation style.
|
|
|
|
*/
|
|
|
|
Clone.prototype.setRotationStyle = function (rotationStyle) {
|
|
|
|
if (rotationStyle == Clone.ROTATION_STYLE_NONE) {
|
|
|
|
this.rotationStyle = Clone.ROTATION_STYLE_NONE;
|
|
|
|
} else if (rotationStyle == Clone.ROTATION_STYLE_ALL_AROUND) {
|
|
|
|
this.rotationStyle = Clone.ROTATION_STYLE_ALL_AROUND;
|
|
|
|
} else if (rotationStyle == Clone.ROTATION_STYLE_LEFT_RIGHT) {
|
|
|
|
this.rotationStyle = Clone.ROTATION_STYLE_LEFT_RIGHT;
|
|
|
|
}
|
|
|
|
if (this.renderer) {
|
|
|
|
var renderedDirectionScale = this._getRenderedDirectionAndScale();
|
|
|
|
this.renderer.updateDrawableProperties(this.drawableID, {
|
|
|
|
direction: renderedDirectionScale.direction,
|
|
|
|
scale: renderedDirectionScale.scale
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2016-09-08 09:40:27 -04:00
|
|
|
/**
|
|
|
|
* Get a costume index of this clone, by name of the costume.
|
|
|
|
* @param {?string} costumeName Name of a costume.
|
|
|
|
* @return {number} Index of the named costume, or -1 if not present.
|
|
|
|
*/
|
|
|
|
Clone.prototype.getCostumeIndexByName = function (costumeName) {
|
|
|
|
for (var i = 0; i < this.sprite.costumes.length; i++) {
|
|
|
|
if (this.sprite.costumes[i].name == costumeName) {
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
};
|
|
|
|
|
2016-08-31 11:21:32 -04:00
|
|
|
/**
|
|
|
|
* Update all drawable properties for this clone.
|
|
|
|
* Use when a batch has changed, e.g., when the drawable is first created.
|
|
|
|
*/
|
|
|
|
Clone.prototype.updateAllDrawableProperties = function () {
|
|
|
|
if (this.renderer) {
|
2016-09-28 17:09:04 -04:00
|
|
|
var renderedDirectionScale = this._getRenderedDirectionAndScale();
|
2016-08-31 11:21:32 -04:00
|
|
|
this.renderer.updateDrawableProperties(this.drawableID, {
|
|
|
|
position: [this.x, this.y],
|
2016-09-28 17:09:04 -04:00
|
|
|
direction: renderedDirectionScale.direction,
|
|
|
|
scale: renderedDirectionScale.scale,
|
2016-08-31 11:21:32 -04:00
|
|
|
visible: this.visible,
|
2016-08-31 11:30:09 -04:00
|
|
|
skin: this.sprite.costumes[this.currentCostume].skin
|
2016-08-31 11:21:32 -04:00
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2016-08-31 11:50:10 -04:00
|
|
|
/**
|
|
|
|
* Return the human-readable name for this clone, i.e., the sprite's name.
|
|
|
|
* @override
|
|
|
|
* @returns {string} Human-readable name for the clone.
|
|
|
|
*/
|
|
|
|
Clone.prototype.getName = function () {
|
|
|
|
return this.sprite.name;
|
|
|
|
};
|
|
|
|
|
2016-09-12 10:58:50 -04:00
|
|
|
/**
|
|
|
|
* Return whether the clone is touching a color.
|
|
|
|
* @param {Array.<number>} rgb [r,g,b], values between 0-255.
|
|
|
|
* @return {Promise.<Boolean>} True iff the clone is touching the color.
|
|
|
|
*/
|
|
|
|
Clone.prototype.isTouchingColor = function (rgb) {
|
|
|
|
if (this.renderer) {
|
|
|
|
return this.renderer.isTouchingColor(this.drawableID, rgb);
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return whether the clone's color is touching a color.
|
|
|
|
* @param {Object} targetRgb {Array.<number>} [r,g,b], values between 0-255.
|
|
|
|
* @param {Object} maskRgb {Array.<number>} [r,g,b], values between 0-255.
|
|
|
|
* @return {Promise.<Boolean>} True iff the clone's color is touching the color.
|
|
|
|
*/
|
|
|
|
Clone.prototype.colorIsTouchingColor = function (targetRgb, maskRgb) {
|
|
|
|
if (this.renderer) {
|
|
|
|
return this.renderer.isTouchingColor(
|
|
|
|
this.drawableID,
|
|
|
|
targetRgb,
|
|
|
|
maskRgb
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
};
|
|
|
|
|
2016-09-15 19:37:12 -04:00
|
|
|
/**
|
|
|
|
* Make a clone of this clone, copying any run-time properties.
|
|
|
|
* If we've hit the global clone limit, returns null.
|
|
|
|
* @return {!Clone} New clone object.
|
|
|
|
*/
|
|
|
|
Clone.prototype.makeClone = function () {
|
|
|
|
if (!this.runtime.clonesAvailable()) {
|
|
|
|
return; // Hit max clone limit.
|
|
|
|
}
|
|
|
|
this.runtime.changeCloneCounter(1);
|
|
|
|
var newClone = this.sprite.createClone();
|
|
|
|
newClone.x = this.x;
|
|
|
|
newClone.y = this.y;
|
|
|
|
newClone.direction = this.direction;
|
|
|
|
newClone.visible = this.visible;
|
|
|
|
newClone.size = this.size;
|
|
|
|
newClone.currentCostume = this.currentCostume;
|
2016-09-28 17:09:04 -04:00
|
|
|
newClone.rotationStyle = this.rotationStyle;
|
2016-09-15 19:37:12 -04:00
|
|
|
newClone.effects = JSON.parse(JSON.stringify(this.effects));
|
2016-09-21 16:38:33 -04:00
|
|
|
newClone.variables = JSON.parse(JSON.stringify(this.variables));
|
|
|
|
newClone.lists = JSON.parse(JSON.stringify(this.lists));
|
2016-09-15 19:37:12 -04:00
|
|
|
newClone.initDrawable();
|
|
|
|
newClone.updateAllDrawableProperties();
|
|
|
|
return newClone;
|
|
|
|
};
|
|
|
|
|
2016-09-21 16:31:07 -04:00
|
|
|
/**
|
|
|
|
* Called when the project receives a "green flag."
|
|
|
|
* For a clone, this clears graphic effects.
|
|
|
|
*/
|
|
|
|
Clone.prototype.onGreenFlag = function () {
|
|
|
|
this.clearEffects();
|
|
|
|
};
|
|
|
|
|
2016-09-15 19:37:12 -04:00
|
|
|
/**
|
|
|
|
* Dispose of this clone, destroying any run-time properties.
|
|
|
|
*/
|
|
|
|
Clone.prototype.dispose = function () {
|
|
|
|
if (this.isOriginal) { // Don't allow a non-clone to delete itself.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
this.runtime.changeCloneCounter(-1);
|
|
|
|
if (this.renderer && this.drawableID !== null) {
|
|
|
|
this.renderer.destroyDrawable(this.drawableID);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2016-06-29 13:48:30 -04:00
|
|
|
module.exports = Clone;
|