mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-23 06:23:37 -05:00
Fix up property imports from SB2 (#196)
* Update target's drawable properties after SB2 import * Always use `hasOwnProperty` parsing SB2 JSON
This commit is contained in:
parent
470f686662
commit
13f287e871
1 changed files with 8 additions and 7 deletions
|
@ -51,7 +51,7 @@ function parseScratchObject (object, runtime, topLevel) {
|
|||
var costume = object.costumes[i];
|
||||
// @todo: Make sure all the relevant metadata is being pulled out.
|
||||
sprite.costumes.push({
|
||||
skin: 'https://cdn.assets.scratch.mit.edu/internalapi/asset/'
|
||||
skin: 'https://cdn.assets.scratch.mit.edu/internalapi/asset/'
|
||||
+ costume.baseLayerMD5 + '/get/',
|
||||
name: costume.costumeName,
|
||||
bitmapResolution: costume.bitmapResolution,
|
||||
|
@ -68,26 +68,27 @@ function parseScratchObject (object, runtime, topLevel) {
|
|||
var target = sprite.createClone();
|
||||
// Add it to the runtime's list of targets.
|
||||
runtime.targets.push(target);
|
||||
if (object.scratchX) {
|
||||
if (object.hasOwnProperty('scratchX')) {
|
||||
target.x = object.scratchX;
|
||||
}
|
||||
if (object.scratchY) {
|
||||
if (object.hasOwnProperty('scratchY')) {
|
||||
target.y = object.scratchY;
|
||||
}
|
||||
if (object.direction) {
|
||||
if (object.hasOwnProperty('direction')) {
|
||||
target.direction = object.direction;
|
||||
}
|
||||
if (object.scale) {
|
||||
if (object.hasOwnProperty('scale')) {
|
||||
// SB2 stores as 1.0 = 100%; we use % in the VM.
|
||||
target.size = object.scale * 100;
|
||||
}
|
||||
if (object.visible) {
|
||||
if (object.hasOwnProperty('visible')) {
|
||||
target.visible = object.visible;
|
||||
}
|
||||
if (object.currentCostumeIndex) {
|
||||
if (object.hasOwnProperty('currentCostumeIndex')) {
|
||||
target.currentCostume = object.currentCostumeIndex;
|
||||
}
|
||||
target.isStage = topLevel;
|
||||
target.updateAllDrawableProperties();
|
||||
// The stage will have child objects; recursively process them.
|
||||
if (object.children) {
|
||||
for (var j = 0; j < object.children.length; j++) {
|
||||
|
|
Loading…
Reference in a new issue