Commit ccde8b83 authored by wildfirecode's avatar wildfirecode

1

parent efd335fc
No preview for this file type
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
<body> <body>
<div style="margin: auto;width: 100%;height: 100%;" class="egret-player" data-entry-class="Main" data-orientation="auto" <div style="margin: auto;width: 100%;height: 100%;" class="egret-player" data-entry-class="Main" data-orientation="auto"
data-scale-mode="showAll" data-frame-rate="30" data-content-width="750" data-content-height="1624" data-multi-fingered="2" data-scale-mode="showAll" data-frame-rate="60" data-content-width="750" data-content-height="1624" data-multi-fingered="2"
data-show-fps="false" data-show-log="false" data-show-fps-style="x:0,y:0,size:12,textColor:0xffffff,bgAlpha:0.9"> data-show-fps="false" data-show-log="false" data-show-fps-style="x:0,y:0,size:12,textColor:0xffffff,bgAlpha:0.9">
</div> </div>
...@@ -42,6 +42,9 @@ ...@@ -42,6 +42,9 @@
<!-- <script src="default.thm.js"></script> --> <!-- <script src="default.thm.js"></script> -->
<script src="output.js"></script> <script src="output.js"></script>
<script> <script>
var debug=1;
var moneyHandSize = 40;
var type = 'woodbox';
var gameId = 1; var gameId = 1;
var CFG = { var CFG = {
appInfo: { appInfo: {
......
...@@ -17,8 +17,8 @@ ...@@ -17,8 +17,8 @@
"name": "rule" "name": "rule"
}, },
{ {
"keys": "monkey_png", "name": "preload",
"name": "start_monkey" "keys": "gift2_png,coin_png,gift_png,goldenbox_png,silverbox_png,woodbox_png"
} }
], ],
"resources": [ "resources": [
...@@ -78,9 +78,34 @@ ...@@ -78,9 +78,34 @@
"name": "bg_jpg" "name": "bg_jpg"
}, },
{ {
"url": "assets/startScene/monkey/monkey.png", "name": "gift2_png",
"type": "image", "type": "image",
"name": "monkey_png" "url": "assets/startScene/gift2.png"
},
{
"name": "coin_png",
"type": "image",
"url": "assets/startScene/coin.png"
},
{
"name": "gift_png",
"type": "image",
"url": "assets/startScene/gift.png"
},
{
"name": "goldenbox_png",
"type": "image",
"url": "assets/startScene/goldenbox.png"
},
{
"name": "silverbox_png",
"type": "image",
"url": "assets/startScene/silverbox.png"
},
{
"name": "woodbox_png",
"type": "image",
"url": "assets/startScene/woodbox.png"
} }
] ]
} }
\ No newline at end of file
...@@ -9,7 +9,12 @@ export class MyExmlPlugin extends ExmlPlugin2 implements plugins.Command { ...@@ -9,7 +9,12 @@ export class MyExmlPlugin extends ExmlPlugin2 implements plugins.Command {
async onFile(file: plugins.File) { async onFile(file: plugins.File) {
const excludes = [ const excludes = [
'coin.png', 'coin.png',
'goBtn.png', 'gift.png',
'gift2.png',
'goldenbox.png',
'silverbox.png',
'woodbox.png',
'monkey.png',
]; ];
if (excludes.indexOf(file.basename) != -1) { if (excludes.indexOf(file.basename) != -1) {
return file; return file;
......
import { getImgURL } from "../../libs/tc/util/GFun";
import { getResPath } from "../utils";
export default class Box extends egret.Sprite {
private _type: string;
constructor(type) {
super();
this._type = type;
}
async createBg() {
let url = getResPath() + `resource/assets/startScene/${this._type}.png`;
url = await getImgURL(url);
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);
});
}
get type(){return this._type}
}
\ No newline at end of file
export default class BoxType {
static coin = 'coin'
static gift = 'coin'
static gift2 = 'coin'
static goldenbox = 'coin'
static silverbox = 'coin'
static woodbox = 'coin'
}
\ No newline at end of file
import { getImgURL } from "../../libs/tc/util/GFun";
import { getResPath } from "../utils";
export default class Monkey extends egret.Sprite {
private h = 525;
private w = 265;
private h0 = 8;
private w0 = 118;
private h1 = 23;
private w1 = 29;
private r1;
private len;
constructor() {
super();
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();
}
startShaking() {
this.addEventListener(egret.Event.ENTER_FRAME, this.onEnterFrame, this);
}
stopShaking() {
this.addEventListener(egret.Event.ENTER_FRAME, this.onEnterFrame, this);
}
reset() {
this.rotation = 0;
this._dir = 1;
}
private static RANGE = 30;
private _shakeSpeed = .5;
private _dir = 1;
onEnterFrame() {
this.rotation += this._shakeSpeed * this._dir;
if (this.rotation > Monkey.RANGE)
this._dir = -1;
if (this.rotation < -Monkey.RANGE)
this._dir = 1;
this.dispatchEvent(new egret.Event('pointUpdate', false, false, this.getPoint()))
}
getPoint() {
const r = (this.r1 + this.rotation) / 180 * Math.PI;
const a = Math.sin(r) * this.len;
const b = Math.cos(r) * this.len;
const y = b;
const x = -a;
return new egret.Point(x, y);
}
async createBg() {
let url = getResPath() + `resource/assets/startScene/monkey.png`;
url = await getImgURL(url);
return new Promise((resolve) => {
RES.getResByUrl(url, (picData) => {
const pic = new egret.Bitmap(picData);
this.addChild(pic);
resolve(pic)
}, this, RES.ResourceItem.TYPE_IMAGE);
});
}
}
\ No newline at end of file
import { getImgURL } from "../../libs/tc/util/GFun"; import { getImgURL } from "../../libs/tc/util/GFun";
import Scene from "../views/Scene"; import { GamePlayModel } from "../../libs/tw/model/game/GamePlayModel";
import { getResPath } from "../utils"; import { getResPath } from "../utils";
import Scene from "../views/Scene";
import Box from "./Box";
import BoxType from "./BoxType";
import Monkey from "./Monkey";
import { NetManager } from "../../libs/tw/manager/NetManager";
const { TouchEvent } = egret; const { TouchEvent } = egret;
export default class StartScene extends Scene { export default class StartScene extends Scene {
start(data?) { private _monkey: Monkey;
this.createBg(); private _shape: egret.Shape;
async start(data?) {
const picData: any = await this.getBg();
const pic = new egret.Bitmap(picData);
this.addChild(pic);
const box = new Box(window['type']);
this.addChild(box);
box.x = box.stage.stageWidth / 2;
box.y = box.stage.stageHeight / 2;
await box.createBg();
const monkey = new Monkey();
this.addChild(monkey);
monkey.startShaking();
monkey.addEventListener('pointUpdate', this.onPointUpdate, this)
monkey.x = 369;
monkey.y = 70;
this._monkey = monkey;
if (window['debug']) {
this._shape = new egret.Shape();
this.addChild(this._shape);
} }
const map = {
woodbox: 1,
silverbox: 3,
goldenbox: 5,
};
const model = new GamePlayModel();
model.update();
NetManager.ins.getInfo(() => {
model.doStart(() => {
model.submit(() => { }, map[box.type])
async createBg() { }, false);
});
// box.addEventListener(egret.TouchEvent.TOUCH_TAP, () => {
// }, this);
}
onPointUpdate(e: egret.Event) {
const point = e.data as egret.Point;
if (window['debug']) {
this._shape.graphics.clear();
this._shape.graphics.beginFill(0xff0000);
const size = window['moneyHandSize'];
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();
}
}
async getBg() {
let url = getResPath() + 'resource/assets/startScene/bg.jpg'; let url = getResPath() + 'resource/assets/startScene/bg.jpg';
url = await getImgURL(url); url = await getImgURL(url);
return new Promise((resolve) => {
RES.getResByUrl(url, (picData) => { RES.getResByUrl(url, (picData) => {
const pic = new egret.Bitmap(picData); resolve(picData)
this.addChild(pic);
}, this, RES.ResourceItem.TYPE_IMAGE); }, this, RES.ResourceItem.TYPE_IMAGE);
});
} }
protected get skinKey() { return 'Start' } protected get skinKey() { return 'Start' }
......
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