Commit 59bc156e authored by wildfirecode's avatar wildfirecode

1

parent d7657c2d
No preview for this file type
......@@ -42,18 +42,18 @@
<!-- <script src="default.thm.js"></script> -->
<script src="output.js"></script>
<script>
var debug = 1;
var moneyHandSize = 50;
var boxmap = {
coin: { award: 0, skin: 'https://yun.duiba.com.cn/db_games/activity/fishing/1539151820/resource/assets/startScene/coin.png' },
gift: { award: 0, skin: 'https://yun.duiba.com.cn/db_games/activity/fishing/1539151820/resource/assets/startScene/gift.png' },
gift2: { award: 0, skin: 'https://yun.duiba.com.cn/db_games/activity/fishing/1539151820/resource/assets/startScene/gift2.png' },
woodbox: { award: 1, skin: 'https://yun.duiba.com.cn/db_games/activity/fishing/1539151820/resource/assets/startScene/woodbox.png' }, //木宝箱
silverbox: { award: 3, skin: 'https://yun.duiba.com.cn/db_games/activity/fishing/1539151820/resource/assets/startScene/silverbox.png' },//银宝箱
goldenbox: { award: 5, skin: 'https://yun.duiba.com.cn/db_games/activity/fishing/1539151820/resource/assets/startScene/goldenbox.png' },//金宝箱
};
var debug = 1;
var moneyHandSize = 50;
var boxmap = {
coin: { award: 0, skin: 'http://localhost:8080/egret/resource/assets/startScene/coin.png' },
gift: { award: 0, skin: 'http://localhost:8080/egret/resource/assets/startScene/gift.png' },
gift2: { award: 0, skin: 'http://localhost:8080/egret/resource/assets/startScene/gift2.png' },
woodbox: { award: 1, skin: 'http://localhost:8080/egret/resource/assets/startScene/woodbox.json', offset: [128, 79] }, //木宝箱
silverbox: { award: 3, skin: 'http://localhost:8080/egret/resource/assets/startScene/silverbox.png' },//银宝箱
goldenbox: { award: 5, skin: 'http://localhost:8080/egret/resource/assets/startScene/goldenbox.png' },//金宝箱
};
var __bgUrl__ = 'https://yun.duiba.com.cn/db_games/activity/fishing/1539151820/resource/assets/startScene/bg.jpg';
var __bgUrl__ = 'http://localhost:8080/egret/resource/assets/startScene/bg.jpg';
var gameId = 1;
var CFG = {
......
......@@ -19,8 +19,17 @@ export default class MainBase extends eui.UILayer {
if (RES.fileSystem['getFileOld']) return;
RES.fileSystem['getFileOld'] = RES.fileSystem.getFile;
window['RES'].fileSystem.getFile = function (filename: string) {
console.log("RES.fileSystem.getFile->",filename)
if (filename.indexOf('.json') != -1) {
var arr = filename.split('.json')[0].split('/');
var filename1 = arr[arr.length - 1] + '_png';
var filename2 = filename.split('.json')[0] + '.png';
if (!RES.fileSystem['fsData'][filename1])
RES.fileSystem['fsData'][filename1] =
{ name: filename1, type: 'image', url: filename2, root: '', extra: '1' };
}
var result = RES.fileSystem['getFileOld'](filename);
if (result && result.url) {
if (result && result.url && check_webp_feature()) {
result = JSON.parse(JSON.stringify(result));
result.url = result.url.replace('.png', '.png?x-oss-process=image/format,webp');
result.url = result.url.replace('.jpg', '.jpg?x-oss-process=image/format,webp');
......
{"file":"net.png","frames":{
"01":{"x":1223,"y":1,"w":609,"h":428,"offX":69,"offY":104,"sourceW":750,"sourceH":558},
"02":{"x":613,"y":431,"w":610,"h":414,"offX":68,"offY":81,"sourceW":750,"sourceH":558},
"03":{"x":1225,"y":822,"w":610,"h":383,"offX":68,"offY":59,"sourceW":750,"sourceH":558},
"04":{"x":1,"y":856,"w":612,"h":371,"offX":65,"offY":32,"sourceW":750,"sourceH":558},
"05":{"x":1227,"y":1207,"w":610,"h":371,"offX":68,"offY":19,"sourceW":750,"sourceH":558},
"06":{"x":615,"y":1207,"w":610,"h":372,"offX":68,"offY":39,"sourceW":750,"sourceH":558},
"07":{"x":1225,"y":431,"w":610,"h":389,"offX":68,"offY":84,"sourceW":750,"sourceH":558},
"08":{"x":1,"y":431,"w":610,"h":423,"offX":68,"offY":100,"sourceW":750,"sourceH":558},
"09":{"x":612,"y":1,"w":609,"h":428,"offX":69,"offY":104,"sourceW":750,"sourceH":558},
"10":{"x":1,"y":1,"w":609,"h":428,"offX":69,"offY":104,"sourceW":750,"sourceH":558}}}
\ No newline at end of file
{"file":"woodbox.png","frames":{
"01":{"x":1,"y":208,"w":151,"h":206,"offX":52,"offY":11,"sourceW":236,"sourceH":224},
"03":{"x":210,"y":204,"w":175,"h":200,"offX":30,"offY":14,"sourceW":236,"sourceH":224},
"02":{"x":415,"y":203,"w":171,"h":205,"offX":32,"offY":12,"sourceW":236,"sourceH":224},
"06":{"x":811,"y":1,"w":188,"h":199,"offX":23,"offY":18,"sourceW":236,"sourceH":224},
"07":{"x":615,"y":1,"w":194,"h":198,"offX":20,"offY":17,"sourceW":236,"sourceH":224},
"05":{"x":615,"y":201,"w":184,"h":197,"offX":25,"offY":17,"sourceW":236,"sourceH":224},
"04":{"x":801,"y":202,"w":180,"h":200,"offX":27,"offY":15,"sourceW":236,"sourceH":224},
"10":{"x":1,"y":1,"w":207,"h":205,"offX":13,"offY":12,"sourceW":236,"sourceH":224},
"09":{"x":210,"y":1,"w":203,"h":201,"offX":15,"offY":14,"sourceW":236,"sourceH":224},
"08":{"x":415,"y":1,"w":198,"h":200,"offX":18,"offY":15,"sourceW":236,"sourceH":224}}}
\ No newline at end of file
......@@ -99,9 +99,16 @@
"name": "silverbox_png"
},
{
"url": "assets/startScene/woodbox.png",
"type": "image",
"name": "woodbox_png"
"url": "assets/startScene/woodbox.json",
"type": "sheet",
"name": "woodbox_json",
"subkeys": "01,02,03,04,05,06,07,08,09,10"
},
{
"url": "assets/startScene/net.json",
"type": "sheet",
"name": "net_json",
"subkeys": "01,02,03,04,05,06,07,08,09,10"
}
]
}
\ No newline at end of file
......@@ -15,6 +15,7 @@ export class MyExmlPlugin extends ExmlPlugin2 implements plugins.Command {
'silverbox.png',
'woodbox.png',
'monkey.png',
'net.png',
];
if (excludes.indexOf(file.basename) != -1) {
return file;
......
export default class SheetAnimation extends egret.Bitmap {
private _counter: number;
private _sheet: egret.SpriteSheet;
private _fps = 24;
private _fpscounter = 1;
totalFrames: number = 10;
onEnterFrame() {
if (this._fpscounter == 1) {
let key = '0' + this._counter;
if (this._counter >= this.totalFrames)
key = this._counter + '';
const picData = this._sheet.getTexture(key);
this.$setBitmapData(picData);
this.dispatchEvent(new egret.Event('frameUpdate', false, false, this._counter));
this._counter++;
if (this._counter > this.totalFrames)
this._counter = 1;
}
this._fpscounter++;
if (this._fpscounter > Math.ceil(60 / this._fps))
this._fpscounter = 1;
}
set sheet(val: egret.SpriteSheet) {
this._sheet = val;
this.stopAtFirstFrame();
this.totalFrames = this.getTotalFrames();
}
private getTotalFrames() {
let counter = 0;
for (const key in this._sheet._textureMap) {
counter++;
}
return counter;
}
stopAtFirstFrame() {
const picData = this._sheet.getTexture('01');
this.$setBitmapData(picData);
this.stop();
}
set fps(val: number) {
this._fps = val;
}
play() {
this._fpscounter = 1;
this._counter = 1;
this.addEventListener(egret.Event.ENTER_FRAME, this.onEnterFrame, this);
}
stop() {
this.removeEventListener(egret.Event.ENTER_FRAME, this.onEnterFrame, this);
}
destroy() {
this.stop();
this._sheet=null;
}
}
\ No newline at end of file
import { getResPath } from "../utils";
import SheetAnimation from "../components/SheetAnimation";
import IBoxItem from "./IBoxItem";
export default class Box extends egret.Sprite {
private _pic: SheetAnimation;
private _type: string;
private _moveSpeed = 3;
constructor(type) {
super();
this._type = type;
this._pic = new SheetAnimation();
this.addChild(this._pic);
}
start() {
this.x = 750 / 2 + 20;
this.y = 400;
// this.scaleX=this.scaleY=0.5;
this.move();
}
move() {
this.addEventListener(egret.Event.ENTER_FRAME, this.onEnterFrame, this);
}
private _onDisappear: boolean;
disappear() {
this._onDisappear = true;
this._pic.destroy();
egret.Tween.get(this).to({ alpha: 0 }, 500).call(this.destroy, this);
}
destroy() {
this.removeEventListener(egret.Event.ENTER_FRAME, this.onEnterFrame, this);
this.parent.removeChild(this);
}
stopMove() {
}
onEnterFrame() {
this.y += this._moveSpeed;
if (this.y > 1106 && !this._onDisappear) {
this.disappear();
}
}
async createBg() {
let url = getResPath() + `resource/assets/startScene/${this._type}.png`;
let url = this.boxData.skin;
return new Promise((resolve) => {
RES.getResByUrl(url, (picData) => {
const pic = new egret.Bitmap(picData);
this.addChild(pic);
this.anchorOffsetX = picData.textureWidth / 2;
this.anchorOffsetY = picData.textureHeight / 2;
resolve(pic)
}, this, RES.ResourceItem.TYPE_IMAGE);
RES.getResByUrl(url, (sheet: egret.SpriteSheet) => {
this.start();
this._pic.sheet = sheet;
this._pic.fps = 10;
this._pic.play();
this.alpha = 0;
egret.Tween.get(this).to({ alpha: 1 }, 500);
this.anchorOffsetX = this.boxData.offset[0];
this.anchorOffsetY = this.boxData.offset[1];
resolve(this);
}, this, RES.ResourceItem.TYPE_SHEET);
});
}
get type() { return this._type }
get boxData(): IBoxItem { return window['boxmap'][this._type]; }
static getBoxList() {
const list = [];
for (const key in window['boxmap']) {
......
import Box from "./Box";
export default class BoxList {
private _parent: egret.Sprite;
constructor(parent: egret.Sprite) {
this._parent = parent;
this.init();
}
init() {
}
createFirstBox() {
return new Promise(async (resolve) => {
const box = new Box('woodbox')
this._parent.addChild(box);
await box.createBg();
resolve();
})
}
}
\ No newline at end of file
export default interface IBoxItem {
award: number;
skin: string;
offset:number[];
}
\ No newline at end of file
......@@ -9,15 +9,24 @@ export default class Monkey extends egret.Sprite {
private w1 = 29;
private r1;
private len;
private targetY = 70;
private targetX = 369;
constructor() {
super();
this.x = 750;
this.y = - this.h;
this.anchorOffsetX = 113;
this.anchorOffsetY = 8;
const a = this.w0 - this.w1;
const b = this.h - this.h0 - this.h1;
this.r1 = Math.tan(a / b) / Math.PI * 180;
this.len = Math.sqrt(a * a + b * b);
this.createBg();
this.start()
}
private async start() {
await this.createBg();
egret.Tween.get(this).to({y:this.targetY,x:this.targetX},1000,egret.Ease.getBackInOut(.7))
}
startShaking() {
......
import SheetAnimation from "../components/SheetAnimation";
export default class Net extends egret.Sprite {
private _pic: SheetAnimation;
constructor() {
super();
this._pic = new SheetAnimation();
this.addChild(this._pic);
this.createBg();
this.y = 500;
}
doAction() {
this._pic.play();
this._pic.addEventListener('frameUpdate', this.onEnterFrame, this);
}
onEnterFrame(e: egret.Event) {
if (e.data == this._pic.totalFrames) {
this._pic.removeEventListener('frameUpdate', this.onEnterFrame, this);
this._pic.stopAtFirstFrame();
}
}
async createBg() {
const sheet = await RES.getResAsync('net_json') as egret.SpriteSheet;
this._pic.sheet = sheet;
this._pic.fps = 10;
this.alpha = 0;
egret.Tween.get(this).to({ alpha: 1 }, 500);
setInterval(()=>{
this.doAction()
},5000);
}
}
\ No newline at end of file
......@@ -4,33 +4,34 @@ import PanelCtrl from "../ctrls/panelCtrl";
import { ModuleTypes } from "../types/sceneTypes";
import Scene from "../views/Scene";
import Box from "./Box";
import IBoxItem from "./IBoxItem";
import Monkey from "./Monkey";
import Net from "./Net";
import BoxList from "./BoxList";
const { TouchEvent } = egret;
export default class StartScene extends Scene {
private _net: Net;
private _monkey: Monkey;
private _shape: egret.Shape;
private _boxList: BoxList;
async start(data?) {
const picData: any = await this.getBg();
const pic = new egret.Bitmap(picData);
this.addChild(pic);
this.getLayer(LayerTypes.bg).addChild(pic);
const box = new Box(Box.getBoxList()[5]);
this.addChild(box);
box.x = box.stage.stageWidth / 2;
box.y = box.stage.stageHeight / 2;
await box.createBg();
this._boxList = new BoxList(this.getLayer(LayerTypes.box));
await this._boxList.createFirstBox();
const monkey = new Monkey();
this.addChild(monkey);
this.getLayer(LayerTypes.monkey).addChild(monkey);
monkey.startShaking();
monkey.addEventListener('pointUpdate', this.onPointUpdate, this)
monkey.x = 369;
monkey.y = 70;
this._monkey = monkey;
const net = new Net();
this.getLayer(LayerTypes.net).addChild(net);
if (window['debug']) {
this._shape = new egret.Shape();
this.addChild(this._shape);
......@@ -39,18 +40,17 @@ export default class StartScene extends Scene {
const model = new GamePlayModel();
model.update();
box.touchEnabled = true;
box.addEventListener(egret.TouchEvent.TOUCH_BEGIN, () => {
const boxData: IBoxItem = window['boxmap'][box.type];
NetManager.ins.getInfo(() => {
model.doStart(() => {
model.submit(() => { }, boxData.award)
}, false);
});
// box.touchEnabled = true;
// box.addEventListener(egret.TouchEvent.TOUCH_BEGIN, () => {
// NetManager.ins.getInfo(() => {
// model.doStart(() => {
// model.submit(() => { }, box.boxData.award)
// }, false);
// });
PanelCtrl.instance.show(ModuleTypes.RULE_PANEL);
// PanelCtrl.instance.show(ModuleTypes.RULE_PANEL);
}, this);
// }, this);
}
onPointUpdate(e: egret.Event) {
......@@ -74,5 +74,17 @@ export default class StartScene extends Scene {
});
}
protected get layerKeys() {
return [LayerTypes.bg,
LayerTypes.kids,
LayerTypes.net,
LayerTypes.box,
LayerTypes.monkey,
LayerTypes.guide]
}
protected get skinKey() { return 'Start' }
}
enum LayerTypes {
bg, kids, box, net, monkey, guide
}
\ No newline at end of file
import ComponentBase from "../components/ComponentBase";
export default class Scene extends ComponentBase {
protected onSkinComplete() {
super.onSkinComplete();
this.createLayers();
}
private _map: { [key: string]: egret.Sprite }
createLayers() {
this._map = {};
for (const key of this.layerKeys) {
const layer = new egret.Sprite();
this.addChild(layer);
this._map[key] = layer;
}
}
getLayer(key) {
return this._map[key]
}
protected get layerKeys() {
return []
}
}
\ 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