Bubbles should be in the same layer as sprites. Other cleanup.

This commit is contained in:
Karishma Chadha 2018-05-20 19:49:42 -04:00
parent 64c8484066
commit 38875bc65c
3 changed files with 11 additions and 12 deletions

View file

@ -92,7 +92,7 @@ class Scratch3LooksBlocks {
_onTargetWillExit (target) {
const bubbleState = this._getBubbleState(target);
if (bubbleState.drawableId && bubbleState.skinId) {
this.runtime.renderer.destroyDrawable(bubbleState.drawableId, StageLayering.BUBBLE_LAYER);
this.runtime.renderer.destroyDrawable(bubbleState.drawableId, StageLayering.SPRITE_LAYER);
this.runtime.renderer.destroySkin(bubbleState.skinId);
bubbleState.drawableId = null;
bubbleState.skinId = null;
@ -196,7 +196,7 @@ class Scratch3LooksBlocks {
bubbleState.onSpriteRight = false;
}
bubbleState.drawableId = this.runtime.renderer.createDrawable(StageLayering.BUBBLE_LAYER);
bubbleState.drawableId = this.runtime.renderer.createDrawable(StageLayering.SPRITE_LAYER);
bubbleState.skinId = this.runtime.renderer.createTextSkin(type, text, bubbleState.onSpriteRight, [0, 0]);
this.runtime.renderer.updateDrawableProperties(bubbleState.drawableId, {

View file

@ -50,12 +50,7 @@ class StageLayering {
{
group: StageLayering.SPRITE_LAYER,
explicitOrdering: false
},
{
group: StageLayering.BUBBLE_LAYER,
explicitOrdering: false
}
];
}
}

View file

@ -847,9 +847,11 @@ class RenderedTarget extends Target {
*/
goBehindOther (other) {
if (this.renderer) {
const otherLayer = this.renderer.setDrawableOrder(
other.drawableID, 0, StageLayering.SPRITE_LAYER, true);
this.renderer.setDrawableOrder(this.drawableID, otherLayer, StageLayering.SPRITE_LAYER);
this.renderer.positionDrawableRelativeToOther(
this.drawableID, other.drawableID, -1, StageLayering.SPRITE_LAYER);
// const otherLayer = this.renderer.setDrawableOrder(
// other.drawableID, 0, StageLayering.SPRITE_LAYER, true);
// this.renderer.setDrawableOrder(this.drawableID, otherLayer, StageLayering.SPRITE_LAYER);
}
}
@ -918,7 +920,7 @@ class RenderedTarget extends Target {
newClone.effects = JSON.parse(JSON.stringify(this.effects));
newClone.variables = JSON.parse(JSON.stringify(this.variables));
newClone.lists = JSON.parse(JSON.stringify(this.lists));
newClone.initDrawable(StageLayering.SPRITE_LAYER); // TODO should sprite clones be in their own layer group?
newClone.initDrawable(StageLayering.SPRITE_LAYER);
newClone.updateAllDrawableProperties();
// Place behind the current target.
newClone.goBehindOther(this);
@ -1055,7 +1057,9 @@ class RenderedTarget extends Target {
this.runtime.stopForTarget(this);
this.sprite.removeClone(this);
if (this.renderer && this.drawableID !== null) {
this.renderer.destroyDrawable(this.drawableID, StageLayering.SPRITE_LAYER);
this.renderer.destroyDrawable(this.drawableID, this.isStage ?
StageLayering.BACKGROUND_LAYER :
StageLayering.SPRITE_LAYER);
if (this.visible) {
this.emit(RenderedTarget.EVENT_TARGET_VISUAL_CHANGE, this);
this.runtime.requestRedraw();