Commit 9bbe9bd6 authored by wildfirecode's avatar wildfirecode

1

parent b28aabbe
No preview for this file type
......@@ -42,9 +42,9 @@
<script src="output.js"></script>
<script>
var __t0__ = Date.now();
var __debug__ = 0;
var __debug__ = 1;
var __monkeyHandSize__ = 50;
var __boxMoveSpeed__ = 1.5;
var __boxMoveSpeed__ = 6;
var __boxmap__ = {
coin:{ award: 0, skin: 'resource/assets/startScene/coin.json', offset: [117, 68] },
gift:{ award: 0, skin: 'resource/assets/startScene/gift.json', offset: [119, 103] },
......
{"file":"coin.png","frames":{
"11":{"x":0,"y":0,"w":217,"h":160,"offX":12,"offY":12,"sourceW":246,"sourceH":181},
"10":{"x":219,"y":0,"w":214,"h":159,"offX":13,"offY":14,"sourceW":246,"sourceH":181},
"09":{"x":435,"y":0,"w":210,"h":156,"offX":15,"offY":16,"sourceW":246,"sourceH":181},
"08":{"x":647,"y":0,"w":207,"h":154,"offX":16,"offY":18,"sourceW":246,"sourceH":181},
"07":{"x":647,"y":156,"w":203,"h":153,"offX":18,"offY":19,"sourceW":246,"sourceH":181},
"00":{"x":852,"y":163,"w":109,"h":111,"offX":64,"offY":10,"sourceW":246,"sourceH":181},
"01":{"x":856,"y":0,"w":109,"h":161,"offX":61,"offY":11,"sourceW":246,"sourceH":181},
"03":{"x":637,"y":311,"w":189,"h":158,"offX":24,"offY":14,"sourceW":246,"sourceH":181},
"02":{"x":828,"y":311,"w":186,"h":160,"offX":25,"offY":12,"sourceW":246,"sourceH":181},
"06":{"x":435,"y":158,"w":200,"h":153,"offX":19,"offY":19,"sourceW":246,"sourceH":181},
"07":{"x":647,"y":156,"w":203,"h":153,"offX":18,"offY":19,"sourceW":246,"sourceH":181},
"11":{"x":0,"y":0,"w":217,"h":160,"offX":12,"offY":12,"sourceW":246,"sourceH":181},
"05":{"x":0,"y":162,"w":196,"h":155,"offX":21,"offY":18,"sourceW":246,"sourceH":181},
"04":{"x":219,"y":161,"w":193,"h":158,"offX":22,"offY":16,"sourceW":246,"sourceH":181},
"03":{"x":637,"y":311,"w":189,"h":158,"offX":24,"offY":14,"sourceW":246,"sourceH":181},
"02":{"x":828,"y":311,"w":186,"h":160,"offX":25,"offY":12,"sourceW":246,"sourceH":181},
"01":{"x":856,"y":0,"w":109,"h":161,"offX":61,"offY":11,"sourceW":246,"sourceH":181}}}
\ No newline at end of file
"10":{"x":219,"y":0,"w":214,"h":159,"offX":13,"offY":14,"sourceW":246,"sourceH":181},
"09":{"x":435,"y":0,"w":210,"h":156,"offX":15,"offY":16,"sourceW":246,"sourceH":181},
"08":{"x":647,"y":0,"w":207,"h":154,"offX":16,"offY":18,"sourceW":246,"sourceH":181}}}
\ No newline at end of file
{"file":"gift.png","frames":{
"09":{"x":0,"y":0,"w":208,"h":205,"offX":17,"offY":24,"sourceW":237,"sourceH":239},
"08":{"x":210,"y":0,"w":205,"h":202,"offX":18,"offY":27,"sourceW":237,"sourceH":239},
"07":{"x":210,"y":204,"w":202,"h":199,"offX":19,"offY":30,"sourceW":237,"sourceH":239},
"00":{"x":0,"y":615,"w":152,"h":148,"offX":40,"offY":20,"sourceW":237,"sourceH":239},
"01":{"x":194,"y":811,"w":152,"h":209,"offX":40,"offY":20,"sourceW":237,"sourceH":239},
"03":{"x":200,"y":405,"w":189,"h":205,"offX":23,"offY":24,"sourceW":237,"sourceH":239},
"02":{"x":0,"y":406,"w":186,"h":207,"offX":24,"offY":21,"sourceW":237,"sourceH":239},
"06":{"x":0,"y":207,"w":198,"h":197,"offX":20,"offY":32,"sourceW":237,"sourceH":239},
"07":{"x":210,"y":204,"w":202,"h":199,"offX":19,"offY":30,"sourceW":237,"sourceH":239},
"05":{"x":188,"y":612,"w":195,"h":197,"offX":21,"offY":31,"sourceW":237,"sourceH":239},
"04":{"x":0,"y":811,"w":192,"h":200,"offX":22,"offY":28,"sourceW":237,"sourceH":239},
"03":{"x":200,"y":405,"w":189,"h":205,"offX":23,"offY":24,"sourceW":237,"sourceH":239},
"02":{"x":0,"y":406,"w":186,"h":207,"offX":24,"offY":21,"sourceW":237,"sourceH":239},
"01":{"x":194,"y":811,"w":152,"h":209,"offX":40,"offY":20,"sourceW":237,"sourceH":239}}}
\ No newline at end of file
"09":{"x":0,"y":0,"w":208,"h":205,"offX":17,"offY":24,"sourceW":237,"sourceH":239},
"08":{"x":210,"y":0,"w":205,"h":202,"offX":18,"offY":27,"sourceW":237,"sourceH":239}}}
\ No newline at end of file
{"file":"gift2.png","frames":{
"11":{"x":0,"y":0,"w":225,"h":157,"offX":8,"offY":8,"sourceW":244,"sourceH":184},
"10":{"x":227,"y":0,"w":222,"h":158,"offX":10,"offY":10,"sourceW":244,"sourceH":184},
"09":{"x":451,"y":0,"w":217,"h":158,"offX":13,"offY":13,"sourceW":244,"sourceH":184},
"08":{"x":670,"y":0,"w":213,"h":158,"offX":15,"offY":16,"sourceW":244,"sourceH":184},
"07":{"x":0,"y":159,"w":209,"h":158,"offX":17,"offY":18,"sourceW":244,"sourceH":184},
"00":{"x":347,"y":320,"w":156,"h":157,"offX":42,"offY":7,"sourceW":244,"sourceH":184},
"01":{"x":189,"y":320,"w":156,"h":157,"offX":42,"offY":7,"sourceW":244,"sourceH":184},
"03":{"x":817,"y":160,"w":191,"h":158,"offX":27,"offY":10,"sourceW":244,"sourceH":184},
"02":{"x":0,"y":319,"w":187,"h":157,"offX":29,"offY":8,"sourceW":244,"sourceH":184},
"06":{"x":211,"y":160,"w":204,"h":158,"offX":20,"offY":18,"sourceW":244,"sourceH":184},
"07":{"x":0,"y":159,"w":209,"h":158,"offX":17,"offY":18,"sourceW":244,"sourceH":184},
"11":{"x":0,"y":0,"w":225,"h":157,"offX":8,"offY":8,"sourceW":244,"sourceH":184},
"05":{"x":417,"y":160,"w":200,"h":158,"offX":22,"offY":16,"sourceW":244,"sourceH":184},
"04":{"x":619,"y":160,"w":196,"h":158,"offX":24,"offY":13,"sourceW":244,"sourceH":184},
"03":{"x":817,"y":160,"w":191,"h":158,"offX":27,"offY":10,"sourceW":244,"sourceH":184},
"02":{"x":0,"y":319,"w":187,"h":157,"offX":29,"offY":8,"sourceW":244,"sourceH":184},
"01":{"x":189,"y":320,"w":156,"h":157,"offX":42,"offY":7,"sourceW":244,"sourceH":184}}}
\ No newline at end of file
"10":{"x":227,"y":0,"w":222,"h":158,"offX":10,"offY":10,"sourceW":244,"sourceH":184},
"09":{"x":451,"y":0,"w":217,"h":158,"offX":13,"offY":13,"sourceW":244,"sourceH":184},
"08":{"x":670,"y":0,"w":213,"h":158,"offX":15,"offY":16,"sourceW":244,"sourceH":184}}}
\ No newline at end of file
{"file":"goldenbox.png","frames":{
"11":{"x":0,"y":0,"w":231,"h":132,"offX":14,"offY":22,"sourceW":260,"sourceH":170},
"10":{"x":233,"y":0,"w":228,"h":128,"offX":15,"offY":24,"sourceW":260,"sourceH":170},
"09":{"x":463,"y":0,"w":224,"h":127,"offX":17,"offY":26,"sourceW":260,"sourceH":170},
"08":{"x":689,"y":0,"w":221,"h":127,"offX":19,"offY":28,"sourceW":260,"sourceH":170},
"07":{"x":463,"y":129,"w":217,"h":127,"offX":21,"offY":30,"sourceW":260,"sourceH":170},
"00":{"x":208,"y":259,"w":163,"h":126,"offX":47,"offY":21,"sourceW":260,"sourceH":170},
"01":{"x":848,"y":258,"w":163,"h":126,"offX":47,"offY":21,"sourceW":260,"sourceH":170},
"03":{"x":444,"y":258,"w":202,"h":127,"offX":29,"offY":24,"sourceW":260,"sourceH":170},
"02":{"x":648,"y":258,"w":198,"h":127,"offX":31,"offY":22,"sourceW":260,"sourceH":170},
"06":{"x":682,"y":129,"w":213,"h":127,"offX":23,"offY":30,"sourceW":260,"sourceH":170},
"07":{"x":463,"y":129,"w":217,"h":127,"offX":21,"offY":30,"sourceW":260,"sourceH":170},
"11":{"x":0,"y":0,"w":231,"h":132,"offX":14,"offY":22,"sourceW":260,"sourceH":170},
"05":{"x":233,"y":130,"w":209,"h":127,"offX":25,"offY":28,"sourceW":260,"sourceH":170},
"04":{"x":0,"y":134,"w":206,"h":127,"offX":27,"offY":26,"sourceW":260,"sourceH":170},
"03":{"x":444,"y":258,"w":202,"h":127,"offX":29,"offY":24,"sourceW":260,"sourceH":170},
"02":{"x":648,"y":258,"w":198,"h":127,"offX":31,"offY":22,"sourceW":260,"sourceH":170},
"01":{"x":848,"y":258,"w":163,"h":126,"offX":47,"offY":21,"sourceW":260,"sourceH":170}}}
\ No newline at end of file
"10":{"x":233,"y":0,"w":228,"h":128,"offX":15,"offY":24,"sourceW":260,"sourceH":170},
"09":{"x":463,"y":0,"w":224,"h":127,"offX":17,"offY":26,"sourceW":260,"sourceH":170},
"08":{"x":689,"y":0,"w":221,"h":127,"offX":19,"offY":28,"sourceW":260,"sourceH":170}}}
\ No newline at end of file
{"file":"net.png","frames":{
"10":{"x":1222,"y":0,"w":609,"h":428,"offX":69,"offY":104,"sourceW":750,"sourceH":558},
"09":{"x":611,"y":0,"w":609,"h":428,"offX":69,"offY":104,"sourceW":750,"sourceH":558},
"08":{"x":0,"y":430,"w":610,"h":423,"offX":68,"offY":100,"sourceW":750,"sourceH":558},
"07":{"x":1224,"y":430,"w":610,"h":389,"offX":68,"offY":84,"sourceW":750,"sourceH":558},
"06":{"x":614,"y":1206,"w":610,"h":372,"offX":68,"offY":39,"sourceW":750,"sourceH":558},
"05":{"x":1226,"y":1206,"w":610,"h":371,"offX":68,"offY":19,"sourceW":750,"sourceH":558},
"04":{"x":0,"y":855,"w":612,"h":371,"offX":65,"offY":32,"sourceW":750,"sourceH":558},
"03":{"x":1224,"y":821,"w":610,"h":383,"offX":68,"offY":59,"sourceW":750,"sourceH":558},
"02":{"x":612,"y":430,"w":610,"h":414,"offX":68,"offY":81,"sourceW":750,"sourceH":558},
"01":{"x":0,"y":0,"w":609,"h":428,"offX":69,"offY":104,"sourceW":750,"sourceH":558}}}
\ No newline at end of file
"00":{"x":0,"y":430,"w":609,"h":428,"offX":69,"offY":104,"sourceW":750,"sourceH":558},
"01":{"x":1222,"y":0,"w":609,"h":428,"offX":69,"offY":104,"sourceW":750,"sourceH":558},
"03":{"x":611,"y":855,"w":610,"h":383,"offX":68,"offY":59,"sourceW":750,"sourceH":558},
"02":{"x":1223,"y":430,"w":610,"h":414,"offX":68,"offY":81,"sourceW":750,"sourceH":558},
"06":{"x":0,"y":1240,"w":610,"h":372,"offX":68,"offY":39,"sourceW":750,"sourceH":558},
"07":{"x":1223,"y":846,"w":610,"h":389,"offX":68,"offY":84,"sourceW":750,"sourceH":558},
"05":{"x":612,"y":1610,"w":610,"h":371,"offX":68,"offY":19,"sourceW":750,"sourceH":558},
"04":{"x":1223,"y":1237,"w":612,"h":371,"offX":65,"offY":32,"sourceW":750,"sourceH":558},
"10":{"x":611,"y":0,"w":609,"h":428,"offX":69,"offY":104,"sourceW":750,"sourceH":558},
"09":{"x":0,"y":0,"w":609,"h":428,"offX":69,"offY":104,"sourceW":750,"sourceH":558},
"08":{"x":611,"y":430,"w":610,"h":423,"offX":68,"offY":100,"sourceW":750,"sourceH":558}}}
\ No newline at end of file
{"file":"silverbox.png","frames":{
"12":{"x":588,"y":266,"w":160,"h":130,"offX":67,"offY":12,"sourceW":273,"sourceH":166},
"11":{"x":0,"y":0,"w":245,"h":131,"offX":20,"offY":13,"sourceW":273,"sourceH":166},
"10":{"x":247,"y":0,"w":241,"h":131,"offX":22,"offY":15,"sourceW":273,"sourceH":166},
"09":{"x":490,"y":0,"w":237,"h":131,"offX":24,"offY":18,"sourceW":273,"sourceH":166},
"08":{"x":729,"y":0,"w":233,"h":131,"offX":26,"offY":21,"sourceW":273,"sourceH":166},
"07":{"x":0,"y":133,"w":229,"h":131,"offX":28,"offY":23,"sourceW":273,"sourceH":166},
"00":{"x":750,"y":266,"w":160,"h":130,"offX":67,"offY":12,"sourceW":273,"sourceH":166},
"01":{"x":588,"y":266,"w":160,"h":130,"offX":67,"offY":12,"sourceW":273,"sourceH":166},
"03":{"x":0,"y":266,"w":213,"h":131,"offX":36,"offY":15,"sourceW":273,"sourceH":166},
"02":{"x":215,"y":266,"w":209,"h":131,"offX":38,"offY":13,"sourceW":273,"sourceH":166},
"06":{"x":231,"y":133,"w":225,"h":131,"offX":30,"offY":23,"sourceW":273,"sourceH":166},
"12":{"x":426,"y":266,"w":160,"h":130,"offX":67,"offY":12,"sourceW":273,"sourceH":166},
"07":{"x":0,"y":133,"w":229,"h":131,"offX":28,"offY":23,"sourceW":273,"sourceH":166},
"11":{"x":0,"y":0,"w":245,"h":131,"offX":20,"offY":13,"sourceW":273,"sourceH":166},
"05":{"x":458,"y":133,"w":221,"h":131,"offX":32,"offY":21,"sourceW":273,"sourceH":166},
"04":{"x":681,"y":133,"w":217,"h":131,"offX":34,"offY":18,"sourceW":273,"sourceH":166},
"03":{"x":0,"y":266,"w":213,"h":131,"offX":36,"offY":15,"sourceW":273,"sourceH":166},
"02":{"x":215,"y":266,"w":209,"h":131,"offX":38,"offY":13,"sourceW":273,"sourceH":166},
"01":{"x":426,"y":266,"w":160,"h":130,"offX":67,"offY":12,"sourceW":273,"sourceH":166}}}
\ No newline at end of file
"10":{"x":247,"y":0,"w":241,"h":131,"offX":22,"offY":15,"sourceW":273,"sourceH":166},
"09":{"x":490,"y":0,"w":237,"h":131,"offX":24,"offY":18,"sourceW":273,"sourceH":166},
"08":{"x":729,"y":0,"w":233,"h":131,"offX":26,"offY":21,"sourceW":273,"sourceH":166}}}
\ No newline at end of file
{"file":"woodbox.png","frames":{
"11":{"x":0,"y":0,"w":211,"h":148,"offX":9,"offY":6,"sourceW":230,"sourceH":180},
"10":{"x":213,"y":0,"w":207,"h":148,"offX":11,"offY":8,"sourceW":230,"sourceH":180},
"09":{"x":422,"y":0,"w":202,"h":149,"offX":14,"offY":10,"sourceW":230,"sourceH":180},
"08":{"x":626,"y":0,"w":198,"h":149,"offX":16,"offY":13,"sourceW":230,"sourceH":180},
"07":{"x":826,"y":0,"w":194,"h":149,"offX":18,"offY":14,"sourceW":230,"sourceH":180},
"00":{"x":0,"y":301,"w":147,"h":148,"offX":44,"offY":5,"sourceW":230,"sourceH":180},
"01":{"x":149,"y":301,"w":146,"h":148,"offX":44,"offY":5,"sourceW":230,"sourceH":180},
"03":{"x":564,"y":151,"w":177,"h":148,"offX":28,"offY":8,"sourceW":230,"sourceH":180},
"02":{"x":743,"y":151,"w":173,"h":148,"offX":30,"offY":6,"sourceW":230,"sourceH":180},
"06":{"x":0,"y":150,"w":190,"h":149,"offX":21,"offY":14,"sourceW":230,"sourceH":180},
"07":{"x":826,"y":0,"w":194,"h":149,"offX":18,"offY":14,"sourceW":230,"sourceH":180},
"11":{"x":0,"y":0,"w":211,"h":148,"offX":9,"offY":6,"sourceW":230,"sourceH":180},
"05":{"x":192,"y":150,"w":186,"h":149,"offX":23,"offY":13,"sourceW":230,"sourceH":180},
"04":{"x":380,"y":151,"w":182,"h":149,"offX":25,"offY":10,"sourceW":230,"sourceH":180},
"03":{"x":564,"y":151,"w":177,"h":148,"offX":28,"offY":8,"sourceW":230,"sourceH":180},
"02":{"x":743,"y":151,"w":173,"h":148,"offX":30,"offY":6,"sourceW":230,"sourceH":180},
"01":{"x":0,"y":301,"w":146,"h":148,"offX":44,"offY":5,"sourceW":230,"sourceH":180}}}
\ No newline at end of file
"10":{"x":213,"y":0,"w":207,"h":148,"offX":11,"offY":8,"sourceW":230,"sourceH":180},
"09":{"x":422,"y":0,"w":202,"h":149,"offX":14,"offY":10,"sourceW":230,"sourceH":180},
"08":{"x":626,"y":0,"w":198,"h":149,"offX":16,"offY":13,"sourceW":230,"sourceH":180}}}
\ No newline at end of file
......@@ -15,6 +15,10 @@
{
"keys": "ruleBg_png,X_png",
"name": "rule"
},
{
"keys": "guide_tips_png,guide_hand_png,guide_dialog_png",
"name": "guide"
}
],
"resources": [
......@@ -102,18 +106,33 @@
"url": "assets/startScene/woodbox.json",
"type": "sheet",
"name": "woodbox_json",
"subkeys": "01,02,03,04,05,06,07,08,09,10"
"subkeys": "00,01,02,03,04,05,06,07,08,09,10,11"
},
{
"url": "assets/startScene/net.json",
"type": "sheet",
"name": "net_json",
"subkeys": "01,02,03,04,05,06,07,08,09,10"
"subkeys": "00,01,02,03,04,05,06,07,08,09,10"
},
{
"url": "assets/startScene/monkey.png",
"type": "image",
"name": "monkey_png"
},
{
"url": "assets/startScene/guide/guide_tips.png",
"type": "image",
"name": "guide_tips_png"
},
{
"url": "assets/startScene/guide/guide_hand.png",
"type": "image",
"name": "guide_hand_png"
},
{
"url": "assets/startScene/guide/guide_dialog.png",
"type": "image",
"name": "guide_dialog_png"
}
]
}
\ No newline at end of file
......@@ -3,13 +3,13 @@ export default class SheetAnimation extends egret.Bitmap {
private _sheet: egret.SpriteSheet;
private _fps = 24;
private _fpscounter = 1;
totalFrames: number = 10;
totalFrames: number;
onEnterFrame() {
if (this._fpscounter == 1) {
let key = '0' + this._counter;
if (this._counter >= 10)
key = this._counter + '';
const picData = this._sheet.getTexture(key);
this.$setBitmapData(picData);
this.dispatchEvent(new egret.Event('frameUpdate', false, false, this._counter));
......@@ -26,7 +26,7 @@ export default class SheetAnimation extends egret.Bitmap {
set sheet(val: egret.SpriteSheet) {
this._sheet = val;
this.stopAtFirstFrame();
this.totalFrames = this.getTotalFrames();
this.totalFrames = this.getTotalFrames() - 1;
}
private getTotalFrames() {
......@@ -43,6 +43,12 @@ export default class SheetAnimation extends egret.Bitmap {
this.stop();
}
stopAtIdleFrame() {
const picData = this._sheet.getTexture('00');
this.$setBitmapData(picData);
this.stop();
}
set fps(val: number) {
this._fps = val;
}
......@@ -53,12 +59,12 @@ export default class SheetAnimation extends egret.Bitmap {
this.addEventListener(egret.Event.ENTER_FRAME, this.onEnterFrame, this);
}
stop() {
private stop() {
this.removeEventListener(egret.Event.ENTER_FRAME, this.onEnterFrame, this);
}
destroy() {
this.stop();
this._sheet=null;
this._sheet = null;
}
}
\ No newline at end of file
......@@ -3,28 +3,27 @@ export default class Box extends egret.Sprite {
private _pic: SheetAnimation;
private _type: string;
private START_SCALE = 0.5;
private START_X = 395;
private START_X = 375;
private START_Y = 350;
private END_Y = 1100;
private MIDDLE_Y = 800;
speed: number;
static MIDDLE_Y = 800;
speed = 0;
constructor(type) {
super();
this._type = type;
this._pic = new SheetAnimation();
this.addChild(this._pic);
this.speed = __boxMoveSpeed__;
}
private _passMiddleTag: boolean;
onEnterFrame() {
this.y += this.speed;
let distance = this.y - this.START_Y;
const totalDistance = (this.MIDDLE_Y - this.START_Y);
const totalDistance = (Box.MIDDLE_Y - this.START_Y);
if (distance > totalDistance) {
distance = totalDistance;
}
if (this.y > this.MIDDLE_Y && !this._passMiddleTag) {
if (this.y > Box.MIDDLE_Y && !this._passMiddleTag) {
this._passMiddleTag = true;
this.dispatchEvent(new egret.Event('onPassMiddle'));
}
......@@ -83,6 +82,26 @@ export default class Box extends egret.Sprite {
});
}
private _vyStart = 15;
private _vy: number;
private _gy: number;
private _throwStartVY: number;
private _scaleMax = 2;
onThrowTick(): any {
this._vy += this._gy;
this.y += this._vy;
const scale = (this._vyStart * this._scaleMax - Math.abs(this._vy)) / this._vyStart;
this.scaleX = this.scaleY = scale;
}
doThrow(): any {
this._pic.stopAtIdleFrame();
this._throwStartVY = this._vy;
this._vy = -this._vyStart;
this._gy = .2;
}
get vy(){return this._vy}
get type() { return this._type }
get boxData() { return __boxmap__[this._type] }
}
\ No newline at end of file
......@@ -5,18 +5,20 @@ export default class BoxListCtrl {
private _parent: egret.Sprite;
private _boxKeys: string[];
private _boxs: Box[];
private _boxSpeed: number;
constructor(parent: egret.Sprite) {
this._parent = parent;
this._boxs = [];
this.init();
this._boxSpeed = __boxMoveSpeed__;
}
init() {
this._boxKeys = getBoxKeyList();
}
private BOX_CREATE_INTERVAL = 60 * 4;
private BOX_CREATE_INTERVAL = 60 * 1.2;
private _timer: number;
private _currentBoxIndex = 0;
private _frameCounter = 0;
......@@ -44,6 +46,7 @@ export default class BoxListCtrl {
createBox() {
const box = new Box(this._boxKeys[this._currentBoxIndex]);
box.speed = this._boxSpeed;
box.addEventListener('onDisappear', this.onDisappear, this);
this._parent.addChild(box);
box.createBg();
......@@ -52,9 +55,12 @@ export default class BoxListCtrl {
onDisappear(e: egret.Event) {
const currentBox = e.target as Box;
this.removeBoxFromList(currentBox);
}
removeBoxFromList(currentBox: Box) {
const index = this._boxs.indexOf(currentBox);
if (index != -1)
this._boxs.splice(index, 1);
if (index != -1) this._boxs.splice(index, 1);
}
reset() {
......@@ -66,6 +72,7 @@ export default class BoxListCtrl {
createFirstBox() {
return new Promise(async (resolve) => {
const box = new Box(this._boxKeys[this._currentBoxIndex]);
box.speed = this._boxSpeed;
box.addEventListener('onDisappear', this.onDisappear, this);
this._boxs.push(box);
this._parent.addChild(box);
......@@ -75,5 +82,12 @@ export default class BoxListCtrl {
})
}
updateSpeed(val: number) {
this._boxSpeed = val;
this._boxs.forEach((box) => {
box.speed = this._boxSpeed;
});
}
get boxs() { return this._boxs }
}
\ No newline at end of file
......@@ -4,11 +4,13 @@ import Monkey from "./Monkey";
export default class GuideCtrl {
private _main: StartScene;
private _tag: boolean;
private _guideTop: egret.Sprite;
constructor(view: StartScene) {
this._main = view;
this.init();
if (this._tag) {
this._main.guideView.destroy();
this._main.addTouchEvent();
} else {
this.start();
}
......@@ -16,19 +18,72 @@ export default class GuideCtrl {
start(): any {
this._main.monkey.once('onStartShaking', this.onMonkeyStartShaking, this);
this._main.boxList.boxs[0].once('onPassMiddle', this.onPassMiddle, this);
this._main.boxListCtrl.boxs[0].once('onPassMiddle', this.onPassMiddle, this);
this._main.boxListCtrl.updateSpeed(__boxMoveSpeed__ * 4);
}
onPassMiddle() {
this._main.boxList.pause();
this._main.boxListCtrl.pause();
this.addGuide();
this._main.once(egret.TouchEvent.TOUCH_BEGIN, this.onTouch, this);
}
tips;
async addGuide() {
this._guideTop = new egret.Sprite();
this._main.topLay.addChild(this._guideTop);
const hand = await RES.getResAsync('guide_hand_png');
const tips = await RES.getResAsync('guide_tips_png');
const guide_dialog = await RES.getResAsync('guide_dialog_png');
await this.showtipsAni(tips);
await this.showhandAni(hand);
await this.showguideAni(guide_dialog);
}
async showtipsAni(texture) {
const pic = new egret.Bitmap(texture);
pic.anchorOffsetX = pic.width >> 1;
pic.anchorOffsetY = pic.height >> 1;
this._guideTop.addChild(pic);
return new Promise((r) => {
egret.Tween.get(pic).set({ x: 0, y: 700 + 10 })
.to({ x: 750 / 2 }, 200, egret.Ease.getBackOut(3))
.call(() => r(pic));
});
}
async showhandAni(texture) {
const pic = new egret.Bitmap(texture);
pic.anchorOffsetX = pic.width >> 1;
pic.anchorOffsetY = pic.height >> 1;
this._guideTop.addChild(pic);
return new Promise((r) => {
egret.Tween.get(pic).set({ x: 750, y: 700 + 230 }).to({ x: 750 / 2 }, 200, egret.Ease.getBackOut(3))
.call(() => r(pic));
});
}
async showguideAni(texture) {
const pic = new egret.Bitmap(texture);
pic.anchorOffsetX = pic.width >> 1;
pic.anchorOffsetY = pic.height >> 1;
this._guideTop.addChild(pic);
return new Promise((r) => {
egret.Tween.get(pic).set({ x: 750, y: 200 }).to({ x: 200 }, 200, egret.Ease.getBackOut(3))
.call(() => r(pic));
});
}
onTouch() {
// this._main.boxList.resume();
this._main.boxListCtrl.updateSpeed(__boxMoveSpeed__);
this.setTag();
this._main.guideView.destroy();
this._main.onTouch();
egret.Tween.get(this._guideTop).to({ alpha: 0 }, 200).call(() => {
this._main.topLay.removeChild(this._guideTop);
this._guideTop = null;
}, this);
this._main.doAction();
this._main.addTouchEvent();
}
......
......@@ -12,7 +12,7 @@ export default class Monkey extends egret.Sprite {
private targetY = 70;
private targetX = 369;
static RANGE = 60;
private _shakeSpeed = .5;
private _shakeSpeed = 1;
constructor() {
super();
this.anchorOffsetX = 113;
......@@ -28,7 +28,7 @@ export default class Monkey extends egret.Sprite {
await this.createBg();
egret.Tween.get(this)
.set({ scaleX: 0.1, scaleY: 0.1, alpha: .5, rotation: Monkey.RANGE / 3, x: 750 + 100 })
.to({ y: this.targetY, x: this.targetX, scaleX: 1, scaleY: 1, alpha: 1 }, 1000, egret.Ease.getBackInOut(.9))
.to({ y: this.targetY, x: this.targetX, scaleX: 1, scaleY: 1, alpha: 1 }, 1000, egret.Ease.getBackOut(.9))
.wait(500)
.call(this.startShaking, this);
}
......
......@@ -5,15 +5,19 @@ import Monkey from "./Monkey";
import Net from "./Net";
import Guide from "./Guide";
import GuideCtrl from "./GuideCtrl";
import Box from "./Box";
import debug from "./debug";
import LayerTypes from "./data/LayerTypes";
const { TouchEvent } = egret;
export default class StartScene extends Scene {
private _net: Net;
private _monkey: Monkey;
private _shape: egret.Shape;
private _boxList: BoxListCtrl;
private _boxListCtrl: BoxListCtrl;
private _guideView: Guide;
private _guideCtrl: GuideCtrl;
static NET_RANGE = 200;
private _debug: debug;
async start(data?) {
const t1 = Date.now() - __t0__;
console.log(`startScene添加到stage:${t1 / 1000}s`)
......@@ -25,10 +29,10 @@ export default class StartScene extends Scene {
const t2 = Date.now() - __t0__;
console.log(`首屏(背景显示)时间:${t2 / 1000}s`);
this._boxList = new BoxListCtrl(this.getLayer(LayerTypes.box));
await this._boxList.createFirstBox();
this._boxListCtrl = new BoxListCtrl(this.getLayer(LayerTypes.box));
await this._boxListCtrl.createFirstBox();
this._boxList.resume();
this._boxListCtrl.resume();
const t3 = Date.now() - __t0__;
console.log(`关键利益点时间:${t3 / 1000}s`);
......@@ -44,10 +48,8 @@ export default class StartScene extends Scene {
this.getLayer(LayerTypes.net).addChild(net);
this._net = net;
if (__debug__) {
this._shape = new egret.Shape();
this.addChild(this._shape);
this._debug = new debug(this.getLayer(LayerTypes.top));
}
const model = new GamePlayModel();
......@@ -75,19 +77,80 @@ export default class StartScene extends Scene {
}
onTouch() {
this._boxListCtrl.pause();
this.doAction();
}
private _catchedBox: Box;
doAction() {
this._net.doAction();
const catchedBoxs = this._boxListCtrl.boxs.filter(
box => Math.abs(box.y - Box.MIDDLE_Y) < StartScene.NET_RANGE);
const catchedBox = catchedBoxs[0];
if (catchedBox) { //抓住了,box没有办法再过线消失
//先从boxlist中移除,使之不再受到boxlistCtrl的控制
this._boxListCtrl.removeBoxFromList(catchedBox);
this._catchedBox = catchedBox;
catchedBox.doThrow();
this.addThrowTick();
} else {//没有抓住,不需要处理,如果过网了就会自动消失。如果没有过网,下次还能抓。
}
}
addThrowTick() {
this.addEventListener(egret.Event.ENTER_FRAME, this.onThrowTick, this);
}
removeThrowTick() {
this.removeEventListener(egret.Event.ENTER_FRAME, this.onThrowTick, this);
}
onThrowTick() {
this._catchedBox.onThrowTick();
const disX = Math.abs(this._catchedBox.x - this._handX);
const disY = Math.abs(this._catchedBox.y - this._handY);
const dis = 100 + __monkeyHandSize__;
if (disX < dis && disY < dis) {
this.onCatchedByMonkey();
}
else if (this._catchedBox.vy > 0) {
this.onNotCatchedByMonkey();
}
}
private _catchedBoxByMoneky: Box;
onCatchedByMonkey() {
this.removeThrowTick();
this._catchedBoxByMoneky = this._catchedBox;
this._catchedBox = null;
egret.Tween.get(this._catchedBoxByMoneky)
.to({ scaleX: 1, scaleY: 1 }, 500)
.wait(500)
.to({ alpha: 0 }, 500).call(() => {
this._catchedBoxByMoneky.destroy();
this._catchedBoxByMoneky = null;
}, this);
}
onNotCatchedByMonkey() {
this.removeThrowTick();
this._catchedBox = null;
}
private _handX: number;
private _handY: number;
onPointUpdate(e: egret.Event) {
const point = e.data as egret.Point;
if (__debug__) {
this._shape.graphics.clear();
this._shape.graphics.beginFill(0xff0000);
const size = __monkeyHandSize__;
const x = point.x + this._monkey.x;
const y = point.y + this._monkey.y;
this._shape.graphics.drawRect(x - size / 2, y - size / 2, size, size);
this._shape.graphics.endFill();
const p = e.data as egret.Point;
this._handX = p.x + this._monkey.x;
this._handY = p.y + this._monkey.y;
if (this._catchedBoxByMoneky) {
this._catchedBoxByMoneky.x = this._handX;
this._catchedBoxByMoneky.y = this._handY;
}
if (this._debug) {
this._debug.shape.x = this._handX;
this._debug.shape.y = this._handY;
}
}
async getBg() {
......@@ -107,16 +170,14 @@ export default class StartScene extends Scene {
LayerTypes.net,
LayerTypes.box,
LayerTypes.monkey,
LayerTypes.top,
]
}
protected get skinKey() { return 'Start' }
get guideView() { return this._guideView }
get monkey() { return this._monkey }
get boxList() { return this._boxList }
get boxListCtrl() { return this._boxListCtrl }
get net() { return this._net }
}
enum LayerTypes {
bg, kids, box, net, monkey, guide
get topLay() { return this.getLayer(LayerTypes.top) }
}
\ No newline at end of file
enum LayerTypes {
bg, kids, box, net, monkey, guide, top
}
export default LayerTypes
\ No newline at end of file
import Box from "./Box";
import StartScene from "./StartScene";
export default class debug {
parent;
shape: egret.Shape;
constructor(parent: egret.Sprite) {
this.parent = parent;
const top = this.parent;
this.shape = new egret.Shape();
top.addChild(this.shape);
this.shape.graphics.beginFill(0xff0000);
// const size = __monkeyHandSize__;
// this.shape.graphics.drawRect(0, 0, 2, 2);
this.shape.graphics.drawCircle(0,0,4);
this.shape.graphics.endFill();
const shape1 = new egret.Shape();
shape1.graphics.beginFill(0xff0000);
shape1.graphics.drawRect(0, 0, 999, 1);
shape1.graphics.endFill();
shape1.y = Box.MIDDLE_Y;
top.addChild(shape1);
const shape2 = new egret.Shape();
shape2.graphics.beginFill(0xff0000);
shape2.graphics.drawRect(0, 0, 999, 1);
shape2.graphics.endFill();
shape2.y = Box.MIDDLE_Y - StartScene.NET_RANGE;
top.addChild(shape2);
const shape3 = new egret.Shape();
shape3.graphics.beginFill(0xff0000);
shape3.graphics.drawRect(0, 0, 999, 1);
shape3.graphics.endFill();
shape3.y = Box.MIDDLE_Y + StartScene.NET_RANGE;
top.addChild(shape3);
}
}
\ 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