Commit 1c884ff1 authored by zjz1994's avatar zjz1994

代码暂存

parent d92dfed4
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -24,7 +24,6 @@
_this.width = MapData.itemsize;
_this.height = MapData.itemsize;
_this.anchorX = MapData.itemsize / 2;
_this.anchorY = MapData.itemsize;
_this.eimage = new engine.Image();
_this.addChild(_this.eimage);
_this.touch = true;
......@@ -40,8 +39,10 @@
configurable: true
});
Element.prototype.init = function (type) {
this.anchorY = MapData.itemsize;
this.scaleX = 1;
this.scaleY = 1;
this.alpha = 1;
this.type = type;
var ename = MapData.getEtypeImgName(type);
var imgwid = this.eimage.texture.width;
......@@ -130,6 +131,7 @@
};
return Element;
}(engine.Container));
//# sourceMappingURL=Element.js.map
var ElementType;
(function (ElementType) {
......@@ -284,6 +286,7 @@
_this.homey = -20;
_this.ination = false;
_this.canation = true;
_this.score = 0;
_this.once(engine.Event.ADDED_TO_STAGE, _this.setup, _this);
return _this;
}
......@@ -298,7 +301,6 @@
this.homeimg.x = this.homex;
this.homeimg.y = this.homey;
this.homeimg.stop();
console.log("房子动画", this.homeimg);
this.container = new engine.Container();
this.addChild(this.container);
this.container.y = this.conty;
......@@ -331,14 +333,63 @@
this.lastframeTime = Date.now();
this.lastatime = Date.now();
this.addEventListener(engine.Event.ENTER_FRAME, this.onUpdate, this);
var testbtn = new engine.Label();
testbtn.text = "reset";
testbtn.size = 56;
testbtn.width = 200;
testbtn.height = 100;
this.addChild(testbtn);
testbtn.y = 900;
testbtn.fillColor = "red";
testbtn.addEventListener(engine.MouseEvent.CLICK, this.reset, this);
};
GameView.prototype.playComp = function () {
this.homeimg.stop(1);
};
GameView.prototype.init = function () {
this.score = 0;
this.initContainer();
};
GameView.prototype.reset = function () {
return tslib.__awaiter(this, void 0, void 0, function () {
var key, rcname, rcele, rcelex, rceley, rcetype, fallpro, testdata;
return tslib.__generator(this, function (_a) {
switch (_a.label) {
case 0:
this.anicontainer.removeChild(this.selectimg);
this.selectArr = new Array();
this.changeEnable(false);
for (key in this.lattices) {
rcname = this.lattices[key];
rcele = this.container.getChildByName(rcname);
rcelex = rcele.x;
rceley = rcele.y;
rcetype = rcele.type;
this.container.removeChild(rcele);
this.lattices[key] = "empty";
this.goDisplayAni(rcetype, rcelex, rceley);
}
fallpro = new Promise(function (res) {
setTimeout(function () {
res();
}, 300);
});
return [4, fallpro];
case 1:
_a.sent();
testdata = [
[1, 2, 5, 3, 4],
[3, 1, 4, 4, 5],
[2, 5, 3, 5, 1],
[5, 4, 1, 2, 3],
[4, 1, 3, 5, 2],
];
this.levelData = testdata;
this.fall("newlevel");
return [2];
}
});
});
};
GameView.prototype.start = function () {
};
......@@ -357,14 +408,29 @@
this.lastframeTime = ntime;
};
GameView.prototype.initContainer = function () {
this.lattices = {};
if (this.lattices) {
for (var key in this.lattices) {
var rcname = this.lattices[key];
var rcele = this.container.getChildByName(rcname);
if (rcele) {
var rcetype = rcele.type;
this.container.removeChild(rcele);
this.lattices[key] = "empty";
MapData.recoverEle(rcele, rcetype);
}
}
}
else {
this.lattices = {};
}
var testdata = [
[1, 2, 5, 3, 4],
[3, 1, 4, 4, 5],
[3, 1, 5, 4, 5],
[2, 5, 3, 5, 1],
[5, 4, 1, 2, 3],
[4, 1, 3, 5, 2],
[5, 4, 5, 2, 3],
[4, 1, 5, 5, 2],
];
this.levelData = testdata;
for (var r = 0; r < testdata.length; r++) {
var rdata = testdata[r];
for (var c = 0; c < rdata.length; c++) {
......@@ -518,6 +584,7 @@
return tslib.__generator(this, function (_a) {
switch (_a.label) {
case 0:
console.log(JSON.stringify(this.eliminateArr));
for (i = 0; i < this.eliminateArr.length; i++) {
ielidata = this.eliminateArr[i];
ielidxname = ielidata.idxname;
......@@ -553,7 +620,8 @@
});
});
};
GameView.prototype.fall = function () {
GameView.prototype.fall = function (type) {
if (type === void 0) { type = "normal"; }
return tslib.__awaiter(this, void 0, void 0, function () {
var fallData, fcutr, fc, r, c, idxname, elename, frcname, fetype, fele, cutr, fepos, fallPromise, _loop_1, this_1, f, isdiedata;
return tslib.__generator(this, function (_a) {
......@@ -571,7 +639,13 @@
if (elename == "empty") {
frcname = this.getFallRcEle(r, c);
if (!frcname) {
fetype = MapData.getRandEtype();
fetype = void 0;
if (type == "normal") {
fetype = MapData.getRandEtype();
}
else {
fetype = this.levelData[r][c];
}
fele = MapData.getOneEle(fetype);
cutr = fcutr[c];
fepos = MapData.getRCPos(cutr, c);
......@@ -647,6 +721,30 @@
});
});
};
GameView.prototype.goDisplayAni = function (ielitype, ielix, ieliy) {
var _this = this;
var aniele = MapData.getOneEle(ielitype);
aniele.alpha = 0;
var anix = ielix;
var aniy = ieliy + this.conty;
this.anicontainer.addChild(aniele);
aniele.touch = false;
aniele.x = anix;
aniele.y = aniy;
aniele.alpha = 1;
aniele.anchorY = MapData.itemsize / 2;
engine.Tween.removeTweens(aniele);
engine.Tween.get(aniele)
.to({
scaleX: 0,
scaleY: 0,
alpha: 0
}, 300)
.call(function () {
_this.anicontainer.removeChild(aniele);
MapData.recoverEle(aniele, ielitype);
});
};
GameView.prototype.goHomeAni = function (ielitype, ielix, ieliy) {
var aniele = MapData.getOneEle(ielitype);
aniele.alpha = 0;
......@@ -669,6 +767,7 @@
}
if (v) {
this.lastatime = Date.now();
this.ination = false;
}
this.canation = v;
};
......@@ -1039,6 +1138,7 @@
return eletype;
};
GameView.prototype.checkAddEli = function (etype, earr) {
console.log(JSON.stringify(earr));
for (var e = 0; e < earr.length; e++) {
var ename = earr[e];
var needadd = true;
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -48,6 +48,7 @@ export default class GameView extends engine.Container {
ination = false;
canation = true;
score = 0;
setup() {
MapData.initPoolEle();
......@@ -62,7 +63,7 @@ export default class GameView extends engine.Container {
this.homeimg.x = this.homex;
this.homeimg.y = this.homey;
this.homeimg.stop();
console.log("房子动画",this.homeimg);
// console.log("房子动画",this.homeimg);
this.container = new engine.Container();
this.addChild(this.container);
......@@ -104,17 +105,61 @@ export default class GameView extends engine.Container {
this.lastframeTime = Date.now();
this.lastatime = Date.now();
this.addEventListener(engine.Event.ENTER_FRAME,this.onUpdate,this);
//测试
let testbtn = new engine.Label();
testbtn.text = "reset";
testbtn.size = 56;
testbtn.width = 200;
testbtn.height = 100;
this.addChild(testbtn);
testbtn.y = 900;
testbtn.fillColor = "red";
testbtn.addEventListener(engine.MouseEvent.CLICK,this.reset,this);
}
playComp(){
this.homeimg.stop(1);
}
init(){
this.score = 0;
this.initContainer();
}
reset(){
levelData;
async reset(){
this.anicontainer.removeChild(this.selectimg);
this.selectArr = new Array();
this.changeEnable(false);
for(let key in this.lattices){
let rcname = this.lattices[key];
let rcele:Element = this.container.getChildByName(rcname);
let rcelex = rcele.x;
let rceley = rcele.y;
let rcetype = rcele.type;
this.container.removeChild(rcele);
this.lattices[key] = "empty";
this.goDisplayAni(rcetype,rcelex,rceley);
}
let fallpro = new Promise(res=>{
setTimeout(function(){
res();
},300);
})
await fallpro;
let testdata = [
[1,2,5,3,4],
[3,1,4,4,5],
[2,5,3,5,1],
[5,4,1,2,3],
[4,1,3,5,2],
];
this.levelData = testdata;
this.fall("newlevel");
}
start(){
......@@ -135,14 +180,30 @@ export default class GameView extends engine.Container {
this.lastframeTime = ntime;
}
initContainer(){
this.lattices = {};
if(this.lattices){
for(let key in this.lattices){
let rcname = this.lattices[key];
let rcele:Element = this.container.getChildByName(rcname);
if(rcele){
let rcetype = rcele.type;
this.container.removeChild(rcele);
this.lattices[key] = "empty";
MapData.recoverEle(rcele,rcetype);
}
}
}else{
this.lattices = {};
}
let testdata = [
[1,2,5,3,4],
[3,1,4,4,5],
[3,1,5,4,5],
[2,5,3,5,1],
[5,4,1,2,3],
[4,1,3,5,2],
[5,4,5,2,3],
[4,1,5,5,2],
]
this.levelData = testdata;
for(let r=0;r<testdata.length;r++){
let rdata = testdata[r];
for(let c=0;c<rdata.length;c++){
......@@ -317,6 +378,7 @@ export default class GameView extends engine.Container {
//消除
async eliminate(){
console.log(JSON.stringify(this.eliminateArr));
for(let i=0;i<this.eliminateArr.length;i++){
let ielidata = this.eliminateArr[i];
let ielidxname = ielidata.idxname;
......@@ -350,7 +412,7 @@ export default class GameView extends engine.Container {
this.homeimg.play(1,1);
}
//掉落
async fall(){
async fall(type="normal"){
let fallData = new Array();
let fcutr = new Array();
......@@ -366,7 +428,13 @@ export default class GameView extends engine.Container {
if(elename=="empty"){
let frcname = this.getFallRcEle(r,c);
if(!frcname){
let fetype = MapData.getRandEtype();
let fetype;
if(type=="normal"){
fetype = MapData.getRandEtype();
}else{
fetype = this.levelData[r][c];
}
let fele = MapData.getOneEle(fetype);
let cutr = fcutr[c];
......@@ -440,6 +508,34 @@ export default class GameView extends engine.Container {
//检查死图
}
}
//原地消失
goDisplayAni(ielitype,ielix,ieliy){
let aniele = MapData.getOneEle(ielitype);
aniele.alpha = 0;
let anix = ielix;
let aniy = ieliy+this.conty;
this.anicontainer.addChild(aniele);
aniele.touch = false;
aniele.x = anix;
aniele.y = aniy;
aniele.alpha = 1;
aniele.anchorY = MapData.itemsize/2;
engine.Tween.removeTweens(aniele);
engine.Tween.get(aniele)
.to({
scaleX:0,
scaleY:0,
alpha:0
},300)
.call(()=>{
this.anicontainer.removeChild(aniele);
MapData.recoverEle(aniele,ielitype);
})
}
//飞到小屋
goHomeAni(ielitype,ielix,ieliy){
let aniele = MapData.getOneEle(ielitype);
aniele.alpha = 0;
......@@ -469,6 +565,7 @@ export default class GameView extends engine.Container {
}
if(v){
this.lastatime = Date.now();
this.ination = false;
}
this.canation = v;
}
......@@ -894,6 +991,7 @@ export default class GameView extends engine.Container {
return eletype;
}
checkAddEli(etype,earr){
console.log(JSON.stringify(earr));
for(let e=0;e<earr.length;e++){
let ename = earr[e];
......
......@@ -17,8 +17,7 @@ export default class Element extends engine.Container{
this.height = MapData.itemsize;
this.anchorX = MapData.itemsize/2;
// this.anchorY = MapData.itemsize/2;
this.anchorY = MapData.itemsize;
this.eimage = new engine.Image();
this.addChild(this.eimage);
......@@ -26,9 +25,10 @@ export default class Element extends engine.Container{
this.addEventListener(engine.MouseEvent.CLICK,this.selectele,this);
}
init(type:ElementType){
this.anchorY = MapData.itemsize;
this.scaleX = 1;
this.scaleY = 1;
this.alpha = 1;
this.type = type;
let ename = MapData.getEtypeImgName(type);
// this.eimage.texture = MapData.getTextureType(type);
......
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