Commit d403ece2 authored by zjz1994's avatar zjz1994

代码暂存

parent e4229d77
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -320,6 +320,43 @@
MapData.eleidx = 1;
MapData.elePool = {};
MapData.anispeed = 1000;
MapData.levelData = [
[
[1, 2, 5, 3, 4],
[3, 1, 2, 4, 5],
[2, 5, 3, 4, 1],
[5, 4, 1, 2, 3],
[4, 1, 3, 5, 2],
],
[
[5, 2, 1, 2, 1],
[3, 1, 4, 5, 4],
[2, 5, 3, 5, 1],
[5, 4, 1, 2, 3],
[4, 1, 3, 1, 2],
],
[
[2, 4, 1, 5, 2],
[2, 3, 4, 1, 3],
[4, 1, 3, 2, 3],
[3, 2, 1, 1, 4],
[1, 1, 3, 5, 4],
],
[
[3, 2, 1, 4, 5],
[2, 4, 1, 2, 3],
[2, 3, 2, 3, 3],
[4, 4, 5, 5, 4],
[3, 3, 1, 2, 4],
],
[
[4, 5, 1, 2, 4],
[3, 2, 3, 4, 2],
[1, 5, 2, 3, 5],
[4, 5, 5, 1, 3],
[1, 2, 3, 2, 4],
]
];
return MapData;
}());
//# sourceMappingURL=MapData.js.map
......@@ -339,6 +376,8 @@
_this._gametime = 60;
_this._gamestat = 2;
_this.ingameover = false;
_this.ingame = true;
_this.level = 0;
_this._seq = 1;
_this.sptime = Date.now();
_this._score = 0;
......@@ -461,6 +500,7 @@
this.score = 0;
this.gametime = time;
this.seq = 1;
this.level = level;
this.ingameover = false;
this.changeHomeShow(mode);
this.initContainer();
......@@ -517,6 +557,7 @@
this.anicontainer.removeChild(this.selectimg);
this.selectArr = new Array();
this.gametime = time;
this.level = level;
this.ingameover = false;
this.seq = 1;
this.changeHomeShow(mode);
......@@ -541,13 +582,7 @@
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],
];
testdata = MapData.levelData[this.level];
this.levelData = testdata;
this.fall("newlevel");
return [2];
......@@ -560,9 +595,18 @@
this.selectArr = new Array();
this.changeEnable(true);
};
GameView.prototype.pause = function () {
console.log("游戏暂停");
this.ingame = false;
};
GameView.prototype.resume = function () {
console.log("游戏继续");
this.lastframeTime = Date.now();
this.ingame = true;
};
GameView.prototype.onUpdate = function () {
var ntime = Date.now();
if (this.gamestat == 1) {
if (this.gamestat == 1 && this.ingame) {
var passtime = ntime - this.lastframeTime;
if (ntime - this.lastatime >= 5000 && !this.ination && this.canation && this.selectArr.length == 0) {
this.attionEliShow();
......@@ -601,13 +645,7 @@
else {
this.lattices = {};
}
var testdata = [
[1, 2, 5, 3, 4],
[3, 1, 5, 4, 5],
[2, 5, 3, 5, 1],
[5, 4, 5, 2, 3],
[4, 1, 5, 5, 2],
];
var testdata = MapData.levelData[this.level];
this.levelData = testdata;
for (var r = 0; r < testdata.length; r++) {
var rdata = testdata[r];
......@@ -758,6 +796,7 @@
engine.Tween.removeTweens(snode1);
engine.Tween.removeTweens(snode2);
if (this.eliminateArr.length > 0) {
this.inEliminate = true;
engine.Tween.get(snode1).to({
x: snode2x,
y: snode2y
......@@ -1632,6 +1671,8 @@
engine.globalEvent.addEventListener('game-init', _this.init, _this);
engine.globalEvent.addEventListener('game-reset', _this.reset, _this);
engine.globalEvent.addEventListener('game-start', _this.start, _this);
engine.globalEvent.addEventListener('game-pause', _this.pause, _this);
engine.globalEvent.addEventListener('game-resume', _this.resume, _this);
return _this;
}
GameWrapper.prototype.init = function (event) {
......@@ -1651,6 +1692,12 @@
GameWrapper.prototype.start = function () {
this._gameView.start();
};
GameWrapper.prototype.pause = function () {
this._gameView.pause();
};
GameWrapper.prototype.resume = function () {
this._gameView.resume();
};
return GameWrapper;
}(engine.Container));
//# sourceMappingURL=GameWrapper.js.map
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -96,6 +96,12 @@
},
"game-start": {
"alias": "开始"
},
"game-pause": {
"alias": "暂停"
},
"game-resume": {
"alias": "继续"
}
},
"out": {
......
......@@ -69,6 +69,8 @@ export default class GameView extends engine.Container {
jtex2;
jtey2;
ingame = true;
level = 0;
set gamestat(stat){//1游戏中,2,游戏外
this._gamestat = stat;
if(stat==2){
......@@ -223,6 +225,7 @@ export default class GameView extends engine.Container {
this.score = 0;
this.gametime = time;
this.seq = 1;
this.level = level;
this.ingameover = false;
this.changeHomeShow(mode);
this.initContainer();
......@@ -272,6 +275,7 @@ export default class GameView extends engine.Container {
this.anicontainer.removeChild(this.selectimg);
this.selectArr = new Array();
this.gametime = time;
this.level = level;
this.ingameover = false;
this.seq = 1;
this.changeHomeShow(mode);
......@@ -298,13 +302,7 @@ export default class GameView extends engine.Container {
})
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],
];
let testdata = MapData.levelData[this.level];
this.levelData = testdata;
this.fall("newlevel");
}
......@@ -313,9 +311,18 @@ export default class GameView extends engine.Container {
this.selectArr = new Array();
this.changeEnable(true);
}
pause(){
console.log("游戏暂停");
this.ingame = false;
}
resume(){
console.log("游戏继续");
this.lastframeTime = Date.now();
this.ingame = true;
}
onUpdate(){
let ntime = Date.now();
if(this.gamestat==1){
if(this.gamestat==1&&this.ingame){
let passtime = ntime - this.lastframeTime;
if(ntime-this.lastatime>=5000&&!this.ination&&this.canation&&this.selectArr.length==0){
this.attionEliShow();
......@@ -355,20 +362,8 @@ export default class GameView extends engine.Container {
this.lattices = {};
}
let testdata = [
[1,2,5,3,4],
[3,1,5,4,5],
[2,5,3,5,1],
[5,4,5,2,3],
[4,1,5,5,2],
];
// let testdata = [
// [1,2,1,4,1],
// [3,1,4,5,4],
// [2,5,3,5,1],
// [5,4,1,2,3],
// [4,1,3,1,2],
// ];
let testdata = MapData.levelData[this.level];
this.levelData = testdata;
for(let r=0;r<testdata.length;r++){
......@@ -549,6 +544,7 @@ export default class GameView extends engine.Container {
engine.Tween.removeTweens(snode2);
if(this.eliminateArr.length>0){
this.inEliminate = true;
engine.Tween.get(snode1).to({
x:snode2x,
y:snode2y
......
......@@ -17,6 +17,8 @@ export class GameWrapper extends engine.Container {
engine.globalEvent.addEventListener('game-init',this.init,this);
engine.globalEvent.addEventListener('game-reset',this.reset,this);
engine.globalEvent.addEventListener('game-start',this.start,this);
engine.globalEvent.addEventListener('game-pause',this.pause,this);
engine.globalEvent.addEventListener('game-resume',this.resume,this);
}
init(event:engine.Event){
......@@ -36,4 +38,10 @@ export class GameWrapper extends engine.Container {
start(){
this._gameView.start();
}
pause(){
this._gameView.pause();
}
resume(){
this._gameView.resume();
}
}
......@@ -34,6 +34,44 @@ export default class MapData{
static birdTex:engine.Texture;
static koalaTex:engine.Texture;
static levelData:Array<Array<Array<number>>> = [
[
[1,2,5,3,4],
[3,1,2,4,5],
[2,5,3,4,1],
[5,4,1,2,3],
[4,1,3,5,2],
],
[
[5,2,1,2,1],
[3,1,4,5,4],
[2,5,3,5,1],
[5,4,1,2,3],
[4,1,3,1,2],
],
[
[2,4,1,5,2],
[2,3,4,1,3],
[4,1,3,2,3],
[3,2,1,1,4],
[1,1,3,5,4],
],
[
[3,2,1,4,5],
[2,4,1,2,3],
[2,3,2,3,3],
[4,4,5,5,4],
[3,3,1,2,4],
],
[
[4,5,1,2,4],
[3,2,3,4,2],
[1,5,2,3,5],
[4,5,5,1,3],
[1,2,3,2,4],
]
]
static getRy(r){
return this.paddingb+r*(this.itemsize+this.paddingi);
}
......
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