Commit 91a00c20 authored by wildfirecode's avatar wildfirecode

1

parent 8c2c1061
......@@ -20,7 +20,7 @@ export default async (thisObj: MainScene) => {
//map promise
//先判断是否能跳动,目前都能跳
const promiseList: Promise<any>[] = [];
const sands = [];
// const sands = [];
for (let i = 0; i < sandLattices.length; i++) {
const sandLattice = sandLattices[i];
const indexEnd = judgeActionIndex(sandLattice.index, thisObj.lattices)
......@@ -41,13 +41,13 @@ export default async (thisObj: MainScene) => {
if (!sandMoveAni) {
sandMoveAni = new SandMoveAni();
}
thisObj.addChild(sandMoveAni);
promiseList.push(sandMoveAni.play([sand.x, sand.y], p));
sands.push(sand);
thisObj.map.addChild(sandMoveAni);
promiseList.push(sandMoveAni.play(from, p,sand));
// sands.push(sand);
}
}
await Promise.all(promiseList);
sands.forEach(e => e.visible = true);
// sands.forEach(e => e.visible = true);
}
//找到毛球移动的目标位置
......
......@@ -3,6 +3,7 @@ import { loadSvga } from "../loadSvga";
export default class Sand extends egret.Sprite {
mc;
constructor() {
super();
this.initSvga();
......@@ -13,6 +14,7 @@ export default class Sand extends egret.Sprite {
movieclip.anchorOffsetX = 78 / 2;
movieclip.anchorOffsetY = 78 / 2;
this.addChild(movieclip);
this.mc=movieclip;
}
}
......
......@@ -13,13 +13,20 @@ export const monstShootAniDur: number = 400;
export class SandMoveAni extends egret.DisplayObjectContainer {
fromContainer;
toContainer;
moveMc: any;
constructor() {
super()
}
async initMc(from: number[], to: number[]) {
const fromContainer = await this.createContainer();
this.moveMc = await loadSvga(getResPath() + 'resource/assets/svgas/sand_move.svga');
this.moveMc.anchorOffsetX = 200 / 2;
this.moveMc.anchorOffsetY = 100 / 2;
this.moveMc.x = (from[0] + to[0]) / 2;
this.moveMc.y = (from[1] + to[1]) / 2;
this.addChild(this.moveMc);
const fromContainer = await this.createContainer(1);
fromContainer.x = from[0];
fromContainer.y = from[1];
this.fromContainer = fromContainer;
......@@ -31,39 +38,86 @@ export class SandMoveAni extends egret.DisplayObjectContainer {
this.addChild(this.fromContainer);
this.addChild(this.toContainer);
this.fromMask.anchorOffsetY = 78;
this.fromMask.y = 78;
this.toMask.anchorOffsetY = 78;
this.toMask.y = 78;
this.fromMask.scaleY = 1;
this.toMask.scaleY = 0;
this.setMove(from, to);
}
private setMove(from, to) {
const [fromX, fromY] = from;
const [toX, toY] = to;
if (fromX - toX == 0) {//竖向
if (toY < fromY)
this.moveMc.rotation = 90;//上
else
this.moveMc.rotation = -90;//下
} else {//横向
if (toX < fromX)
this.moveMc.rotation = 0
else
this.moveMc.rotation = 180;
}
//向上
//向下
//向左
//向右
}
private reset(from: number[], to: number[]) {
this.moveMc.x = (from[0] + to[0]) / 2;
this.moveMc.y = (from[1] + to[1]) / 2;
this.fromContainer.x = from[0];
this.fromContainer.y = from[1];
this.toContainer.x = to[0];
this.toContainer.y = to[1];
this.fromMask.scaleY = 1;
this.toMask.scaleY = 0;
this.setMove(from, to);
}
async play(from: number[], to: number[]) {
async play(from: number[], to: number[], sand) {
if (!this.fromContainer) {
await this.initMc(from, to);
} else {
this.reset(from, to);
}
await wait(5000);
this.moveMc.gotoAndPlay(1);
await (new Promise((r) => {
const dur = 1000;
egret.Tween.get(this.fromMask).to({ scaleY: 0 }, dur);
egret.Tween.get(this.toMask).to({ scaleY: 1 }, dur).call(r);
}));
sand.visible = true;
this.parent && this.parent.removeChild(this);
Pool.recover(RecoverName.SAND_MOVE_ANI, this);
return null;
}
private async createContainer() {
fromMask: egret.Shape;
toMask: egret.Shape;
private async createContainer(isfrom = 0) {
const container = new egret.Sprite();
const rect = this.createRect();
const rect = this.createRect(isfrom);
const mc = await this.createMc();
container.addChild(mc);
container.addChild(rect);
mc.mask = rect;
return mc;
if (isfrom)
this.fromMask = rect;
else
this.toMask = rect;
return container;
}
private createRect() {
private createRect(isfrom) {
const rect = new egret.Shape();
rect.graphics.beginFill(0, 1);
const r = 80;
......
......@@ -236,6 +236,7 @@ export const submitTran = {
25: 14,
26: 15,
34: 16,
36: 17,
}
// SCORE(1, "分数"),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment