From fc3a8fb81fd0bcec9e1686a55b8458d11ed7fc3e Mon Sep 17 00:00:00 2001 From: unanmed <1319491857@qq.com> Date: Thu, 26 Dec 2024 21:51:39 +0800 Subject: [PATCH] refactor: delete pop.ts --- src/game/system.ts | 1 - src/plugin/index.ts | 2 -- src/plugin/pop.ts | 60 --------------------------------------------- 3 files changed, 63 deletions(-) delete mode 100644 src/plugin/pop.ts diff --git a/src/game/system.ts b/src/game/system.ts index 7620022..3b5f352 100644 --- a/src/game/system.ts +++ b/src/game/system.ts @@ -157,7 +157,6 @@ type InterfaceType = keyof SystemInterfaceMap; interface PluginInterface { // 渲染进程定义的插件 - pop_r: typeof import('../plugin/pop'); use_r: typeof import('../plugin/use'); fly_r: typeof import('../plugin/ui/fly'); chase_r: typeof import('../plugin/chase'); diff --git a/src/plugin/index.ts b/src/plugin/index.ts index d5185bc..62844e1 100644 --- a/src/plugin/index.ts +++ b/src/plugin/index.ts @@ -1,7 +1,6 @@ import * as fly from './ui/fly'; import * as chase from './chase'; import * as completion from './completion'; -import * as pop from './pop'; import * as use from './use'; import * as gameCanvas from './fx/gameCanvas'; import * as animateController from './animateController'; @@ -13,7 +12,6 @@ import './loopMap'; Mota.Plugin.register('fly_r', fly); Mota.Plugin.register('chase_r', chase); Mota.Plugin.register('completion_r', completion, completion.init); -Mota.Plugin.register('pop_r', pop, pop.init); Mota.Plugin.register('use_r', use); Mota.Plugin.register('gameCanvas_r', gameCanvas); Mota.Plugin.register( diff --git a/src/plugin/pop.ts b/src/plugin/pop.ts deleted file mode 100644 index 3f9f465..0000000 --- a/src/plugin/pop.ts +++ /dev/null @@ -1,60 +0,0 @@ -// 示例插件:文字弹出 -// todo: 重写 - -let pop: any[] = []; - -let time = 0; - -export function init() { - // core.registerAnimationFrame('pop', true, popValue); -} - -/** - * 弹出文字 - */ -function popValue(t: number) { - if (t - time < 15) return; - let ctx = core.getContextByName('pop')!; - if (!ctx) ctx = core.createCanvas('pop', 0, 0, core._PX_, core._PY_, 90); - core.clearMap(ctx); - let count = 0; - pop.forEach(function (one) { - // 由frame计算出dy - const dy = 6 - one.frame * 0.2; - const dx = 1; - one.py -= dy; - one.px += dx; - one.frame++; - // 绘制 - if (one.frame >= 60) core.setAlpha(ctx, 3 - one.frame / 30); - else core.setAlpha(ctx, 1); - core.fillBoldText( - ctx, - one.value, - one.px, - one.py, - '#f22', - '#000', - '24px normal' - ); - if (one.frame >= 90) count++; - }); - if (count > 0) pop.splice(0, count); - time = t; -} - -/** - * 添加弹出文字 - * @param px 弹出的横坐标 - * @param py 弹出的纵坐标 - * @param value 弹出的文字 - */ -export function addPop(px: number, py: number, value: string) { - var data = { - px: px, - py: py, - value: value, - frame: 0 - }; - pop.push(data); -}