import { PluginPureHook } from '@gedit/runtime-compiler'; import { DragonBonesGameObject } from '@gedit/runtime-render'; import { addGameObjectToMap, parseQuery, code } from '../common'; import { attachCollisionBody } from './collision-body'; import { transform, filterOrigin } from './transform'; import { LocalComponent } from './utils'; export interface DragonBonesParams { skeletonName: string; } export interface DragonBonesSkeletons { skeletons: { name: string; width: number; height: number; }[]; } export function dragonbones( ctx: PluginPureHook, component: DragonBonesGameObject ): void { const { dragonbones: data, name, displayType } = component; const { texture, params } = parseQuery(data.texture); const playTimes = data.animationLoop ? 0 : 1; const blk = new LocalComponent(ctx); ctx.comment(`@type ${displayType}\n@name ${name}`); blk.in(); ctx.println(`${code.create(component)}('${params.skeletonName}', '${texture}');`); addGameObjectToMap(ctx, component); attachCollisionBody(ctx, component); transform(ctx, component, true, filterOrigin); ctx.println(' .animation'); ctx.println(` .play('${data.animationName}', ${playTimes})`); blk.out(); }