2016-06-29 13:48:30 -04:00
|
|
|
var Blocks = require('./blocks');
|
2016-08-31 11:39:57 -04:00
|
|
|
var uid = require('../util/uid');
|
2016-06-29 13:48:30 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @fileoverview
|
|
|
|
* A Target is an abstract "code-running" object for the Scratch VM.
|
|
|
|
* Examples include sprites/clones or potentially physical-world devices.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param {?Blocks} blocks Blocks instance for the blocks owned by this target.
|
|
|
|
* @constructor
|
|
|
|
*/
|
|
|
|
function Target (blocks) {
|
|
|
|
if (!blocks) {
|
|
|
|
blocks = new Blocks(this);
|
|
|
|
}
|
2016-08-31 11:39:57 -04:00
|
|
|
/**
|
|
|
|
* A unique ID for this target.
|
|
|
|
* @type {string}
|
|
|
|
*/
|
|
|
|
this.id = uid();
|
|
|
|
/**
|
|
|
|
* Blocks run as code for this target.
|
|
|
|
* @type {!Blocks}
|
|
|
|
*/
|
2016-06-29 13:48:30 -04:00
|
|
|
this.blocks = blocks;
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = Target;
|