Commit 8bfe8d17 authored by zjz1994's avatar zjz1994

性能优化暂存

parent 2ea5fb9e
......@@ -25,12 +25,12 @@ export default class SceneCtrl {
change(type: ModuleTypes, data?, onComplete?: Function) {
if(type==ModuleTypes.MAIN_SCENE){
console.log("游戏界面单例处理");
// console.log("游戏界面单例处理");
if(this.mainscene){
console.log("使用已存在mainscene");
// console.log("使用已存在mainscene");
this.showAfterLoadAtlas(this.mainscene,data,onComplete);
}else{
console.log("第一次创建mainscene");
// console.log("第一次创建mainscene");
this.mainscene = new MainScene();
if (!window['development']) {
Loading.instace.show();
......@@ -65,17 +65,31 @@ export default class SceneCtrl {
showAfterLoadAtlas(scene: Scene, data, onComplete: Function) {
Loading.instace.hide();
scene.loadSkin();
scene.addEventListener(egret.Event.ADDED_TO_STAGE, () => {
// console.log("showAfterLoadAtlas",scene.skinName);
// scene.addEventListener(egret.Event.ADDED_TO_STAGE, () => {
// console.log("addToStageListener",scene.skinName);
// scene.start(data);
// }, this);
// scene.addEventListener(egret.Event.ADDED_TO_STAGE,this.sceneAddStateListener,this);
scene.once(egret.Event.ADDED_TO_STAGE, () => {
// console.log("addToStageListener",scene.skinName);
scene.start(data);
}, this);
scene.onLoad().then(() => {
// console.log("onLoad---after",scene.skinName);
this.addToStage(scene);
onComplete && onComplete();
});
}
// sceneAddStateListener(e){
// console.log("addToStageListener",e.target.skinName);
// let scene = e.target;
// scene.start(data);
// }
addMask() {
if (!this._mask) {
this._mask = new egret.Sprite();
......
......@@ -74,7 +74,7 @@ import {
submitTran,
forwardDirection,
} from '../something/enum/ElementType';
import { isIce, isSpecialLattice, isSand, isBlock } from '../something/enum/LatticeType';
import { isIce, isSpecialLattice, isSand, isBlock, LatticeType } from '../something/enum/LatticeType';
import { PassType } from '../something/enum/PassType';
import { RecoverName } from '../something/enum/RecoverName';
import { StateType } from '../something/enum/StateType';
......@@ -380,8 +380,8 @@ export default class MainScene extends Scene {
//初始换道具容器
this.propBtnCon = new PropBtnCon();
this.propBtnCon.y = 299 + Tool.gameAreaHeight// + 55;
this.addChild(this.propBtnCon);
console.log("添加道具group",this.propBtnCon);
this.mapContainer = new egret.DisplayObjectContainer();
this.addChild(this.mapContainer);
......@@ -420,6 +420,16 @@ export default class MainScene extends Scene {
async start(data) {
super.start();
this.emptys = new Array();
this.warningCop = new Array();
this.eliminatedElements = new Array();
this.lollipopMark = false;
this.hasEliminatedElements = new Array();
this.scoreAnis = new Array();
this.cannoArr = new Array();
this.cannoEffect = new Array();
this.readyCannoArr = new Array();
this.fireteamCannoArr = new Array();
this.mapContainer.removeChildren();
this.mapupContainer.removeChildren();
......@@ -615,7 +625,6 @@ export default class MainScene extends Scene {
mvdata = cannoparticlemvdata;
}
if(mvdata){
// console.log("复用mvdata,免加载");
let mv = new window["SVGA"].EgretMovieClip(mvdata);
this.initCannoMv(mv,jsvgname,i);
}else{
......@@ -748,7 +757,8 @@ export default class MainScene extends Scene {
//当前分数
//初始换道具容器
this.propBtnCon.y = 299 + Tool.gameAreaHeight// + 55;
this.propGuide.changeOffset(this.propBtnCon.y);
//初始化道具信息
this.updateScene();
......@@ -912,7 +922,8 @@ export default class MainScene extends Scene {
mask.addChild(oneMask);
list.forEach(i => {
const arrow = createArrowBg(tex);
const arrow = Tool.getConver();
arrow.rotation = getArrowRotation(dir);
conveyorContainer.addChild(arrow);
const p = Tool.getPositionByIndex(i);
......@@ -950,14 +961,16 @@ export default class MainScene extends Scene {
latticeDisplay = ice;
this.lattices[i].ice = ice;
} else if(isSand(latticesD[i])) {
latticeDisplay = Pool.takeOut(RecoverName.SAND);
if(!latticeDisplay){
latticeDisplay = getSandDisplayBlock();
}
this.lattices[i].sand = latticeDisplay as Sand;
} else {
latticeDisplay = genBlockDisplay(latticesD[i]);
this.lattices[i].block = latticeDisplay as BaseBlock;
}
if(latticeDisplay) {
// this.map.addChild(latticeDisplay);
this.mapupContainer.addChild(latticeDisplay);
latticeDisplay.x = p[0];
latticeDisplay.y = p[1];
......@@ -1020,8 +1033,9 @@ export default class MainScene extends Scene {
var elements = this.chapterData.map.elements || Tool.setNumber01(this.chapterData.map.lattices.slice());
//猩猩初始时加入
var pongoArr:Array<{tl:number,tr:number,bl:number,br:number}> = new Array();
for(var i = 0; i < elements.length; i++) {
console.log("开始initElement",this.chapter);
for(let i = 0; i < elements.length; i++) {
// console.log("initElement遍历-------",i);
//如果对应格子为空,直接跳过,
if(!this.lattices[i]) continue;
var p = Tool.getPositionByIndex(i);
......@@ -1044,6 +1058,7 @@ export default class MainScene extends Scene {
if(!ele) {
ele = new Element(type)
} else {
// console.log("initElement复用ele",i,elements[i],Tool.indexToRc(i));
ele.reset(type)
}
ele.x = p[0];
......@@ -1079,6 +1094,7 @@ export default class MainScene extends Scene {
if(!lol) {
lol = new Element(ElementType.LOLLIPOP)
} else {
// console.log("initElement复用ele",i,elements[i],Tool.indexToRc(i));
lol.reset(ElementType.LOLLIPOP)
}
lol.x = p[0];
......@@ -1092,6 +1108,7 @@ export default class MainScene extends Scene {
if(!rock) {
rock = new Element(ElementType.ROCK)
} else {
// console.log("initElement复用ele",i,elements[i],Tool.indexToRc(i));
rock.reset(ElementType.ROCK)
}
rock.x = p[0];
......@@ -1465,10 +1482,6 @@ export default class MainScene extends Scene {
this.musicBtn.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_musicBtn, this)
this.quitBtn.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_quitBtn, this)
this.propBtnCon.boomBtn.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_boomBtn, this)
this.propBtnCon.hammerBtn.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_hammerBtn, this)
this.propBtnCon.stepBtn.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_stepBtn, this)
this.elementContainer.removeEventListener(egret.TouchEvent.TOUCH_BEGIN, this.mouseDownE, this);
this.elementContainer.removeEventListener(egret.TouchEvent.TOUCH_MOVE, this.mouseMoveE, this);
......@@ -1483,6 +1496,9 @@ export default class MainScene extends Scene {
//容器事件
this.elementContainer.removeEventListener(egret.TouchEvent.TOUCH_BEGIN, this.mouseDownE, this);
this.elementContainer.removeEventListener(egret.TouchEvent.TOUCH_MOVE, this.mouseMoveE, this);
this.reCoverAllLattice();
}
onEnterFrame() {
......@@ -5004,6 +5020,55 @@ export default class MainScene extends Scene {
return ele
}
/**
* 关闭页面时,回收所有的元素
*/
reCoverAllLattice(){
if(this.warningCop){
egret.Tween.removeTweens(this.warningCop[0]);
egret.Tween.removeTweens(this.warningCop[1]);
}
console.log("页面回收");
for(let i=0;i<this.lattices.length;i++){
let ilattice = this.lattices[i];
if(!ilattice)continue;
this.recoverMapast(ilattice);
this.recoverEleast(ilattice);
}
}
recoverMapast(lat:Lattice){
if(lat.ice&&lat.ice.parent){
let ice = lat.ice;
ice.parent.removeChild(ice);
Pool.recover(RecoverName.ICE,ice);
}else if(lat.block&&lat.block.parent){
let block = lat.block;
block.parent.removeChild(block);
if(lat.block.blocktype==LatticeType.BlOCK){
Pool.recover(RecoverName.BLOCK,block);
}else if(lat.block.blocktype==LatticeType.BLOCK_AND_ICE){
Pool.recover(RecoverName.ICE_BLOCK,block);
}else if(lat.block.blocktype==LatticeType.BLOCK_AND_DARK_ICE){
Pool.recover(RecoverName.DARK_ICE_BLOCK,block);
}
}else if(lat.sand&&lat.sand.parent){
let sand = lat.sand;
sand.parent.removeChild(sand);
Pool.recover(RecoverName.SAND,sand);
}
}
recoverEleast(lat:Lattice){
let ele = lat.element;
if(!ele)return;
if(ele&&ele.parent){
ele.addDisable();
ele.parent.removeChild(ele);
Pool.recover(RecoverName.ELEMENT,ele);
}
}
/**
* 禁用与开启事件
......
......@@ -10,6 +10,7 @@ import { GenerateLatData } from "./interface/GenerateLatData";
import { Pool } from "./Pool";
import HoneyPotElement from "./class/HoneyPotElement";
import { ElementConfigType } from "./enum/ElementConfigType";
import createArrowBg from "./conveyor/createArrowBg";
//两种,0无棒棒糖,1有
const offsetYTwo: number[] = [];
......@@ -1162,9 +1163,13 @@ export class Tool {
/**
* 传送带
*/
// public static getConver():egret.Sprite{
// }
public static getConver():egret.Sprite{
let sp:egret.Sprite = Pool.takeOut(RecoverName.CONVEYOR);
if(!sp){
sp = createArrowBg();
}
return sp;
}
/**
* 返回个十百等,0是个位 ,1是十位,依次
......
import centerAnchor from "./centerAnchor";
import { Element } from "../class/Element";
import { StateType } from "../enum/StateType";
import { LatticeType } from "../enum/LatticeType";
export default class BaseBlock extends egret.DisplayObjectContainer {
_inited = false;
constructor(state) {
blocktype:LatticeType;
constructor(state,blocktype:LatticeType) {
super();
this._state = state;
this.blocktype = blocktype;
this.initUI();
}
initUI() {
this._block = new egret.Bitmap(RES.getRes('common_block_png'));
this._blockBgFront = new egret.Bitmap(RES.getRes('common_block_front_png'));
......
......@@ -2,6 +2,8 @@ import { LatticeType } from "../enum/LatticeType";
import Block from "./Block";
import BlockDarkIce from "./BlockDarkIce";
import BlockIce from "./BlockIce";
import { Pool } from "../Pool";
import { RecoverName } from "../enum/RecoverName";
export default (type: LatticeType) => {
const typestr = type + '';
......@@ -14,12 +16,36 @@ export default (type: LatticeType) => {
}
switch (type) {
case LatticeType.BlOCK:
return new Block(_state);
let block = Pool.takeOut(RecoverName.BLOCK);
if(!block){
block = new Block(_state,LatticeType.BlOCK);
}else{
block._state = _state;
}
return block;
case LatticeType.BLOCK_AND_ICE:
return new BlockIce(_state);
let iceblock = Pool.takeOut(RecoverName.ICE_BLOCK);
if(!iceblock){
iceblock = new BlockIce(_state,LatticeType.BLOCK_AND_ICE);
}else{
iceblock._state = _state;
iceblock.ice.alpha = 0.6;
iceblock.ice.visible = false;
iceblock.iceCountNum = 1;
}
return iceblock;
case LatticeType.BLOCK_AND_DARK_ICE:
return new BlockDarkIce(_state);
let darkiceblock = Pool.takeOut(RecoverName.DARK_ICE_BLOCK);
if(!darkiceblock){
darkiceblock = new BlockDarkIce(_state,LatticeType.BLOCK_AND_DARK_ICE);
}else{
darkiceblock._state = _state;
iceblock.ice.alpha = 1;
iceblock.ice.visible = false;
iceblock.iceCountNum = 2;
}
return darkiceblock;
default:
break;
}
......
......@@ -163,9 +163,83 @@ export const Chapters24: ChapterData[] = [
2, 14, 2, 1, 5, 1, 2, 14, 2,
2, 2, 2, 5, 5, 5, 2, 2, 2 ], baseElements: [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], recycles: [], generateLats: [ { index: 0, type: null }, { index: 1, type: null }, { index: 7, type: null }, { index: 8, type: null }, { index: 11, type: null }, { index: 15, type: null }, { index: 21, type: null }, { index: 23, type: null }, { index: 31, type: null } ] } },
//623
{ baseElementTypes: [ 1, 2, 3, 4 ], bubbleProbability: 0, stepCount: 23, passTarget: { type: 1, elements: [ { type: 1, count: 115 }, { type: 4, count: 106 } ] }, starScores: [ 15000, 20000, 25000 ], map: { lattices: [ 3, 3, 3, 3, 3, 3, 3, 3, 0, 3, 3, 3, 3, 3, 3, 3, 0, 3, 3, 3, 3, 3, 3, 3, 4, 3, 3, 3, 3, 3, 3, 3, 0, 3, 3, 3, 3, 3, 3, 3, 0, 3, 41, 3, 3, 3, 3, 3, 41, 3, 3, 3, 3, 3, 3, 3, 0, 3, 3, 3, 3, 3, 0, 3, 0, 3, 4, 3, 0, 0, 0, 0, 0, 3, 3, 0, 0, 0, 0, 0, 0 ], connectedLats: [], conveyor: [], conveyorConnectedLats: [], elements: [ 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1, 0, 1, 1, 1, 1, 1, 2, 1, 0, 0, 1, 1, 1, 1, 2, 1, 1, 0, 0, 1, 1, 1, 2, 1, 0, 1, 0, 0, 1, 1, 2, 1, 0, 0, 1, 0, 0, 1, 2, 1, 1, 0, 0, 12, 0, 1, 2, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1 ], baseElements: [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], recycles: [], generateLats: [ { index: 0, type: null }, { index: 1, type: null }, { index: 2, type: null }, { index: 3, type: null }, { index: 4, type: null }, { index: 5, type: null }, { index: 6, type: null }, { index: 7, type: null }, { index: 17, type: null }, { index: 25, type: null }, { index: 41, type: null }, { index: 49, type: null } ] } },
{ baseElementTypes: [ 1, 2, 3, 4 ],
bubbleProbability: 0, stepCount: 23,
passTarget: { type: 1, elements: [ { type: 1, count: 115 }, { type: 4, count: 106 } ] }, starScores: [ 15000, 20000, 25000 ],
map: {
lattices: [
3, 3, 3, 3, 3, 3, 3, 3, 0,
3, 3, 3, 3, 3, 3, 3, 0, 3,
3, 3, 3, 3, 3, 3, 4, 3, 3,
3, 3, 3, 3, 3, 0, 3, 3, 3,
3, 3, 3, 3, 0, 3, 41, 3, 3,
3, 3, 3, 41, 3, 3, 3, 3, 3,
3, 3, 0, 3, 3, 3, 3, 3, 0,
3, 0, 3, 4, 3, 0, 0, 0, 0,
0, 3, 3, 0, 0, 0, 0, 0, 0
], connectedLats: [], conveyor: [], conveyorConnectedLats: [],
elements: [
1, 1, 1, 1, 1, 1, 1, 2, 1,
1, 1, 1, 1, 1, 1, 2, 1, 0,
1, 1, 1, 1, 1, 2, 1, 0, 0,
1, 1, 1, 1, 2, 1, 1, 0, 0,
1, 1, 1, 2, 1, 0, 1, 0, 0,
1, 1, 2, 1, 0, 0, 1, 0, 0,
1, 2, 1, 1, 0, 0, 12, 0, 1,
2, 1, 0, 1, 0, 1, 1, 1, 1,
1, 0, 0, 1, 1, 1, 1, 1, 1
],
baseElements: [
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0
], recycles: [], generateLats: [ { index: 0, type: null }, { index: 1, type: null }, { index: 2, type: null }, { index: 3, type: null }, { index: 4, type: null }, { index: 5, type: null }, { index: 6, type: null }, { index: 7, type: null }, { index: 17, type: null }, { index: 25, type: null }, { index: 41, type: null }, { index: 49, type: null } ] } },
//624
{ baseElementTypes: [ 1, 0, 2, 4 ], bubbleProbability: 0, stepCount: 21, passTarget: { type: 1, elements: [ { type: 36, count: 69 } ] }, starScores: [ 15000, 20000, 25000 ], map: { lattices: [ 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 7, 7, 7, 7, 7, 7, 7, 0, 7, 0, 7, 7, 7, 7, 7, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 41, 41, 0, 7, 7, 7, 0, 4, 4, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 7, 7, 7, 7, 7, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 ], connectedLats: [], conveyor: [], conveyorConnectedLats: [], elements: [ 1, 16, 1, 1, 1, 1, 1, 16, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 4, 4, 1, 1, 1, 5, 5, 1, 2, 2, 2, 1, 1, 1, 1, 1, 1, 4, 4, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ], baseElements: [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], recycles: [], generateLats: [ { index: 0, type: null }, { index: 1, type: null }, { index: 2, type: null }, { index: 3, type: null }, { index: 4, type: null }, { index: 5, type: null }, { index: 6, type: null }, { index: 7, type: null }, { index: 8, type: null }, { index: 18, type: null }, { index: 26, type: null } ] } },
{ baseElementTypes: [ 1, 0, 2, 4 ],
bubbleProbability: 0, stepCount: 21,
passTarget: { type: 1, elements: [ { type: 36, count: 69 } ] },
starScores: [ 15000, 20000, 25000 ],
map: {
lattices: [
7, 7, 7, 7, 7, 7, 7, 7, 7,
0, 7, 7, 7, 7, 7, 7, 7, 0,
7, 0, 7, 7, 7, 7, 7, 0, 7,
7, 7, 7, 7, 7, 7, 7, 7, 7,
41, 41, 0, 7, 7, 7, 0, 4, 4,
7, 7, 7, 7, 7, 7, 7, 7, 7,
7, 7, 7, 7, 7, 7, 7, 7, 7,
7, 0, 7, 7, 7, 7, 7, 0, 7,
7, 7, 7, 7, 7, 7, 7, 7, 7
], connectedLats: [], conveyor: [], conveyorConnectedLats: [],
elements: [
1, 16, 1, 1, 1, 1, 1, 16, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 4, 4, 4, 1, 1, 1,
5, 5, 1, 2, 2, 2, 1, 1, 1,
1, 1, 1, 4, 4, 4, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 4, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1
],
baseElements: [
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0
], recycles: [],
generateLats: [ { index: 0, type: null }, { index: 1, type: null }, { index: 2, type: null }, { index: 3, type: null }, { index: 4, type: null }, { index: 5, type: null }, { index: 6, type: null }, { index: 7, type: null }, { index: 8, type: null }, { index: 18, type: null }, { index: 26, type: null } ] } },
//625
{ baseElementTypes: [ 0, 2, 3, 4 ], bubbleProbability: 0, stepCount: 25, passTarget: { type: 1, elements: [ { type: 24, count: 20 }, { type: 26, count: 20 } ] }, starScores: [ 15000, 20000, 25000 ], map: { lattices: [ 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ], connectedLats: [], conveyor: [], conveyorConnectedLats: [], elements: [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 13, 13, 13, 13, 13, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 1, 1, 1, 2, 2, 1, 2, 1, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ], baseElements: [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 51, 11, 33, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], recycles: [], generateLats: [ { index: 1, type: null }, { index: 2, type: null }, { index: 3, type: null }, { index: 4, type: null }, { index: 5, type: null }, { index: 6, type: null }, { index: 7, type: null }, { index: 18, type: null }, { index: 26, type: null }, { index: 47, type: null }, { index: 48, type: null }, { index: 49, type: null }, { index: 50, type: null }, { index: 51, type: null } ] } }
]
......@@ -103,24 +103,29 @@ export class Element extends eui.Component {
resetFireworks(thisobj) {
this.changeSource('empty_png');
this.showImage.alpha = 0;
if(this._fireworks){
}else{
const mv: any = initSvga(getFireworksVideoItem());
this._fireworks = mv;
thisobj.addChild(mv);
mv.anchorOffsetX = 340 / 2;
mv.anchorOffsetY = 500;
mv.x = this.x;
mv.y = this.y - 38;
this._fireworks.gotoAndStop(1);
}
thisobj.addChild(this._fireworks);
this._fireworks.gotoAndStop(1);
}
toFireworksAction(start, end) {
const cb = () => {
if (this._fireworks.currentFrame == end) { //向上吹
this._fireworks.gotoAndStop(start);
this._fireworks.removeEventListener(egret.Event.ENTER_FRAME, cb, this);
// this._fireworks.removeEventListener(egret.Event.ENTER_FRAME, cb, this);
}
};
this._fireworks.addEventListener(egret.Event.ENTER_FRAME, cb, this);
this._fireworks.once(egret.Event.ENTER_FRAME, cb, this);
this._fireworks.gotoAndPlay(start, true);
}
......@@ -128,13 +133,17 @@ export class Element extends eui.Component {
async resetMonster() {
this.changeSource('empty_png');
this.showImage.alpha = 0;
if(this._mv){
}else{
const mv: any = await loadSvga(getResPath() + 'resource/assets/svgas/monster.svga');
this._mv = mv;
this.addChild(mv);
mv.anchorOffsetX = 150;
mv.anchorOffsetY = 150;
mv.x = - 3;
mv.y = - 6;
}
this.addChild(this._mv);
this.toStandByAction();
}
......@@ -150,15 +159,19 @@ export class Element extends eui.Component {
toStandByAction() {
if (!this._mv) return;
const mv = this._mv;
const cb = () => {
if (mv.currentFrame == 360) { //向上吹
// const cb = () => {
// if (mv.currentFrame == 360) { //向上吹
// mv.gotoAndPlay(1, true);
// }
// };
this._mv.addEventListener(egret.Event.ENTER_FRAME, this._mvEnterFrame1, this);
mv.gotoAndPlay(1, true);
}
};
this._mv.addEventListener(egret.Event.ENTER_FRAME, cb, this);
mv.gotoAndPlay(1, true);
_mvEnterFrame1(){
if(this._mv.currentFrame == 360){
this._mv.gotoAndPlay(1,true);
}
}
toAction() {
return new Promise((r) => {
if (!this._mv) {
......@@ -170,6 +183,7 @@ export class Element extends eui.Component {
const cb = () => {
if (mv.currentFrame == 508) { //向上吹
this.toStandByAction();
this._mv.removeEventListener(egret.Event.ENTER_FRAME,cb,this);
}
if (mv.currentFrame == 391) {
r();
......@@ -952,14 +966,47 @@ export class Element extends eui.Component {
this.showImage.anchorOffsetY = 0;
this.showImage.scaleY = 1;
this.showImage.scaleX = 1;
this.showImage.alpha = 1;
egret.Tween.removeTweens(this.showImage);
//类型重置,showImage修改
this._type = type;
this.cannobox.visible = this.cannolab.visible = type == ElementType.CANNO;
this.showImage.visible = type != ElementType.CANNO;
this.cannolab.visible = false;
this.inPongoPart = null;
//重置element
if(this._mv&&this._mv.parent){
this._mv.removeEventListener(egret.Event.ENTER_FRAME,this._mvEnterFrame1,this);
this._mv.parent.removeChild(this._mv);
console.log("有怪物",type);
}
if(this._fireworks&&this._fireworks.parent){
this._fireworks.parent.removeChild(this._fireworks);
}
if(this.cannoMoveClip&&this.cannoMoveClip.parent){
this.cannoMoveClip.removeEventListener(egret.Event.ENTER_FRAME,this.toFrameAni,this);
this.cannoMoveClip.parent.removeChild(this.cannoMoveClip);
}
if(this.pongoMoveClip&&this.pongoMoveClip.parent){
this.pongoMoveClip.removeEventListener(egret.Event.ENTER_FRAME,this.pongoFrameAni,this);
this.pongoMoveClip.parent.removeChild(this.pongoMoveClip);
}
if(this.pongoMvLeftJio&&this.pongoMvLeftJio.parent){
this.pongoMvLeftJio.removeEventListener(egret.Event.COMPLETE,this.pongoRmLeftJio,this);
this.pongoMvLeftJio.parent.removeChild(this.pongoMvLeftJio);
}
if(this.pongoMvRightJio&&this.pongoMvRightJio.parent){
this.pongoMvRightJio.removeEventListener(egret.Event.COMPLETE,this.pongoRmRightJio,this);
this.pongoMvRightJio.parent.removeChild(this.pongoMvRightJio);
}
if(type==ElementType.Pongo||type==ElementType.CANNO){
}else{
this.changeSource("ele" + type + "_png");
}
//特效重置
this.effectType = null;
this.temEffectType = null;
......
......@@ -79,4 +79,9 @@ export enum RecoverName {
BLOCK_STATE = "BLOCK_STATE",
CONVEYOR = 'CONVEYOR',
SAND = 'SAND',
BLOCK = 'BLOCK',
ICE_BLOCK = 'ICE_BLOCK',
DARK_ICE_BLOCK = 'DARK_ICE_BLOCK',
}
\ No newline at end of file
......@@ -44,6 +44,12 @@ export class PropGuide extends egret.DisplayObjectContainer {
if (this.parent) this.parent.removeChild(this)
}, this)
}
changeOffset(offsetY: number){
this.boomBtn.y = offsetY - 55;
this.hammerBtn.y = offsetY - 55;
this.stepBtn.y = offsetY - 55;
this.msgTxt.y = offsetY - 80;
}
init(prop: PropType) {
if (prop == PropType.BOOM) {
this.boomBtn.visible = true;
......
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