refactor: delete pop.ts

This commit is contained in:
AncTe committed 2024-12-26 21:51:39 +08:00
1 parent 4102893916
commit fc3a8fb81f
3 files changed
-63

No files matched your search

-2
View File
@@ -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(
-60
View File
@@ -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);
}