Commit 34b7e815 authored by zjz1994's avatar zjz1994

调整动画

parent 94e8ca88
...@@ -434,6 +434,13 @@ export default class MainScene extends Scene { ...@@ -434,6 +434,13 @@ export default class MainScene extends Scene {
}> = []; }> = [];
islongScreen:boolean = false; islongScreen:boolean = false;
freefoodData:Array<{
idx:number,
type:ElementType
}> = [];
inaniFood:boolean = false;
constructor(){ constructor(){
super(); super();
window['gm'] = this.gm; window['gm'] = this.gm;
...@@ -556,6 +563,8 @@ export default class MainScene extends Scene { ...@@ -556,6 +563,8 @@ export default class MainScene extends Scene {
this.icefoodArr = new Array(); this.icefoodArr = new Array();
this.ficefoodArr = new Array(); this.ficefoodArr = new Array();
this.freefoodData = new Array();
this.inaniFood = false;
this.initTurf(); this.initTurf();
...@@ -3106,6 +3115,19 @@ export default class MainScene extends Scene { ...@@ -3106,6 +3115,19 @@ export default class MainScene extends Scene {
async fallCallback() { async fallCallback() {
this.initTurf(); this.initTurf();
this.incheckFall = true; this.incheckFall = true;
//冰下食物
if(this.inaniFood){
return;
}
if(this.freefoodData.length>0){
this.solveFoodEli();
return;
}
// //掉落后先走猩猩的消除 // //掉落后先走猩猩的消除
// if(this.gopongoArr.length>0){//消除猩猩,先播放猩猩消失的动画,后消除 // if(this.gopongoArr.length>0){//消除猩猩,先播放猩猩消失的动画,后消除
// for(var cp=0;cp<this.gopongoArr.length;cp++){ // for(var cp=0;cp<this.gopongoArr.length;cp++){
...@@ -3342,6 +3364,7 @@ export default class MainScene extends Scene { ...@@ -3342,6 +3364,7 @@ export default class MainScene extends Scene {
} }
//如果只有步数转化的,不能再进结算, //如果只有步数转化的,不能再进结算,
else { else {
// /**
var effectElements = [], elements = []; var effectElements = [], elements = [];
for(var i = Tool.colNum * Tool.rowNum - 1; i >= 0; i--) { for(var i = Tool.colNum * Tool.rowNum - 1; i >= 0; i--) {
var lat = this.lattices[i]; var lat = this.lattices[i];
...@@ -3358,6 +3381,7 @@ export default class MainScene extends Scene { ...@@ -3358,6 +3381,7 @@ export default class MainScene extends Scene {
this.eliminate(); this.eliminate();
return; return;
} }
// */
// else{ // else{
// console.log("可以结束"); // console.log("可以结束");
// } // }
...@@ -7005,37 +7029,54 @@ export default class MainScene extends Scene { ...@@ -7005,37 +7029,54 @@ export default class MainScene extends Scene {
var ifood:Food = this.mapupfoodContainer.getChildByName(ifoodname) as Food; var ifood:Food = this.mapupfoodContainer.getChildByName(ifoodname) as Food;
if(ifood.freeidxs.indexOf(idx)==-1){ if(ifood.freeidxs.indexOf(idx)==-1){
ifood.freeidxs.push(idx); ifood.freeidxs.push(idx);
if(ifood.freeidxs.length==ifood.lockidxs.length){ if(ifood.freeidxs.length==ifood.lockidxs.length){
eliminatearr.push(...ifood.freeidxs); eliminatearr.push(...ifood.freeidxs);
if(ifood&&ifood.parent){ // if(ifood&&ifood.parent){
ifood.parent.removeChild(ifood); // ifood.parent.removeChild(ifood);
Pool.recover(RecoverName.FOOD,ifood); // Pool.recover(RecoverName.FOOD,ifood);
} // }
this.addFreeiceFoodArr(ifoodname,ifood.freeidxs); this.addFreeiceFoodArr(ifoodname,ifood.freeidxs);
console.log("食物自由了,消除上面的动物,播放食物自由动画"); console.log("食物自由了,消除上面的动物,播放食物自由动画");
//食物动效播完,进行食物的通关目标完成 //食物动效播完,进行食物的通关目标完成
// this.goElementTarget(ifood.type,[ifood.x,ifood.y]); // this.goElementTarget(ifood.type,[ifood.x,ifood.y]);
this.playElfoodAni1(ifood.type,[ifood.x,ifood.y]); // this.playElfoodAni1(ifood.type,[ifood.x,ifood.y]);
var addifood:boolean = false;
for(var j=0;j<this.freefoodData.length;j++){
var jfood = this.freefoodData[j];
if(jfood.idx==ifood.luidx){
addifood = true;
break;
}
}
if(!addifood){
this.freefoodData.push({
idx:ifood.luidx,
type:ifood.type
})
}
} }
} }
} }
} }
// //
if(eliminatearr.length>0){ // if(eliminatearr.length>0){
for(var e=0;e<eliminatearr.length;e++){ // for(var e=0;e<eliminatearr.length;e++){
var eidx = eliminatearr[e]; // var eidx = eliminatearr[e];
var lat = this.lattices[eidx]; // var lat = this.lattices[eidx];
var caneliminate = Tool.judgeEliminate(lat); // var caneliminate = Tool.judgeEliminate(lat);
if(caneliminate){ // if(caneliminate){
if(this.eliminatedElements.indexOf(eidx)==-1){ // if(this.eliminatedElements.indexOf(eidx)==-1){
this.eliminatedElements.push(eidx); // this.eliminatedElements.push(eidx);
} // }
} // }
} // }
} // }
} }
addFreeiceFoodArr(name:string,idxs:Array<number>){ addFreeiceFoodArr(name:string,idxs:Array<number>){
...@@ -7085,6 +7126,43 @@ export default class MainScene extends Scene { ...@@ -7085,6 +7126,43 @@ export default class MainScene extends Scene {
* 甜甜圈:173*174 * 甜甜圈:173*174
* 热狗:300*240 * 热狗:300*240
*/ */
solveFoodEli(){
var foodata = this.freefoodData.shift();
var foodidx = foodata.idx;
var foodtype = foodata.type;
var eliminatearr:Array<number> = new Array();
for(var i=0;i<this.ficefoodArr.length;i++){
var ifoodata = this.ficefoodArr[i];
var ifoodidxs = ifoodata.inidxs;
if(ifoodidxs.indexOf(foodidx)!=-1){
var ifoodname = ifoodata.name;
var ifood:Food = this.mapupfoodContainer.getChildByName(ifoodname) as Food;
if(ifood&&ifood.parent){
ifood.parent.removeChild(ifood);
Pool.recover(RecoverName.FOOD,ifood);
}
eliminatearr.push(...ifood.freeidxs);
this.inaniFood = true;
this.playElfoodAni1(ifood.type,[ifood.x,ifood.y]);
break;
}
}
if(eliminatearr.length>0){
for(var e=0;e<eliminatearr.length;e++){
var eidx = eliminatearr[e];
var lat = this.lattices[eidx];
var caneliminate = Tool.judgeEliminate(lat);
if(caneliminate){
if(this.eliminatedElements.indexOf(eidx)==-1){
this.eliminatedElements.push(eidx);
}
}
}
this.eliminate();
}
}
//食物通关目标动画1段 //食物通关目标动画1段
playElfoodAni1(type: ElementType, fromP: number[]){ playElfoodAni1(type: ElementType, fromP: number[]){
console.log("食物动画一段",type); console.log("食物动画一段",type);
...@@ -7156,29 +7234,39 @@ export default class MainScene extends Scene { ...@@ -7156,29 +7234,39 @@ export default class MainScene extends Scene {
var tscale:number = 1; var tscale:number = 1;
var addx:number = 0; var addx:number = 0;
var addy:number = 0; var addy:number = 0;
var sizew:number;
var sizeh:number;
if(type==ElementType.food1){ if(type==ElementType.food1){
tscale = 0.5; tscale = 0.5;
addx = 21; addx = 21;
addy = -3; addy = -3;
sizew = 93;
sizeh = 159;
}else if(type==ElementType.food2){ }else if(type==ElementType.food2){
tscale = 0.3; tscale = 0.3;
addx = 1; addx = 1;
addy = 1; addy = 1;
sizew = 249;
sizeh = 226;
}else if(type==ElementType.food3){ }else if(type==ElementType.food3){
tscale = 0.4; tscale = 0.4;
addx = 5; addx = 5;
addy = 1; addy = 1;
sizew = 170;
sizeh = 169;
}else if(type==ElementType.food4){ }else if(type==ElementType.food4){
tscale = 0.3; tscale = 0.3;
addx = 0; addx = 0;
addy = 13; addy = 13;
sizew = 248;
sizeh = 168;
} }
var foodsize = mainscene.getFoodeSize(type); var foodsize = mainscene.getFoodeSize(type);
var foodwid = foodsize[0]*tscale; var foodwid = foodsize[0]*tscale;//sizew*tscale;
var foodhei = foodsize[1]*tscale; var foodhei = foodsize[1]*tscale;//sizeh*tscale;
var p3 = mainscene.elementTargets.targets[type].localToGlobal(40 * 0.8, 40 * 0.8); var p3 = mainscene.elementTargets.targets[type].localToGlobal(40 * 0.8, 40 * 0.8);
p3.x = p3.x - foodwid/2 - addx; p3.x = p3.x - foodwid/2 + addx;
p3.y = p3.y - foodhei/2 + addy; p3.y = p3.y - foodhei/2 + addy;
var p2 = new egret.Point((p3.x-p1.x)/3+p1.x,(p3.y-p1.y)/3+p1.y); var p2 = new egret.Point((p3.x-p1.x)/3+p1.x,(p3.y-p1.y)/3+p1.y);
...@@ -7188,8 +7276,12 @@ export default class MainScene extends Scene { ...@@ -7188,8 +7276,12 @@ export default class MainScene extends Scene {
playElfoodAni3(mv:any,type:ElementType,mainscene:MainScene){ playElfoodAni3(mv:any,type:ElementType,mainscene:MainScene){
mainscene.elementTargets.targets[type].count--; mainscene.elementTargets.targets[type].count--;
//mv播放第三段,静态图放大消失就行 //mv播放第三段,静态图放大消失就行
if(mv&&mv.parent){
mv.parent.removeChild(mv);
}
console.log(mainscene.elementTargets.targets[type]); console.log(mainscene.elementTargets.targets[type]);
mainscene.inaniFood = false;
mainscene.eliminate();
} }
//加载食物动画 //加载食物动画
initFoodSvgas(){ initFoodSvgas(){
......
...@@ -22,36 +22,36 @@ export default class TargetItemRenderer extends eui.ItemRenderer { ...@@ -22,36 +22,36 @@ export default class TargetItemRenderer extends eui.ItemRenderer {
this['txt'].text = `${this.data.count}`; this['txt'].text = `${this.data.count}`;
var tscale:number = 1; // var tscale:number = 1;
var flyimg:eui.Image; // var flyimg:eui.Image;
if(this.data.type==ElementType.food1){ // if(this.data.type==ElementType.food1){
tscale = 0.5; // tscale = 0.5;
flyimg = this['icon42_f']; // flyimg = this['icon42_f'];
}else if(this.data.type==ElementType.food1){ // }else if(this.data.type==ElementType.food1){
tscale = 0.3; // tscale = 0.3;
flyimg = this['icon43_f']; // flyimg = this['icon43_f'];
}else if(this.data.type==ElementType.food1){ // }else if(this.data.type==ElementType.food1){
tscale = 0.4; // tscale = 0.4;
flyimg = this['icon44_f']; // flyimg = this['icon44_f'];
}else if(this.data.type==ElementType.food1){ // }else if(this.data.type==ElementType.food1){
tscale = 0.3; // tscale = 0.3;
flyimg = this['icon45_f']; // flyimg = this['icon45_f'];
} // }
var endscale:number = tscale + 0.2; // var endscale:number = tscale + 0.2;
if(flyimg){ // if(flyimg){
console.log("飞动效"); // console.log("飞动效");
flyimg.visible = true; // flyimg.visible = true;
egret.Tween.get(flyimg) // egret.Tween.get(flyimg)
.set({ // .set({
scaleX:tscale, // scaleX:tscale,
scaleY:tscale, // scaleY:tscale,
alpha:1 // alpha:1
}) // })
.to({ // .to({
scaleX:endscale, // scaleX:endscale,
scaleY:endscale, // scaleY:endscale,
alpha:0 // alpha:0
},300); // },300);
} // }
} }
} }
\ No newline at end of file
...@@ -21,6 +21,8 @@ export default class Food extends eui.Component{ ...@@ -21,6 +21,8 @@ export default class Food extends eui.Component{
usecol:number; usecol:number;
lockidxs:Array<number> = []; lockidxs:Array<number> = [];
freeidxs:Array<number> = []; freeidxs:Array<number> = [];
luidx:number;
constructor(){ constructor(){
super(); super();
...@@ -28,6 +30,8 @@ export default class Food extends eui.Component{ ...@@ -28,6 +30,8 @@ export default class Food extends eui.Component{
this.addChild(this.showImage); this.addChild(this.showImage);
} }
resetFood(type:ElementType,dir:string,luidx:number){ resetFood(type:ElementType,dir:string,luidx:number){
this.luidx = luidx;
this.type = type; this.type = type;
this.userow = [1,3,2,3][this.type-ElementType.food1]; this.userow = [1,3,2,3][this.type-ElementType.food1];
this.usecol = [2,3,2,2][this.type-ElementType.food1]; this.usecol = [2,3,2,2][this.type-ElementType.food1];
......
...@@ -34,16 +34,105 @@ export class ElementTarget extends egret.DisplayObjectContainer { ...@@ -34,16 +34,105 @@ export class ElementTarget extends egret.DisplayObjectContainer {
} }
this._count = value; this._count = value;
this.countNum.num = value; this.countNum.num = value;
if(this.flyimg){
var tscale:number = 1;
if(this.type==ElementType.food1){
tscale = 0.5;
}else if(this.type==ElementType.food2){
tscale = 0.3;
}else if(this.type==ElementType.food3){
tscale = 0.4;
}else if(this.type==ElementType.food4){
tscale = 0.3;
}
var endscale:number = tscale + 0.3;
egret.Tween.get(this.flyimg)
.set({
scaleX:tscale,
scaleY:tscale,
alpha:1
})
.to({
scaleX:endscale,
scaleY:endscale,
alpha:0
},300);
}
} }
flyimg:egret.Bitmap;
constructor(type: ElementType) { constructor(type: ElementType) {
super() super()
var texture: egret.Texture = RES.getRes("ele" + type + "_png"); var texture: egret.Texture;
var showImage = new egret.Bitmap(texture); var showImage:egret.Bitmap;
showImage.width = 90; this.type = type;
showImage.height = 90;
showImage.scaleX = showImage.scaleY = 0.7; var imgwid:number;
showImage.y = 10; var imghei:number;
var imgscale:number;
var imgx:number;
var imgy:number;
if(type==ElementType.food1){
texture = RES.getRes("ele" + type + "_png");
showImage = new egret.Bitmap(texture);
imgwid = 93;
imghei = 159;
imgscale = 0.5;
imgx = 21;
imgy = -3;
this.setflyimg(texture,imgwid,imghei,imgscale,imgx,imgy);
}else if(type==ElementType.food2){
texture = RES.getRes("ele" + type + "_png");
showImage = new egret.Bitmap(texture);
imgwid = 249;
imghei = 226;
imgscale = 0.3;
imgx = 1;
imgy = 1;
this.setflyimg(texture,imgwid,imghei,imgscale,imgx,imgy);
}else if(type==ElementType.food3){
texture = RES.getRes("ele" + type + "_png");
showImage = new egret.Bitmap(texture);
imgwid = 170;
imghei = 169;
imgscale = 0.4;
imgx = 5;
imgy = 1;
this.setflyimg(texture,imgwid,imghei,imgscale,imgx,imgy);
}else if(type==ElementType.food4){
texture = RES.getRes("ele" + type + "_png");
showImage = new egret.Bitmap(texture);
imgwid = 248;
imghei = 168;
imgscale = 0.3;
imgx = 0;
imgy = 13;
this.setflyimg(texture,imgwid,imghei,imgscale,imgx,imgy);
}else{
texture = RES.getRes("ele" + type + "_png");
showImage = new egret.Bitmap(texture);
imgwid = 90;
imghei = 90;
imgscale = 0.7;
imgx = 0;
imgy = 10;
}
showImage.width = imgwid;
showImage.height = imghei;
showImage.scaleX = showImage.scaleY = imgscale;
showImage.x = imgx;
showImage.y = imgy;
this.addChild(showImage); this.addChild(showImage);
var texture: egret.Texture = RES.getRes("rightMark_png"); var texture: egret.Texture = RES.getRes("rightMark_png");
this.zeroMark = new egret.Bitmap(texture); this.zeroMark = new egret.Bitmap(texture);
...@@ -56,4 +145,20 @@ export class ElementTarget extends egret.DisplayObjectContainer { ...@@ -56,4 +145,20 @@ export class ElementTarget extends egret.DisplayObjectContainer {
this.countNum.y = 48; this.countNum.y = 48;
this.addChild(this.countNum); this.addChild(this.countNum);
} }
setflyimg(texture:egret.Texture,imgwid:number,imghei:number,imgscale:number,imgx:number,imgy:number){
this.flyimg = new egret.Bitmap(texture);
this.flyimg.width = imgwid;
this.flyimg.height = imghei;
this.flyimg.scaleX = this.flyimg.scaleY = imgscale;
this.flyimg.x = imgx;
this.flyimg.y = imgy;
this.flyimg.anchorOffsetX = imgwid/2;
this.flyimg.anchorOffsetY = imghei/2;
this.flyimg.x = imgx+imgwid*imgscale/2;
this.flyimg.y = imgy+imghei*imgscale/2;
this.addChild(this.flyimg);
}
} }
\ No newline at end of file
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