fix : graphic类别问题

This commit is contained in:
草莓 2025-01-12 12:53:32 +08:00
parent 2a03d7c98d
commit ba1e7ea228
2 changed files with 14 additions and 18 deletions

View File

@ -196,11 +196,11 @@ export abstract class GraphicItemBase
if (isNil(prevValue) && isNil(nextValue)) return; if (isNil(prevValue) && isNil(nextValue)) return;
switch (key) { switch (key) {
case 'fill': case 'fill':
if (!this.assertType(nextValue, 'number', key)) return; if (!this.assertType(nextValue, 'boolean', key)) return;
this.checkMode(GraphicModeProp.Fill, nextValue); this.checkMode(GraphicModeProp.Fill, nextValue);
break; break;
case 'stroke': case 'stroke':
if (!this.assertType(nextValue, 'number', key)) return; if (!this.assertType(nextValue, 'boolean', key)) return;
this.checkMode(GraphicModeProp.Stroke, nextValue); this.checkMode(GraphicModeProp.Stroke, nextValue);
break; break;
case 'strokeAndFill': case 'strokeAndFill':

View File

@ -217,9 +217,9 @@ export class Icon extends RenderItem<EIconEvent> implements IAnimateFrame {
/** 图标id */ /** 图标id */
icon: AllNumbers = 0; icon: AllNumbers = 0;
/** 帧数 */ /** 帧数 */
frame: number = 0; frame?: number = 0;
/** 是否启用动画 */ /** 是否启用动画 */
animate: boolean = false; animate?: boolean = false;
/** 图标的渲染信息 */ /** 图标的渲染信息 */
private renderable?: RenderableData | AutotileRenderable; private renderable?: RenderableData | AutotileRenderable;
@ -245,21 +245,13 @@ export class Icon extends RenderItem<EIconEvent> implements IAnimateFrame {
} else { } else {
const [x1, y1, w1, h1] = renderable.render[frame]; const [x1, y1, w1, h1] = renderable.render[frame];
if (renderable.autotile) { if (renderable.autotile) {
ctx.drawImage( const img = renderable.image[0];
renderable.image[0], ctx.drawImage(img, x1, y1, w1, h1, 0, 0, cw, ch);
x1,
y1,
w1,
h1,
0,
0,
cw,
ch
);
} else { } else {
ctx.drawImage(renderable.image, x1, y1, w1, h1, 0, 0, cw, ch); ctx.drawImage(renderable.image, x1, y1, w1, h1, 0, 0, cw, ch);
} }
this.update(this), renderEmits.addFramer(this); this.update(this);
renderEmits.addFramer(this);
} }
} }
@ -276,13 +268,17 @@ export class Icon extends RenderItem<EIconEvent> implements IAnimateFrame {
return; return;
} else { } else {
this.icon = num; this.icon = num;
renderable.animate = 0;
this.renderable = renderable;
this.frame = renderable.frame; this.frame = renderable.frame;
} }
this.update(); this.update();
} }
destroy(): void {
renderEmits.removeFramer(this);
super.destroy();
}
/** /**
* *
*/ */