Commit 7d469bcf authored by wjf's avatar wjf

l

parent 1fb8bca2
import { Pool } from "../Pool";
import { RecoverName } from "../enum/RecoverName";
//70是chocolateFour的尺寸,偷懒,固定了
var x1 = 70 / 4 - 70 / 2;
var x2 = 70 / 4 * 3 - 70 / 2;
var y1 = 70 / 4 - 70 / 2;
var y2 = 70 / 4 * 3 - 70 / 2;
var dis1 = 20;
var dis2 = 40;
const fourPositions: number[][] = [
[x1, y1],
[x2, y1],
[x1, y2],
[x2, y2]
]
const f1: number[][] = [
[x1 - dis1, y1 - dis1],
[x2 + dis1, y1 - dis1],
[x1 - dis1, y2 + dis1],
[x2 + dis1, y2 + dis1]
]
const f2: number[][] = [
[x1 - dis2, y1 - dis2],
[x2 + dis2, y1 - dis2],
[x1 - dis2, y2 + dis2],
[x2 + dis2, y2 + dis2]
]
/**
* 巧克力分裂动效
*/
export class ChocolateDivideAni extends egret.DisplayObjectContainer {
constructor() {
super()
for (var i = 0; i < 4; i++) {
var t: egret.Texture = RES.getRes("chocolate" + i + "_png");
var b = new egret.Bitmap(t);
b.anchorOffsetX = t.textureWidth / 2;
b.anchorOffsetY = t.textureHeight / 2;
b.scaleX = 32 / t.textureWidth;//32是缩小的尺寸
b.scaleY = 32 / t.textureHeight;
b.x = fourPositions[i][0];
b.y = fourPositions[i][1];
this.addChild(b);
this["chocolate" + i] = b;
}
}
play(p: number[]) {
this.x = p[0];
this.y = p[1];
//重置位置和透明度
for (var i = 0; i < 4; i++) {
let ii = i;
let chocolate: egret.Bitmap = this["chocolate" + i];
chocolate.x = fourPositions[i][0];
chocolate.y = fourPositions[i][1];
chocolate.scaleX = chocolate.scaleY = 32 / 70
chocolate.alpha = 1;
egret.Tween.get(chocolate)
.wait(100)
.to({ x: f1[ii][0], y: f1[ii][1], scaleX: 40 / 70, scaleY: 40 / 70 }, 300)
.wait(100)
.to({ x: f2[ii][0], y: f2[ii][1], alpha: 0 }, 300)
.call(() => {
if (ii == 3) {
//回收元素
if (this.parent) this.parent.removeChild(this);
Pool.recover(RecoverName.CHOCOLATEDIVIDE_ANI, this)
}
})
}
}
}
\ No newline at end of file
...@@ -57,6 +57,7 @@ export enum RecoverName { ...@@ -57,6 +57,7 @@ export enum RecoverName {
EGGBROKEN_ANI = "EggBrokenAni", EGGBROKEN_ANI = "EggBrokenAni",
HAIRBALLGREYDIS_ANI = "HairballGreyDisAni", HAIRBALLGREYDIS_ANI = "HairballGreyDisAni",
HAIRBALLBLACKDIS_ANI = "HairballBlackDisAni", HAIRBALLBLACKDIS_ANI = "HairballBlackDisAni",
CHOCOLATEDIVIDE_ANI = "ChocolateDivideAni",
//方形遮罩 //方形遮罩
RECT_MASK = "RectMask", RECT_MASK = "RectMask",
......
...@@ -21,6 +21,7 @@ import { FesRedShootAni2 } from "../anisCall/FesRedShootAni2"; ...@@ -21,6 +21,7 @@ import { FesRedShootAni2 } from "../anisCall/FesRedShootAni2";
import { loadSvga } from "../../loadSvga"; import { loadSvga } from "../../loadSvga";
import getResPath from "../../../libs/new_tc/getResPath"; import getResPath from "../../../libs/new_tc/getResPath";
import SceneCtrl from "../../../libs/new_wx/ctrls/sceneCtrl"; import SceneCtrl from "../../../libs/new_wx/ctrls/sceneCtrl";
import { ChocolateDivideAni } from "../anis/ChocolateDivideAni";
//孵鸡的数量 //孵鸡的数量
const chickenNum: number = 4; const chickenNum: number = 4;
...@@ -141,7 +142,7 @@ export class AiControl { ...@@ -141,7 +142,7 @@ export class AiControl {
} }
//变成对象 //变成对象
for (var i = 0; i < six.length; i++) six[i] = { index: six[i] }; for (var i = 0; i < six.length; i++) six[i] = { index: six[i] };
//暂时只有一个大红包, //暂时只有一个大红包,如出现多个,需改逻辑
let index = indexs[0]; let index = indexs[0];
var p = Tool.getPositionByIndex(index); var p = Tool.getPositionByIndex(index);
var vec0 = [1, 0]; var vec0 = [1, 0];
...@@ -161,10 +162,12 @@ export class AiControl { ...@@ -161,10 +162,12 @@ export class AiControl {
six.sort(function (a, b) { return b.rotation - a.rotation }); six.sort(function (a, b) { return b.rotation - a.rotation });
//还原为索引 //还原为索引
for (var i = 0; i < six.length; i++) six[i] = six[i].index; for (var i = 0; i < six.length; i++) six[i] = six[i].index;
//动画 //先去掉元素,再加分裂动画
thisObj.removeOperation(index);
//巧克力分裂效果,
thisObj.addChild(Pool.takeOut(RecoverName.CHOCOLATEDIVIDE_ANI) || new ChocolateDivideAni())["play"](p);
//光效动画
thisObj.redBombLightAni(index, () => { thisObj.redBombLightAni(index, () => {
//巧克力分裂效果,先去掉元素,再加动画
let count = 0; let count = 0;
let countAll = six.length; let countAll = six.length;
for (let a = 0; a < six.length; a++) { for (let a = 0; a < six.length; a++) {
...@@ -179,8 +182,8 @@ export class AiControl { ...@@ -179,8 +182,8 @@ export class AiControl {
thisObj.addChild(fesRedShootAni); thisObj.addChild(fesRedShootAni);
fesRedShootAni.play(p, ele, () => { fesRedShootAni.play(p, ele, () => {
if (++count == countAll) { if (++count == countAll) {
//去掉大红包 //去掉大红包,改成上面去掉了
thisObj.removeOperation(index); // thisObj.removeOperation(index);
//进行掉落 //进行掉落
thisObj.fall(() => { thisObj.fall(() => {
thisObj.fallCallback(); thisObj.fallCallback();
......
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