Commit 260191a8 authored by wjf's avatar wjf

l

parent 163b615b
......@@ -3125,9 +3125,9 @@ export default class MainScene extends Scene {
}, 56 / 60 * 1000)
}
//时间再调cd
// setTimeout(() => {
setTimeout(() => {
callback();
// }, 80)
}, 400)
}
/**
......
......@@ -27,7 +27,7 @@ export default class RedBagAni {
let iconCount:number=0;
export const createRedBagIcon = (parent)=>{
// const icon = RES.getRes('mapredbagicom_png'); /// TODO 洒出的图片
const icon:egret.Texture=RES.getRes('chocolate'+(iconCount++%4)+"_png");
const icon:egret.Texture=RES.getRes('chocolate'+(iconCount++%4)+'_png');
const bmp = new egret.Bitmap(icon);
bmp.anchorOffsetX=icon.textureWidth/2//32;
bmp.anchorOffsetY=icon.textureHeight/2//33;
......
......@@ -66,7 +66,7 @@ export function MagicRotateAni(ele: Element, p: number[], con: egret.DisplayObje
* @param rotation 弧度,逆时针
* @param point 定点,默认0,0
*/
function rotationAcodPoint(p: number[], rotation: number, point: number[] = [0, 0]) {
export function rotationAcodPoint(p: number[], rotation: number, point: number[] = [0, 0]) {
//平移
var xp = p[0] - point[0];
var yp = p[1] - point[1];
......
......@@ -5,18 +5,27 @@ import { playSound, SoundType } from "../../soundCtrl";
import { Element } from "../class/Element";
import { Tool } from "../Tool";
import { ElementType } from "../enum/ElementType";
import { getRotByTwoVectors, rotationAcodPoint } from "../anis/MagicRotateAni";
let iconCount: number = 0;
/**
* 情人节版本
*/
export class FesRedShootAni extends egret.DisplayObjectContainer {
light: LightingAni;
imageAni: ImageAni;
imageAniCon: egret.DisplayObjectContainer
imageAniCon: egret.DisplayObjectContainer;
//头部
head: egret.Bitmap;
constructor() {
super()
this.light = new LightingAni();
this.addChild(this.light);
var ht: egret.Texture = RES.getRes("ele" + ElementType.FESTIVALELE_SMALL + "_png")
this.head = new egret.Bitmap(ht);
this.head.anchorOffsetX = ht.textureWidth / 2;
this.head.anchorOffsetY = ht.textureHeight / 2;
this.addChild(this.head);
this.head.scaleX = this.head.scaleY = 0.3;
var arr = []
for (var i = 1; i <= 10; i++) {
arr.push("fesEleSmallDis" + i + "_png");
......@@ -28,31 +37,60 @@ export class FesRedShootAni extends egret.DisplayObjectContainer {
this.imageAni.visible = false
}
reset() {
this.light.visible = true;
this.head.visible = true;
this.imageAni.visible = false;
this.light.scaleX = 0.2;
}
play(startP: number[], ele: Element, callback: Function) {
this.reset()
//算角度
var r = Tool.getForwardRotation(startP, [ele.x, ele.y])
this.light.rotation = r * 180 / Math.PI;
this.light.x = startP[0];
this.light.y = startP[1];
let head = this.head;
let self = this;
//动画帧出现的地方就是元素的位置
this.imageAniCon.x = ele.x;
this.imageAniCon.y = ele.y;
//247
var dis = Math.sqrt(
(startP[0] - ele.x) * (startP[0] - ele.x) +
(startP[1] - ele.y) * (startP[1] - ele.y)
)
var scaleX = dis / 247;
egret.Tween.get(this.light)
.to({ scaleX: scaleX, }, 400)
//
var deltaX = startP[0] - ele.x;
var deltaY = startP[1] - ele.y;
var dis = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
//算角度,弧度,x正方向为0,0到2pi,逆时针为正
var vec0 = [1, 0]
var vec1 = [deltaX, deltaY]
var rotation = getRotByTwoVectors(vec0, vec1);
if (deltaY > 0) rotation = Math.PI * 2 - rotation;
var tAll = 60;
var a = { t: 0 };
egret.Tween.get(a, {
onChange: function () {
//螺旋半径,时间t的函数,越来越大,0
var r = dis * a.t / tAll;
//螺旋角度,基础角度+补间角度,
var theta = a.t / tAll * Math.PI
var x = r * Math.cos(theta)
var y = r * Math.sin(theta)
//旋转一下
var xy = rotationAcodPoint([x, y], rotation);
head.x = xy[0] + startP[0];
head.y = xy[1] + startP[1];
//添加尾部粒子
let p = particlePool.shift();
if (!p) p = new Particle();
p.reset();
p.x = xy[0] + startP[0];
p.y = xy[1] + startP[1];
self.addChildAt(p, 0);
}
})
.to({ t: tAll }, 1200, /*egret.Ease.quadIn*/)
.call(() => {
//隐藏头部
head.visible = false;
ele.reset(ElementType.FESTIVALELE_SMALL);
ele.scaleX = ele.scaleY = 0.1
ele.scaleX = ele.scaleY = 0.1;
ele.changeSource('chocolate' + (iconCount++ % 4) + '_png')
egret.Tween.get(ele)
.to({ scaleX: 1, scaleY: 1 }, 500, egret.Ease.backOut)
......@@ -66,14 +104,50 @@ export class FesRedShootAni extends egret.DisplayObjectContainer {
};
Pool.recover(RecoverName.FESREDSHOOT_ANI, this)
})
setTimeout(() => {
this.light.visible = false;
}, 200)
})
}
}
const particlePool: Particle[] = [];
class Particle extends egret.Bitmap {
private life: number = 0;
private maxLife: number = 60;
public alphaSpeed = 0.02
public scaleSpeed = 0.02;
constructor() {
super();
this.texture = RES.getRes("redbombParticle_png");
this.anchorOffsetX = this.texture.textureWidth / 2;
this.anchorOffsetY = this.texture.textureHeight / 2;
this.addEventListener(egret.Event.ENTER_FRAME, this.enterFrame, this);
}
reset() {
this.life = 0;
this.alpha = 1;
// this.scaleX = this.scaleY = 2;
this.scaleX = this.scaleY = Math.random() * 1;
this.rotation = Math.random() * 360;
}
enterFrame() {
// if (!this.stage) return;
if (++this.life > this.maxLife) {
//回收
if (this.parent) {
this.parent.removeChild(this);
particlePool.push(this);
}
return;
}
this.alpha -= this.alphaSpeed;
if (this.alpha < 0) this.alpha = 0
// this.scaleX = this.scaleY -= this.scaleSpeed;
// if (this.scaleX < 0) this.scaleX = this.scaleY = 0;
}
}
/**
* 需要回调的
......
......@@ -163,6 +163,8 @@ export class AiControl {
for (var i = 0; i < six.length; i++) six[i] = six[i].index;
//动画
thisObj.redBombLightAni(index, () => {
//巧克力分裂效果,先去掉元素,再加动画
let count = 0;
let countAll = six.length;
for (let a = 0; a < six.length; a++) {
......
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