src/virtual-machine.js
/**
     * Add a single sprite from the "Sprite2" (i.e., SB2 sprite) format.
     * @param {string} json JSON string representing the sprite.
     * @returns {Promise} Promise that resolves after the sprite is added
     */
Add a single sprite from the "Sprite2"  format.
@param {string} json JSON string representing the sprite.
@returns {Promise} Promise that resolves after the sprite is added
Add a single sprite from the " Sprite2 " format . @param { string } json JSON string representing the sprite . @returns { Promise } Promise that resolves after the sprite is added
addSprite2 (json) {
        if (typeof json !== 'string') {
            log.error('Failed to parse sprite. Non-string supplied to addSprite2.');
            return;
        }
        json = JSON.parse(json);
        if (typeof json !== 'object') {
            log.error('Failed to parse sprite. JSON supplied to addSprite2 is not an object.');
            return;
        }
        return sb2.deserialize(json, this.runtime, true)
            .then(({targets, extensions}) =>
                this.installTargets(targets, extensions, false));
    }
addSprite2 ( json ) { if ( typeof json !== 'string' ) { log . error ( 'Failed to parse sprite. Non-string supplied to addSprite2.' ) ; return ; } json = JSON . parse ( json ) ; if ( typeof json !== 'object' ) { log . error ( 'Failed to parse sprite. JSON supplied to addSprite2 is not an object.' ) ; return ; } return sb2 . deserialize ( json , this . runtime , true ) . then ( ( { targets , extensions } ) => this . installTargets ( targets , extensions , false ) ) ; }
Add a single sprite from the "Sprite2" (i.e., SB2 sprite) format.
Add a single sprite from the " Sprite2 " ( i . e . SB2 sprite ) format .
// Validate & parse