Commit 83a2ee94 authored by zjz1994's avatar zjz1994

Merge branch 'dev' of http://gitlab2.dui88.com/laoqifeng/zeroing-libs into zjz

# Conflicts:
#	package-lock.json
#	src/custom/dxbcyj-game/debug/main.js.map
#	src/custom/dxbcyj-game/src/game/GameWrapper.ts
parents 0e5d2450 33823dbd
/**
* Created by rockyl on 2018/8/16.
*/
import Block from "./Block";
import {Background} from "./Background";
import Player from "./Player";
import {props} from "../props";
import {createSvga, getTextureByName, playSound} from "./utils";
import {Base} from "./Base";
import {GuideLayer} from "./GuideLayer";
import {GoldBag} from "./GoldBag";
import ObjectPool = engine.ObjectPool;
import { JumpTips } from "./JumpTips";
const PoolName: string = 'gold-bag';
ObjectPool.registerPool(PoolName, function () {
return new GoldBag();
}, function (item: GoldBag, data) {
item.reset(data);
});
export default class GameView extends engine.Container {
background: Background;
base: Base;
frontContainer: engine.Container;
blockContainer: engine.Container;
guideLayer: GuideLayer;
player: Player;
hitEffect: svga.Svga;
currentBlock: Block;
needHitTest;
index = -1;
blockComplete;
baseOffset: number;
scoreAddTipsContainer;
jumpTips
timer;
_pos;
_score;
_remainToShowGoldBag;
_blockShadow
_playerShadow
lastLandType;
scoreAddTips
_touchEnabled;
private _hasSetup;
constructor() {
super();
this.baseOffset = -props.baseOffset + props.playerOffset;
this.once(engine.Event.ADDED_TO_STAGE, this.setup, this);
}
setup() {
if (this._hasSetup) {
return;
}
this._hasSetup = true;
const {width, height} = this.stage;
const background = this.background = new Background();
this.addChild(background);
background.setup();
const frontContainer = this.frontContainer = new engine.Container();
frontContainer.x = width / 2;
this.addChild(frontContainer);
const guideLayer = this.guideLayer = new GuideLayer();
this.addChild(guideLayer);
const base = this.base = new Base();
frontContainer.addChild(base);
base.setup();
let blockShadow = this._blockShadow = new engine.Image(getTextureByName('方块阴影'));
blockShadow.anchorX = blockShadow.width / 2;
blockShadow.anchorY = blockShadow.height / 2;
blockShadow.x = -(blockShadow.width - base.width) / 2;
blockShadow.y =props.blockShadowOffset;
base.addChild(blockShadow);
const blockContainer = this.blockContainer = new engine.Container();
frontContainer.addChild(blockContainer);
const player = this.player = new Player();
frontContainer.addChild(player);
player.setup();
player.addEventListener('jump-on-top', this.onPlayerJumpOnTop, this);
let playerShadow = this._playerShadow = new engine.Image(getTextureByName('玩家阴影'));
playerShadow.anchorX = playerShadow.width / 2;
playerShadow.anchorY = playerShadow.height / 2;
//playerShadow.x = frontContainer.width / 2;
playerShadow.x =this.player.x-playerShadow.width / 2;
let scoreAddTipsContainer = this.scoreAddTipsContainer = new engine.Container();
scoreAddTipsContainer.width=750;
scoreAddTipsContainer.anchorX = scoreAddTipsContainer.width / 2;
scoreAddTipsContainer.anchorY = scoreAddTipsContainer.height / 2;
let scoreAddTips = this.scoreAddTips = new engine.Label();
scoreAddTips.width=750;
scoreAddTips.fillColor = props.scoreAddFontColor;
scoreAddTips.textAlign=engine.TEXT_ALIGN.CENTER;
scoreAddTips.size = props.scoreAddFontSize;
scoreAddTips.alpha=0;
scoreAddTips.text = "+0";
scoreAddTips.x = this.player.x-scoreAddTips.width / 2;
scoreAddTipsContainer.addChild(scoreAddTips);
let jumpTips = this.jumpTips =new JumpTips()
jumpTips.setup()
jumpTips.x=props.jumpTipsOffset.x
frontContainer.addChild(playerShadow);
frontContainer.addChild(player);
frontContainer.addChild(scoreAddTipsContainer);
frontContainer.addChild(jumpTips);
ObjectPool.recycleObject(PoolName, ObjectPool.getObject(PoolName, {
y: 0,
remain: 0,
}));
this.hitEffect = createSvga('被撞烟雾', 'hitEffectAnchor');
this.pos = 0;
this.background.setup();
this.addEventListener(engine.Event.ENTER_FRAME, this.onEnterFrame, this);
this.reset();
}
async setScoreText(score){
return new Promise(resolve => {
this.scoreAddTips.text=score
this.scoreAddTips.y=0
this.scoreAddTips.alpha=1
engine.Tween.get(this.scoreAddTips, null, null, true)
.to({y: -100,alpha:0}, 500, engine.Ease.cubicInOut)
.call(resolve);
})
}
async reset(revive = false) {
this.base.reset();
this.index = -1;
this._score = 0;
if (revive) {
} else {
this.pos = 0;
const blockContainer = this.blockContainer;
for (let i = 0, li = blockContainer.children.length; i < li; i++) {
const block = <Block>blockContainer.getChildAt(i);
block.playLeave();
}
}
for (let i = 0; i < props.initBlockCount; i++) {
this.addBlock(false);
}
for (let i = 0, li = this.goldBags.length; i < li; i++) {
const goldBag = this.goldBags[i];
this.frontContainer.removeChild(goldBag);
ObjectPool.recycleObject(PoolName, goldBag);
}
this.goldBags.splice(0);
//this.addGoldBag();
this.playZoom('in');
await this.resetPlayer(revive);
}
async resetPlayer(revive = false) {
this.player.reset(revive);
this.player.y = this.baseOffset - (this.index + 1) * props.blockHitHeight+props.blockBaseOffset;
}
async start(revive = false) {
this._playerShadow.y =this.player.y+props.playerShadowOffset;
this.scoreAddTipsContainer.y =this.player.y+props.scoreAddTipsOffset;
this.jumpTips.y =this.player.y+props.jumpTipsOffset.y;
//this.setScoreText("+100")
if (!revive) {
await this.player.playReady();
}
console.log("开始")
let guideFlagKey = 'jump-high-guide_' + props.guideFlagKey;
let guideFlag = localStorage.getItem(guideFlagKey);
if (!guideFlag) {
localStorage.setItem(guideFlagKey, '1');
await this.guideLayer.show('', {y: this.stage.height + this.player.y - 280});
}
this.lastLandType = 0;
this._remainToShowGoldBag = props.goldBagScoreMultiple - props.goldBagScoreSubtraction;
this._touchEnabled = true;
setTimeout(() => {
this.addBlock();
}, 100);
engine.globalEvent.dispatchEvent('jump-high-game-start');
}
pause() {
if (this.currentBlock) {
engine.Tween.pauseTweens(this.currentBlock);
}
engine.Tween.pauseTweens(this.player);
}
resume() {
if (this.currentBlock) {
engine.Tween.resumeTweens(this.currentBlock);
}
engine.Tween.resumeTweens(this.player);
}
async revive() {
this.blockContainer.getChildAt(this.index).visible = false;
this.index--;
await this.resetPlayer(true);
await this.playZoom('in');
this.start(true);
}
addBlock(animation = true) {
this.index++;
const blockContainer = this.blockContainer;
let block: Block;
if (blockContainer.children.length > this.index) {
block = <Block>blockContainer.getChildAt(this.index);
block.visible = true;
} else {
block = new Block();
blockContainer.addChild(block);
}
block.reset({
type: Math.floor(Math.random() * props.blockAssets.length),
});
block.y = this.baseOffset - this.index * props.blockHitHeight+props.blockBaseOffset;
this.blockComplete = false;
block.playEnter(this.index, animation).then(
(data) => {
this.blockComplete = true;
}
);
if (animation) {
this.needHitTest = true;
}
this.currentBlock = block;
/*if (this.blockCount > 0 && this.blockCount % props.goldBagMultiple === 0) {
this.addGoldBag();
}*/
}
private goldBags: GoldBag[] = [];
addGoldBag() {
let goldBag = <GoldBag>ObjectPool.getObject(PoolName, {
y: this.baseOffset - (this.blockCount + props.goldBagDistance + props.goldBagJumpSubtraction) * props.blockHitHeight,
remain: props.goldBagDistance,
});
this.frontContainer.addChild(goldBag);
this.goldBags.push(goldBag);
}
private nextToUpdateScore;
async playOpenGoldBag() {
for (let i = 0, li = this.goldBags.length; i < li; i++) {
const goldBag = this.goldBags[i];
goldBag.remain--;
if (goldBag.remain <= 0) {
this.goldBags.splice(i, 1);
i--;
li--;
this.nextToUpdateScore = true;
await goldBag.playOpen();
this.frontContainer.removeChild(goldBag);
ObjectPool.recycleObject(PoolName, goldBag);
}
}
}
onPlayerJumpOnTop() {
if (this.nextToUpdateScore) {
this.nextToUpdateScore = false;
this.scoreChange(4);
playSound('撞击钱袋音效');
}
}
get blockCount() {
return this.index - props.initBlockCount + 1;
}
get pos() {
return this._pos;
}
set pos(v) {
this._pos = v;
this.updatePos();
}
updatePos() {
this.frontContainer.y = this.stage.height + this._pos;
}
private onEnterFrame(event) {
if (this.needHitTest) {
if (this.currentBlock) {
const {x: bx, y: by, dir} = this.currentBlock;
const {x: px, y: py} = this.player;
const {blockHitWidth, blockHitHeight, playerWidth} = props;
let hitOn = false;
if (Math.abs(px - bx) < (blockHitWidth + playerWidth) / 2) {
this.player.changeBaseY(by - blockHitHeight);
if (py > by - blockHitHeight) {
hitOn = true;
}
}
if (hitOn) {
this.onHitOn(dir);
}
}
}
}
async onHitOn(dir) {
this._touchEnabled = false;
this.needHitTest = false;
clearInterval(this.timer);
this.currentBlock.playHit();
this._playerShadow.visible=false;
// this.currentBlock.stop();
this.playHitEffect(dir);
await this.player.hitAway(dir);
this.playZoom('out');
await this.player.parachute(dir);
engine.globalEvent.dispatchEvent('jump-high-game-end');
}
async jump() {
if (!this._touchEnabled) {
return;
}
this._playerShadow.visible=false;
this._touchEnabled = false;
this.playOpenGoldBag();
const result: any = await this.player.jump();
if (result) {
if (result.aboveBlock) {
let pos = Math.abs(this.currentBlock.x);
let type = 0;
if (pos > 0) {
type = pos > 0 && pos < props.scoreThreshold ? 2 : 3;
}
let lastLandType = this.lastLandType;
this.lastLandType = type;
if (type === 0) {
if (lastLandType !== type) { //如果前一次不是完美落地说明block没到正中间,所以没有重叠
type = 1;
}
}
if (type < 3) {
this.currentBlock.playEffect();
}
if(type===0){
this.currentBlock.playProFect();
}
if(type!=3){
this._playerShadow.visible=true;
}
this._playerShadow.y=this.player.y+props.playerShadowOffset;
this.player.playLand(type, this.currentBlock.dir);
this.currentBlock.stop();
this.scoreChange(type);
await this.playShake();
await new Promise(resolve => {
engine.Tween.get(this, null, null, true)
.to({pos: props.blockHitHeight * this.index}, 300, engine.Ease.cubicOut)
.call(resolve)
});
this.addBlock();
// this.frontContainer.addChild(this._playerShadow);
//this._playerShadow.y=this.player.y+props.playerShadowOffset;
}
this._touchEnabled = true;
}
}
private scoreChange(type) {
let scoreAdd = props.scoreWeights[type];
this._score += scoreAdd;
this._remainToShowGoldBag -= scoreAdd;
let score = this._score;
engine.globalEvent.dispatchEvent('jump-high-score', {
type,
score,
scoreAdd,
});
this.scoreAddTipsContainer.y =this.player.y+props.scoreAddTipsOffset;
this.setScoreText(`+${scoreAdd}`)
this.jumpTips.y =this.player.y+props.jumpTipsOffset.y;
this.jumpTips.show()
console.log(score, this._remainToShowGoldBag);
if (this._remainToShowGoldBag <= 0) {
this._remainToShowGoldBag += props.goldBagScoreMultiple;
this.addGoldBag();
console.log('addGoldBag');
}
}
playHitEffect(dir) {
let hitEffect = this.hitEffect;
hitEffect.scaleX = dir;
hitEffect.y = this.player.y - props.hitEffectAnchor.y;
hitEffect.play(true, false);
hitEffect.once(engine.Event.END_FRAME, function () {
this.frontContainer.removeChild(hitEffect);
}, this);
this.frontContainer.addChild(hitEffect);
}
playZoom(type: 'in' | 'out', duration = 700) {
this.background.playZoom(type, duration);
let count = this.stage.height / props.blockHitHeight;
return new Promise(resolve => {
this.frontContainer.anchorY = -props.blockHitHeight * (this.index + count * 1.3) + props.baseOffset;
let scale = type === 'in' ? 1 : /*Math.max(*/Math.min((this.stage.height / props.blockHitHeight / (this.index + count)), props.maxScale)/*, props.minScale)*/;
console.log(scale);
engine.Tween.get(this.frontContainer, null, null, true)
.to({scaleX: scale, scaleY: scale}, duration, engine.Ease.cubicInOut)
.call(resolve);
})
}
playShake(){
const {x, y} = this.frontContainer;
return new Promise(resolve => {
const shakeOffset = 7;
const duration = 30;
engine.Tween.get(this.frontContainer, null, null, true)
.to({x: x, y: y - shakeOffset}, duration)
.to({x: x, y: y + shakeOffset}, duration)
.to({x: x + shakeOffset, y: y}, duration)
.to({x: x - shakeOffset, y: y}, duration)
.to({x: x, y: y}, duration)
.call(resolve)
})
}
}
{
"name": "拼图",
"desc": "拼图模块1.0",
"props": {
"OFFSET_X": {
"alias": "OFFSET_X",
"type": "number",
"default": 0
},
"OFFSET_Y": {
"alias": "OFFSET_Y",
"type": "number",
"default": 0
},
"GAME_TIME": {
"alias": "游戏时间",
"type": "number",
"default": 30
},
"moistPercent": {
"alias": "湿润度",
"type": "number",
"default": 0
}
},
"assets": [
{
"name": "被遮罩",
"url": "//yun.duiba.com.cn/aurora/assets/c9d66b3e2381fdc7503cdcef9b7173f067a0b96d.png",
"uuid": "8a8e79b6-2c6f-441b-81ae-c441465abfb0",
"ext": ".png"
},
{
"name": "遮罩",
"url": "//yun.duiba.com.cn/aurora/assets/70ade7c1efa699c8662379f406319188fb6aebc5.png",
"uuid": "024d67e9-ed7f-4481-94ca-a15bd5226cad",
"ext": ".png"
},
{
"name": "衣服湿润度",
"url": "//yun.duiba.com.cn/aurora/assets/f59b03b7441b4da17d8e7567b44c6fe92ce9eb50.png",
"uuid": "ed0e8931-2557-4527-bcfc-9071f90d5737",
"ext": ".png"
},
{
"name": "wind",
"url": "//yun.duiba.com.cn/aurora/assets/15fc1dabf22baedd8bf5e5b418e57cfc81686072.svga",
"uuid": "7f1ef018-79ab-42bf-ac85-0208e36e2928",
"ext": ".svga"
},
{
"name": "雨滴动效",
"url": "//yun.duiba.com.cn/aurora/assets/85feef80df5c2c7728da817e488987d09ba0aab3.svga",
"uuid": "973ed8a7-bfeb-42dd-84fb-e062d150073e",
"ext": ".svga"
},
{
"name": "背景",
"url": "//yun.duiba.com.cn/aurora/assets/d0e22ae58b6e8519b969ed207197a31820790349.png",
"uuid": "5ab43bdc-a6ce-46fb-99c2-a806f57f7484",
"ext": ".png"
},
{
"name": "倒计时",
"url": "//yun.duiba.com.cn/aurora/assets/97e5c35fa0503b5d28168fe7d22fb179f1279e21.png",
"uuid": "b7d2a60a-9e60-4eca-be80-a991abea47c9",
"ext": ".png"
},
{
"name": "t1",
"url": "//yun.duiba.com.cn/aurora/assets/6cc52715ce3bee15d10acbe90eac5828c21fdc7f.png",
"uuid": "a163b74f-32bc-43d2-8015-7cf1eac71501",
"ext": ".png"
},
{
"name": "t2",
"url": "//yun.duiba.com.cn/aurora/assets/0d00d8639caf5d344028b01a1022762724164c92.png",
"uuid": "22de82d1-97ec-4195-a32c-f4fc1656e2de",
"ext": ".png"
},
{
"name": "t3",
"url": "//yun.duiba.com.cn/aurora/assets/4b7c2f0d4c8248425ed335838ab5a5ce44256b90.png",
"uuid": "cc952365-a990-4912-98af-50905559b9d5",
"ext": ".png"
},
{
"name": "云1",
"url": "//yun.duiba.com.cn/aurora/assets/429981638472e8f02ce2a780f3b05be72d13b943.png",
"uuid": "1e1a6993-9da0-4813-b1bd-00f2dbae2af2",
"ext": ".png"
},
{
"name": "云2",
"url": "//yun.duiba.com.cn/aurora/assets/c900fe3536b2119b1a917540e1aac5380363d9d1.png",
"uuid": "6ed0e2e7-3ba3-4967-8fe0-39667792e343",
"ext": ".png"
},
{
"name": "太阳",
"url": "//yun.duiba.com.cn/aurora/assets/f4ad009080bac141589b7f8eb88d6e66da732cd9.png",
"uuid": "0f05aaae-338a-439a-82b0-20efcee5cca4",
"ext": ".png"
},
{
"name": "常态1",
"url": "//yun.duiba.com.cn/aurora/assets/3a1e9ec8247078fc92af538ea8ee29c73b532b93.png",
"uuid": "487c1ca7-dea5-4732-b4b6-acb5406ee3a4",
"ext": ".png"
},
{
"name": "吃力1",
"url": "//yun.duiba.com.cn/aurora/assets/40f906478c4fe90f9b68392df0031d382502f8d9.png",
"uuid": "b876771a-a5d1-47f4-bd45-5978519c521a",
"ext": ".png"
},
{
"name": "沮丧1",
"url": "//yun.duiba.com.cn/aurora/assets/f76eb798d2ccff84f53780c37d802830c5f6071c.png",
"uuid": "ff43517a-27bb-4f73-948c-d7a4fa7b4c69",
"ext": ".png"
},
{
"name": "常态2",
"url": "//yun.duiba.com.cn/aurora/assets/875fd6ba38735682fe27d010338277238672f310.png",
"uuid": "4f8d0a7e-9db3-408e-81f2-fdd323ba6094",
"ext": ".png"
},
{
"name": "吃力2",
"url": "//yun.duiba.com.cn/aurora/assets/753b58a25ee4b617afe0a14767036b63681f0809.png",
"uuid": "71e07cee-fd6d-40bb-ac0b-5bb28c87276e",
"ext": ".png"
},
{
"name": "沮丧2",
"url": "//yun.duiba.com.cn/aurora/assets/17682be2c0e9f299315bf4e17598ea2e3c8e11ce.png",
"uuid": "2cd9f1bb-d0d8-42ea-941b-dcd0428e474d",
"ext": ".png"
},
{
"name": "撑伞按钮",
"url": "//yun.duiba.com.cn/aurora/assets/2d15942ed213e1d0ae953925565d80f93cec4701.png",
"uuid": "9e347bef-6e91-4c92-ba5f-f9a52e656207",
"ext": ".png"
},
{
"name": "伞",
"url": "//yun.duiba.com.cn/aurora/assets/a4c14c17dc144611164c70f905f1d35a2aa1812f.png",
"uuid": "c7129f77-92a6-479e-9994-7d4b39040a15",
"ext": ".png"
},
{
"name": "雨滴",
"url": "//yun.duiba.com.cn/aurora/assets/a1bf1b1622759aabec29e857e325039c147bac54.png",
"uuid": "07f74bf6-416f-445e-98d5-021efe4c9fdc",
"ext": ".png"
},
{
"name": "",
"url": "//yun.duiba.com.cn/aurora/assets/1cded0d917c44d22ddce058f239e1cfac1b506c2.png",
"uuid": "57d4067e-c32f-4b12-a8fc-185753726fc6",
"ext": ".png"
},
{
"name": "击中",
"url": "//yun.duiba.com.cn/aurora/assets/251402a1991ef00a124ddd91f519a30147285e00.png",
"uuid": "38ec6627-efa8-4f7a-9bdc-3c73cea717f1",
"ext": ".png"
},
{
"name": "关闭",
"url": "//yun.duiba.com.cn/aurora/assets/6900f3a3b592c1b9cd3925fb9b66b6ec673a8c43.png",
"uuid": "e4a82aee-4472-4b06-bd75-02fb64f1c8c8",
"ext": ".png"
}
],
"events": {
"in": {
"pictures-start": {
"alias": "开始",
"data": {
"picUrl": "图片路径",
"blockUrl": "blockUrl",
"GAME_TIME": "每局的游戏时间",
"MAX_ROW": "行",
"MAX_COL": "列",
"W": "宽",
"H": "高",
"GAP": "图片间隙",
"OFFSET_X": "OFFSET_X",
"OFFSET_Y": "OFFSET_Y"
}
},
"pictures-stop": {
"alias": "停止"
}
},
"out": {
"cloud-time-update": {
"alias": "倒计时更新",
"data": {
"time": "剩余时间"
}
},
"cloud-game-fail": {
"alias": "游戏结束",
"data": {
"reason": "结束原因(1:时间到了)"
}
},
"cloud-game-success": {
"alias": "游戏成功",
"data": {
"time": "游戏消耗时间"
}
}
}
},
"id": "getAwayFromCloud",
"code": "(function (global, factory) {\n\ttypeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('tslib')) :\n\ttypeof define === 'function' && define.amd ? define(['tslib'], factory) :\n\t(global = global || self, global.getAwayFromCloud = factory(global.tslib));\n}(this, (function (tslib) { 'use strict';\n\n\tfunction getTexture(uuid) {\n\t return engine.Texture.from(getAssetByUUID(uuid).uuid);\n\t}\n\tfunction createSvga(name, anchorName) {\n\t var inst = new svga.Svga();\n\t inst.source = 'asset://' + engine.getAssetByName(name).uuid;\n\t return inst;\n\t}\n\t//# sourceMappingURL=utils.js.map\n\n\tvar Human = (function (_super) {\n\t tslib.__extends(Human, _super);\n\t function Human() {\n\t var _this = _super.call(this) || this;\n\t _this.humanArray = [\n\t '487c1ca7-dea5-4732-b4b6-acb5406ee3a4',\n\t '71e07cee-fd6d-40bb-ac0b-5bb28c87276e',\n\t '2cd9f1bb-d0d8-42ea-941b-dcd0428e474d'\n\t ];\n\t _this.human = new engine.Sprite(getTexture(_this.humanArray[0]));\n\t _this.addChild(_this.human);\n\t _this.width = _this.human.width;\n\t _this.height = _this.human.height;\n\t return _this;\n\t }\n\t Human.prototype.facialChange = function (num) {\n\t var face = new engine.Sprite(getTexture(this.humanArray[num]));\n\t this.human.addChild(face);\n\t return face;\n\t };\n\t Human.prototype.removeFace = function (face) {\n\t this.human.removeChild(face);\n\t };\n\t Human.prototype.scaleEffect = function () {\n\t var _this = this;\n\t var aaa = 0;\n\t var pt = Date.now();\n\t this.addEventListener(engine.Event.ENTER_FRAME, function () {\n\t var dt = Date.now() - pt;\n\t aaa += dt;\n\t _this.anchorX = _this.width + _this.width / 2;\n\t _this.anchorY = _this.height;\n\t if (aaa > 90 && aaa <= 100) {\n\t _this.scaleY = 0.99;\n\t _this.scaleX = 1.01;\n\t }\n\t if (aaa > 190 && aaa < 200) {\n\t _this.scaleX = 1;\n\t _this.scaleY = 1;\n\t aaa = 0;\n\t }\n\t pt = Date.now();\n\t });\n\t };\n\t return Human;\n\t}(engine.Container));\n\t//# sourceMappingURL=Human.js.map\n\n\tvar Moist = (function (_super) {\n\t tslib.__extends(Moist, _super);\n\t function Moist() {\n\t var _this = _super.call(this) || this;\n\t _this.moistBg = new engine.Sprite(getTexture('8a8e79b6-2c6f-441b-81ae-c441465abfb0'));\n\t _this.moist = new engine.Sprite(getTexture('024d67e9-ed7f-4481-94ca-a15bd5226cad'));\n\t _this.moistCover = new engine.Sprite(getTexture('024d67e9-ed7f-4481-94ca-a15bd5226cad'));\n\t _this.txt = new engine.TextInput();\n\t _this.hintpic = new engine.Sprite(getTexture('ed0e8931-2557-4527-bcfc-9071f90d5737'));\n\t _this.percent = 0;\n\t _this.addChild(_this.moistBg);\n\t _this.moistBg.addChild(_this.moist);\n\t _this.moist.mask = _this.moistCover;\n\t _this.txt.text = _this.percent * 100 + '%';\n\t _this.txt.size = 30;\n\t _this.txt.fillColor = '#7A83C5';\n\t _this.addChild(_this.txt);\n\t _this.txt.x = 0;\n\t _this.txt.y = -50;\n\t _this.hintpic.x = -10;\n\t _this.hintpic.y = 440;\n\t _this.addChild(_this.hintpic);\n\t return _this;\n\t }\n\t Moist.prototype.cover = function (percent) {\n\t this.moistCover.anchorY = 416;\n\t this.moistBg.addChild(this.moistCover);\n\t this.moistCover.scaleY = percent;\n\t var t = engine.Tween.get(this.moistCover);\n\t };\n\t Moist.prototype.stopScale = function () {\n\t this.moistCover.scaleY = 1;\n\t this.txt.text = '100%';\n\t };\n\t Moist.prototype.updateText = function (percent) {\n\t var a = percent * 100;\n\t if (a <= 90) {\n\t this.txt.text = a.toPrecision(2) + '%';\n\t }\n\t else {\n\t this.txt.text = a.toPrecision(3) + '%';\n\t }\n\t };\n\t Moist.prototype.updatePercent = function (percent) {\n\t this.percent = percent;\n\t };\n\t return Moist;\n\t}(engine.Container));\n\t//# sourceMappingURL=Moist.js.map\n\n\tvar TimeCounter = (function (_super) {\n\t tslib.__extends(TimeCounter, _super);\n\t function TimeCounter() {\n\t var _this = _super.call(this) || this;\n\t _this.timeCounter = new engine.Sprite(getTexture('b7d2a60a-9e60-4eca-be80-a991abea47c9'));\n\t _this.time = 20;\n\t _this.addChild(_this.timeCounter);\n\t _this.timeCounter.x = 256;\n\t _this.timeCounter.y = 50;\n\t _this.timeText = new engine.TextInput();\n\t _this.timeText.text = _this.time + 's';\n\t _this.timeText.size = 48;\n\t _this.timeText.fillColor = '#7A83C5';\n\t _this.timeCounter.addChild(_this.timeText);\n\t _this.timeText.x = 100;\n\t _this.timeText.y = 15;\n\t return _this;\n\t }\n\t TimeCounter.prototype.updateTime = function (time) {\n\t this.time = time;\n\t this.timeText.text = this.time + 's';\n\t };\n\t return TimeCounter;\n\t}(engine.Container));\n\t//# sourceMappingURL=TimeCounter.js.map\n\n\tvar CloudRain = (function (_super) {\n\t tslib.__extends(CloudRain, _super);\n\t function CloudRain() {\n\t var _this = _super.call(this) || this;\n\t _this.clound1 = new engine.Sprite(getTexture('1e1a6993-9da0-4813-b1bd-00f2dbae2af2'));\n\t _this.clound2 = new engine.Sprite(getTexture('6ed0e2e7-3ba3-4967-8fe0-39667792e343'));\n\t _this.sun = new engine.Sprite(getTexture(\"0f05aaae-338a-439a-82b0-20efcee5cca4\"));\n\t _this.sun.x = 90;\n\t _this.sun.y = 120;\n\t _this.addChild(_this.sun);\n\t _this.addChild(_this.clound1);\n\t _this.addChild(_this.clound2);\n\t _this.clound1.x = 100;\n\t _this.clound1.y = 220;\n\t _this.clound2.x = 150;\n\t _this.clound2.y = 220;\n\t return _this;\n\t }\n\t CloudRain.prototype.succeed = function () {\n\t var _this = this;\n\t var a = 0;\n\t var ld = Date.now();\n\t this.addEventListener(engine.Event.ENTER_FRAME, function () {\n\t var dt = Date.now() - ld;\n\t a += dt;\n\t if (a > 100) {\n\t _this.clound1.x -= (800 * dt) / 1000;\n\t _this.clound2.x += (820 * dt) / 1000;\n\t if (_this.clound1.x <= -380) {\n\t _this.clound1.x = -380;\n\t }\n\t if (_this.clound2.x >= 750) {\n\t _this.clound2.x = 750;\n\t }\n\t _this.sun.y -= (150 * dt) / 1000;\n\t if (_this.sun.y <= 60) {\n\t _this.sun.y = 60;\n\t }\n\t }\n\t ld = Date.now();\n\t });\n\t };\n\t return CloudRain;\n\t}(engine.Container));\n\t//# sourceMappingURL=CloudRain.js.map\n\n\tvar GameTest = (function (_super) {\n\t tslib.__extends(GameTest, _super);\n\t function GameTest() {\n\t var _this = _super.call(this) || this;\n\t _this.timeArray = [];\n\t _this.container = new engine.Container();\n\t _this.dripArray = [];\n\t _this.clicknum = 0;\n\t _this.R = 250;\n\t _this.D = 340;\n\t _this.con = new engine.Sprite();\n\t _this.t1 = new engine.Sprite(getTexture('a163b74f-32bc-43d2-8015-7cf1eac71501'));\n\t _this.t2 = new engine.Sprite(getTexture('22de82d1-97ec-4195-a32c-f4fc1656e2de'));\n\t _this.t3 = new engine.Sprite(getTexture('cc952365-a990-4912-98af-50905559b9d5'));\n\t _this.once(engine.Event.ADDED_TO_STAGE, _this.setup, _this);\n\t return _this;\n\t }\n\t GameTest.prototype.setup = function () {\n\t var playBg = new engine.Sprite(getTexture(\"5ab43bdc-a6ce-46fb-99c2-a806f57f7484\"));\n\t this.addChild(playBg);\n\t this.humanbeing = new Human();\n\t this.humanbeing.x = 290;\n\t this.humanbeing.y = 750;\n\t this.addChild(this.humanbeing);\n\t console.log(\"xxxxxx\", this.stage.width, this.stage.height, this.width, this.height);\n\t this.rightHand = new engine.Sprite(getTexture(\"c7129f77-92a6-479e-9994-7d4b39040a15\"));\n\t this.rightHand.x = -70;\n\t this.rightHand.y = -65;\n\t this.rightHand.anchorX = 196;\n\t this.rightHand.anchorY = 253;\n\t this.humanbeing.addChild(this.rightHand);\n\t this.playBtn = new engine.Sprite(getTexture(\"9e347bef-6e91-4c92-ba5f-f9a52e656207\"));\n\t this.playBtn.x = 138;\n\t this.playBtn.y = 1150;\n\t this.playBtn.anchorX = this.playBtn.x + this.playBtn.width / 2;\n\t this.playBtn.anchorY = this.playBtn.y + this.playBtn.height / 2;\n\t this.addChild(this.playBtn);\n\t this.moists = new Moist();\n\t this.moists.x = 20;\n\t this.moists.y = 450;\n\t this.addChild(this.moists);\n\t this.cloud = new CloudRain();\n\t this.addChild(this.cloud);\n\t this.timeArray.push(this.t3, this.t2, this.t1);\n\t };\n\t GameTest.prototype.start = function () {\n\t var _this = this;\n\t var middleX = this.humanbeing.x + this.humanbeing.width / 2;\n\t var validX1 = this.humanbeing.x;\n\t var validX2 = this.humanbeing.x + this.humanbeing.width;\n\t var point1 = new engine.Graphics();\n\t point1.beginFill(0xff0000);\n\t point1.drawRect(0, 0, 10, 10);\n\t point1.x = 0;\n\t point1.y = 100;\n\t point1.endFill();\n\t this.rightHand.addChild(point1);\n\t var point2 = new engine.Graphics();\n\t point2.beginFill(0xff0000);\n\t point2.drawRect(0, 0, 10, 10);\n\t point2.x = 170;\n\t point2.y = 0;\n\t point2.endFill();\n\t this.rightHand.addChild(point2);\n\t var point3 = new engine.Graphics();\n\t point3.beginFill(0xff0000);\n\t point3.drawRect(0, 0, 10, 10);\n\t point3.x = 330;\n\t point3.y = 100;\n\t point3.endFill();\n\t this.rightHand.addChild(point3);\n\t window['p1'] = point1;\n\t window['p2'] = point2;\n\t window['p3'] = point3;\n\t this.timeCounter = new TimeCounter();\n\t this.addChild(this.timeCounter);\n\t var ld = Date.now();\n\t var a = 0;\n\t var b = 0;\n\t var timer = 0;\n\t var succeedFlag = false;\n\t var failFlag = false;\n\t for (var i = 0; i < this.timeArray.length; i++) {\n\t var t = this.timeArray[i];\n\t t.anchorTexture.set(0.5, 0.5);\n\t t.x = 750 / 2;\n\t t.y = 1624 / 2;\n\t t.alpha = 0;\n\t this.container.addChild(t);\n\t this.addChild(this.container);\n\t }\n\t for (var i = 0; i < this.timeArray.length; i++) {\n\t var img = this.timeArray[i];\n\t var delta = i * 1000;\n\t var t = engine.Tween.get(img);\n\t t.wait(delta).set({ alpha: 0.2, scaleX: 2, scaleY: 2 })\n\t .to({ alpha: 1, scaleX: 1, scaleY: 1 }, 300)\n\t .to({ alpha: 0 }, 200)\n\t .wait(500);\n\t if (i === this.timeArray.length - 1) {\n\t t.call(function () {\n\t engine.Tween.get(_this.container).to({ alpha: 0 }, 200).call(function () {\n\t _this.removeChild(_this.container);\n\t });\n\t _this.winds = createSvga(\"wind\");\n\t _this.addChild(_this.winds);\n\t _this.winds.visible = true;\n\t _this.winds.play(true, true);\n\t _this.winds.once(engine.Event.END_FRAME, function () {\n\t _this.removeChild(_this.winds);\n\t }, _this);\n\t });\n\t }\n\t }\n\t this.rainEffect = createSvga(\"雨滴动效\");\n\t this.addEventListener(engine.Event.ENTER_FRAME, function addFrame() {\n\t var _this = this;\n\t var dt = Date.now() - ld;\n\t b += dt;\n\t timer += dt;\n\t if (timer >= 3000) {\n\t a += dt;\n\t if (a > 10) {\n\t a = 0;\n\t if (this.moists.percent < 1 && this.timeCounter.time > 0) {\n\t var drip = new engine.Sprite(getTexture(\"07f74bf6-416f-445e-98d5-021efe4c9fdc\"));\n\t drip.x = Math.random() * (this.humanbeing.x + 160) + (this.humanbeing.x - 160);\n\t drip.y = Math.random() * 100 + 300;\n\t this.dripArray.push(drip);\n\t this.addChild(drip);\n\t }\n\t }\n\t var _loop_1 = function (drip) {\n\t drip.y += (300 * dt) / 1000;\n\t if (drip.y > this_1.stage.height) {\n\t var index_1 = this_1.dripArray.indexOf(drip);\n\t this_1.removeChild(drip);\n\t this_1.dripArray = this_1.dripArray.filter(function (ele, i) { return i != index_1; });\n\t }\n\t };\n\t var this_1 = this;\n\t for (var _i = 0, _a = this.dripArray; _i < _a.length; _i++) {\n\t var drip = _a[_i];\n\t _loop_1(drip);\n\t }\n\t if (b >= 1000) {\n\t b = 0;\n\t if (this.moists.percent < 1) {\n\t this.timeCounter.time -= 1;\n\t if (this.timeCounter.time <= 0) {\n\t this.timeCounter.time = 0;\n\t }\n\t this.timeCounter.updateTime(this.timeCounter.time);\n\t }\n\t if (this.timeCounter.time <= 0 && !succeedFlag) {\n\t this.timeCounter.time = 0;\n\t succeedFlag = true;\n\t console.log(\"游戏成功!\");\n\t this.success();\n\t }\n\t }\n\t var wind = -40;\n\t this.rightHand.rotation += wind / 60;\n\t if (this.rightHand.rotation <= -90) {\n\t this.rightHand.rotation = -90;\n\t }\n\t else if (this.rightHand.rotation >= 90) {\n\t this.rightHand.rotation = 90;\n\t }\n\t if (this.rightHand.rotation <= -60) {\n\t var face_1 = this.humanbeing.facialChange(1);\n\t face_1.x = 7;\n\t face_1.y = 22;\n\t setTimeout(function () {\n\t _this.humanbeing.removeFace(face_1);\n\t }, 100);\n\t }\n\t this.angle = Math.asin(this.D / 2 / this.R) * 57.18;\n\t this.rightHand.name = \"aaa\";\n\t var sa = this.worldMatrix.a;\n\t var sd = this.worldMatrix.d;\n\t var p1x = point1.worldMatrix.tx / sa;\n\t var p2x = point2.worldMatrix.tx / sa;\n\t var p3x = point3.worldMatrix.tx / sa;\n\t var p1y = point1.worldMatrix.ty / sd;\n\t var p2y = point2.worldMatrix.ty / sd;\n\t var p3y = point3.worldMatrix.ty / sd;\n\t var k12 = (p1y - p2y) / (p1x - p2x);\n\t var k23 = (p2y - p3y) / (p2x - p3x);\n\t var px1 = p1x;\n\t var px2 = p2x;\n\t var px3 = p3x;\n\t var maxX = px1 >= px2 ? (px1 >= px3 ? px1 : px3) : px2 >= px3 ? px2 : px3;\n\t var minX = px1 >= px2 ? (px2 >= px3 ? px3 : px2) : px1 >= px3 ? px3 : px1;\n\t var x2 = (middleX + this.R) < maxX ? (middleX + this.R) : maxX;\n\t var _loop_2 = function (drip) {\n\t var dx = drip.worldMatrix.tx / sa;\n\t var dy = drip.worldMatrix.ty / sd;\n\t var b12 = p1y - p1x * k12 - 50;\n\t var b23 = p2y - p2x * k23 - 50;\n\t var y12 = k12 * dx + b12;\n\t var y23 = k23 * dx + b23;\n\t if (dx >= minX && dx < maxX) {\n\t if (dx < px2) {\n\t if (dy >= y12) {\n\t var index_2 = this_2.dripArray.indexOf(drip);\n\t this_2.removeChild(drip);\n\t this_2.dripArray = this_2.dripArray.filter(function (ele, i) { return i != index_2; });\n\t }\n\t }\n\t if (dx >= px2) {\n\t if (dy >= y23) {\n\t var index_3 = this_2.dripArray.indexOf(drip);\n\t this_2.removeChild(drip);\n\t this_2.dripArray = this_2.dripArray.filter(function (ele, i) { return i != index_3; });\n\t }\n\t }\n\t }\n\t if (drip.x > this_2.humanbeing.x &&\n\t drip.x < this_2.humanbeing.x + this_2.humanbeing.width) {\n\t if (drip.y >= this_2.humanbeing.y) {\n\t this_2.moists.percent += 0.1;\n\t this_2.moists.cover(this_2.moists.percent);\n\t this_2.moists.updateText(this_2.moists.percent);\n\t this_2.addChild(this_2.rainEffect);\n\t this_2.rainEffect.visible = true;\n\t this_2.rainEffect.play(true, true);\n\t this_2.rainEffect.x = drip.x - drip.width * 2;\n\t this_2.rainEffect.y = drip.y;\n\t this_2.rainEffect.once(engine.Event.END_FRAME, function () {\n\t _this.rainEffect.visible = false;\n\t });\n\t if (this_2.moists.percent >= 1 && !failFlag) {\n\t this_2.moists.stopScale();\n\t failFlag = true;\n\t console.log(\"游戏结束!\");\n\t this_2.stop();\n\t }\n\t this_2.removeChild(drip);\n\t var face_2 = this_2.humanbeing.facialChange(2);\n\t face_2.x = 7;\n\t face_2.y = 22;\n\t setTimeout(function () {\n\t _this.humanbeing.removeFace(face_2);\n\t }, 500);\n\t console.log(\"\");\n\t var index_4 = this_2.dripArray.indexOf(drip);\n\t this_2.dripArray = this_2.dripArray.filter(function (ele, i) { return i != index_4; });\n\t this_2.humanbeing.scaleEffect();\n\t }\n\t }\n\t };\n\t var this_2 = this;\n\t for (var _b = 0, _c = this.dripArray; _b < _c.length; _b++) {\n\t var drip = _c[_b];\n\t _loop_2(drip);\n\t }\n\t }\n\t ld = Date.now();\n\t });\n\t this.playBtn.addEventListener(engine.MouseEvent.CLICK, this.onClick, this);\n\t this.rightHand.rotation = 0;\n\t };\n\t GameTest.prototype.onClick = function () {\n\t this.clicknum += 1;\n\t this.rightHand.rotation += 10 * this.clicknum;\n\t this.clicknum = 0;\n\t };\n\t GameTest.prototype.stop = function () {\n\t engine.globalEvent.dispatchEvent(\"cloud-game-fail\", { reason: 1 });\n\t };\n\t GameTest.prototype.success = function () {\n\t this.cloud.succeed();\n\t engine.globalEvent.dispatchEvent(\"cloud-game-success\", {\n\t moist: this.moists.percent,\n\t });\n\t };\n\t return GameTest;\n\t}(engine.Container));\n\n\tvar props = {};\n\tfunction prepareProps() {\n\t var metaProps = getProps();\n\t engine.injectProp(props, metaProps);\n\t}\n\tfunction injectProps(p) {\n\t engine.injectProp(props, p);\n\t}\n\t//# sourceMappingURL=props.js.map\n\n\tvar GameWrapper = (function (_super) {\n\t tslib.__extends(GameWrapper, _super);\n\t function GameWrapper() {\n\t var _this = _super.call(this) || this;\n\t engine.globalEvent.addEventListener('pictures-start', _this.start, _this);\n\t engine.globalEvent.addEventListener('pictures-stop', _this.stop, _this);\n\t var gameTest = _this._gameTest = new GameTest();\n\t _this.addChild(gameTest);\n\t return _this;\n\t }\n\t GameWrapper.prototype.start = function (event) {\n\t injectProps(event.data);\n\t this._gameTest.start();\n\t };\n\t GameWrapper.prototype.stop = function (event) {\n\t this._gameTest.stop();\n\t };\n\t return GameWrapper;\n\t}(engine.Container));\n\t//# sourceMappingURL=GameWrapper.js.map\n\n\tfunction index (props) {\n\t prepareProps();\n\t injectProps(props);\n\t var instance = new GameWrapper();\n\t return instance;\n\t}\n\t//# sourceMappingURL=index.js.map\n\n\treturn index;\n\n})));\n"
}
{
"name": "九宫格抽奖-更换奖池",
"desc": "九宫格抽奖模块-更换奖池",
"props": {
"horizontal": {
"alias": "横向间距",
"type": "number",
"default": 1
},
"vertical": {
"alias": "纵向间距",
"type": "number",
"default": 1
},
"circleNumber": {
"alias": "至少转的圈数",
"type": "number",
"default": 3
},
"tweenTime": {
"alias": "单个奖品节点动画时间(毫秒)",
"type": "number",
"default": 200
},
"slowTweenTime": {
"alias": "中奖后缓速递增时长",
"type": "number",
"default": 200
},
"icon_width": {
"alias": "奖品图宽度",
"type": "number",
"default": 110
},
"icon_height": {
"alias": "奖品图高度",
"type": "number",
"default": 110
},
"icon_X": {
"alias": "奖品X轴偏移量(底框背景有透明)",
"type": "number",
"default": 0
},
"icon_Y": {
"alias": "奖品Y轴偏移量(底框背景有透明)",
"type": "number",
"default": -20
},
"prizeName_size": {
"alias": "奖品名字字号",
"type": "number",
"default": 30
},
"prizeName_Ypos": {
"alias": "奖品名字相对于底框的高度",
"type": "number",
"default": 50
},
"prizeName_color": {
"alias": "奖品名字颜色值",
"type": "string",
"default": "#e8805d"
},
"prizeName_maxLength": {
"alias": "奖品名字最长显示长度",
"type": "number",
"default": 8
},
"prizeName_retainLength": {
"alias": "奖品名字超过长度保留多少字数",
"type": "number",
"default": 5
}
},
"assets": [
{
"name": "unchecked",
"url": "//yun.duiba.com.cn/aurora/assets/3351a20f982fea1fbcbbb3b85bc03f6b547c8bbc.png",
"uuid": "48dc9c00-92c3-4926-8d6b-9eb3e0d0668d",
"ext": ".png"
},
{
"name": "checked",
"url": " //yun.duiba.com.cn/aurora/assets/2a9f9ecc43eb912db553fa4685c1987a937f0198.png",
"uuid": "1d7bc84d-689d-4a6a-a023-e4a7b9659083",
"ext": ".png"
}
],
"events": {
"in": {
"jiugong-turntable-change-init": {
"alias": "初始化",
"data": {}
},
"jiugong-turntable-change-prizeData": {
"alias": "奖品数据",
"data": {}
},
"jiugong-turntable-change-start": {
"alias": "开始",
"data": {}
},
"jiugong-turntable-change-winPrize": {
"alias": "中奖",
"data": {}
},
"jiugong-turntable-change-abnormal": {
"alias": "异常",
"data": {}
},
"jiugong-turntable-change-reset": {
"alias": "重置",
"data": {}
}
},
"out": {
"jiugong-turntable-change-over": {
"alias": "结束",
"data": {}
}
}
},
"id": "jiugong-turntable-change",
"code": "(function (global, factory) {\n\ttypeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('tslib')) :\n\ttypeof define === 'function' && define.amd ? define(['tslib'], factory) :\n\t(global = global || self, global['jiugong-turntable-change'] = factory(global.tslib));\n}(this, (function (tslib) { 'use strict';\n\n\tfunction getTexture(uuid) {\r\n\t return engine.Texture.from(getAssetByUUID(uuid).uuid);\r\n\t}\r\n\tfunction getTextureByName(name) {\r\n\t return getTexture(engine.getAssetByName(name).uuid);\r\n\t}\r\n\t//# sourceMappingURL=utils.js.map\n\n\tvar props = {};\r\n\tfunction prepareProps() {\r\n\t var metaProps = getProps();\r\n\t engine.injectProp(props, metaProps);\r\n\t}\r\n\tfunction injectProps(p) {\r\n\t engine.injectProp(props, p);\r\n\t}\r\n\t//# sourceMappingURL=props.js.map\n\n\tvar Turntable = (function (_super) {\r\n\t tslib.__extends(Turntable, _super);\r\n\t function Turntable() {\r\n\t var _this = _super.call(this) || this;\r\n\t _this._vertical_Y = props.vertical || 20;\r\n\t _this._horizontal_X = props.horizontal || 20;\r\n\t _this._prizeIndex = 0;\r\n\t _this._boxArray = [];\r\n\t _this._boxIndex = 0;\r\n\t _this.tweenTime = props.tweenTime || 200;\r\n\t _this.slowTweenTime = props.slowTweenTime || 200;\r\n\t _this.circleNumber = 0;\r\n\t _this.turntableOrder = [1, 2, 3, 5, 8, 7, 6, 4];\r\n\t _this.recordID = -1;\r\n\t _this.boxPrizeIndex = -1;\r\n\t _this.slowDown = false;\r\n\t _this.isStop = false;\r\n\t return _this;\r\n\t }\r\n\t Turntable.prototype.initData = function (res) {\r\n\t this.initTurntable(res);\r\n\t this.setNodeOrder();\r\n\t };\r\n\t Turntable.prototype.initTurntable = function (res) {\r\n\t var turnTableNode = null;\r\n\t if (this._turnTableNode) {\r\n\t this.removeChild(this._turnTableNode);\r\n\t this._turnTableNode = null;\r\n\t this._boxArray = [];\r\n\t this._prizeIndex = 0;\r\n\t this._boxIndex = 0;\r\n\t }\r\n\t turnTableNode = this._turnTableNode = new engine.Container();\r\n\t this.addChild(turnTableNode);\r\n\t for (var index_Y = 0; index_Y < 3; index_Y++) {\r\n\t for (var index_X = 0; index_X < 3; index_X++) {\r\n\t if (index_X == 1 && index_Y == 1)\r\n\t continue;\r\n\t var tmpNode = new engine.Container();\r\n\t var unchecked = this.getImage('unchecked', 1);\r\n\t var checked = this.getImage('checked', 0);\r\n\t tmpNode.width = Math.max(unchecked.width, checked.width);\r\n\t this._singleNodeWidth = this._singleNodeWidth ? this._singleNodeWidth : tmpNode.width;\r\n\t tmpNode.height = Math.max(unchecked.height, checked.height);\r\n\t tmpNode.x = index_X * (tmpNode.width + this._horizontal_X);\r\n\t tmpNode.y = index_Y * (tmpNode.height + this._vertical_Y);\r\n\t tmpNode.addChild(unchecked);\r\n\t tmpNode.addChild(checked);\r\n\t var prize = new engine.Sprite(engine.Texture.fromImage(res[this._prizeIndex].img));\r\n\t var prizeID = res[this._prizeIndex].id;\r\n\t prize.width = props.icon_width;\r\n\t prize.height = props.icon_height;\r\n\t prize.x = (tmpNode.width - prize.width) / 2 + props.icon_X;\r\n\t prize.y = (tmpNode.height - prize.height) / 2 + props.icon_Y;\r\n\t tmpNode.prizeID = prizeID;\r\n\t tmpNode.addChild(prize);\r\n\t var titleLabel = new engine.Label();\r\n\t titleLabel.fillColor = props.prizeName_color;\r\n\t titleLabel.size = props.prizeName_size;\r\n\t titleLabel.width = unchecked.width;\r\n\t titleLabel.textAlign = engine.TEXT_ALIGN.CENTER;\r\n\t titleLabel.x = 0;\r\n\t titleLabel.y = props.prizeName_Ypos;\r\n\t titleLabel.text = this.fixTitle(res[this._prizeIndex].name);\r\n\t tmpNode.addChild(titleLabel);\r\n\t this._prizeIndex++;\r\n\t this._boxArray.push(tmpNode);\r\n\t turnTableNode.addChild(tmpNode);\r\n\t }\r\n\t }\r\n\t turnTableNode.x = (750 - (this._singleNodeWidth * 3 + this._horizontal_X * 2)) / 2;\r\n\t };\r\n\t Turntable.prototype.setNodeOrder = function () {\r\n\t var tmpNodeArray = [];\r\n\t for (var index = 0; index < this.turntableOrder.length; index++) {\r\n\t var order = this.turntableOrder[index];\r\n\t tmpNodeArray.push(this._boxArray[order - 1]);\r\n\t }\r\n\t this._boxArray = tmpNodeArray;\r\n\t };\r\n\t Turntable.prototype.fixTitle = function (name) {\r\n\t if (!name) {\r\n\t return \"\";\r\n\t }\r\n\t if (name.split(\"\").length < props.prizeName_maxLength) {\r\n\t return name;\r\n\t }\r\n\t var n = \"\";\r\n\t for (var i = 0; i < props.prizeName_retainLength; i++) {\r\n\t n += name.split(\"\")[i];\r\n\t }\r\n\t n += \"...\";\r\n\t return n;\r\n\t };\r\n\t Turntable.prototype.getImage = function (resName, alpha) {\r\n\t var tmpImage = new engine.Sprite(getTextureByName(resName));\r\n\t tmpImage.x = 0;\r\n\t tmpImage.y = 0;\r\n\t tmpImage.alpha = alpha;\r\n\t tmpImage.name = resName;\r\n\t return tmpImage;\r\n\t };\r\n\t Turntable.prototype.startDraw = function () {\r\n\t var _this = this;\r\n\t var tmpCheckNode = this._boxArray[this._boxIndex].getChildByName('checked');\r\n\t if (this.isStop) {\r\n\t engine.Tween.removeTweens(tmpCheckNode);\r\n\t return;\r\n\t }\r\n\t if (this.slowDown) {\r\n\t if (this._boxIndex != this.getNodeIndexOFprize()) {\r\n\t this.tweenTime += this.slowTweenTime;\r\n\t }\r\n\t else {\r\n\t this.isStop = true;\r\n\t this.twinkle(tmpCheckNode);\r\n\t }\r\n\t }\r\n\t engine.Tween.get(tmpCheckNode)\r\n\t .to({ alpha: 1 }, this.tweenTime / 2)\r\n\t .to({ alpha: 0 }, this.tweenTime / 2)\r\n\t .call(function () {\r\n\t if (_this.circleNumber >= props.circleNumber && _this.getSlowStart() == _this._boxIndex) {\r\n\t _this.slowDown = true;\r\n\t }\r\n\t _this._boxIndex++;\r\n\t if (_this._boxIndex >= _this._boxArray.length) {\r\n\t _this._boxIndex = 0;\r\n\t _this.circleNumber++;\r\n\t }\r\n\t _this.startDraw();\r\n\t });\r\n\t };\r\n\t Turntable.prototype.getSlowStart = function () {\r\n\t if (this.recordID < 0)\r\n\t return -1;\r\n\t var tmpIndex = this.getNodeIndexOFprize();\r\n\t if (tmpIndex < 4) {\r\n\t return tmpIndex + 4;\r\n\t }\r\n\t else {\r\n\t return tmpIndex - 4;\r\n\t }\r\n\t };\r\n\t Turntable.prototype.getNodeIndexOFprize = function () {\r\n\t if (this.recordID < 0)\r\n\t return -1;\r\n\t for (var index = 0; index < this._boxArray.length; index++) {\r\n\t var element = this._boxArray[index];\r\n\t if (element.prizeID === this.recordID) {\r\n\t return index;\r\n\t }\r\n\t }\r\n\t return -1;\r\n\t };\r\n\t Turntable.prototype.twinkle = function (tmpNode) {\r\n\t engine.Tween.removeTweens(tmpNode);\r\n\t var twinkleTime = 1;\r\n\t engine.Tween.get(tmpNode, { loop: true })\r\n\t .to({ alpha: 0 }, 30)\r\n\t .to({ alpha: 1 }, 30)\r\n\t .call(function () {\r\n\t if (twinkleTime > 5) {\r\n\t engine.Tween.removeTweens(tmpNode);\r\n\t engine.globalEvent.dispatchEvent('jiugong-turntable-change-over');\r\n\t return;\r\n\t }\r\n\t else {\r\n\t twinkleTime++;\r\n\t }\r\n\t });\r\n\t };\r\n\t Turntable.prototype.setRecordID = function (prizeID) {\r\n\t this.recordID = prizeID;\r\n\t };\r\n\t Turntable.prototype.reset = function () {\r\n\t this._boxArray.forEach(function (element) {\r\n\t engine.Tween.removeTweens(element.getChildByName('checked'));\r\n\t });\r\n\t this._boxIndex = 0;\r\n\t this.tweenTime = props.tweenTime || 200;\r\n\t this.slowTweenTime = props.slowTweenTime || 200;\r\n\t this.circleNumber = 0;\r\n\t this.recordID = -1;\r\n\t this.boxPrizeIndex = -1;\r\n\t this.slowDown = false;\r\n\t this.isStop = false;\r\n\t for (var index = 0; index < this._boxArray.length; index++) {\r\n\t var element = this._boxArray[index];\r\n\t element.getChildByName('checked').alpha = 0;\r\n\t }\r\n\t };\r\n\t return Turntable;\r\n\t}(engine.Container));\r\n\t//# sourceMappingURL=turntable.js.map\n\n\tvar GameView = (function (_super) {\r\n\t tslib.__extends(GameView, _super);\r\n\t function GameView() {\r\n\t return _super.call(this) || this;\r\n\t }\r\n\t GameView.prototype.setup = function () {\r\n\t if (this._hasSetup) {\r\n\t return;\r\n\t }\r\n\t this._hasSetup = true;\r\n\t var turntable = this._turntable = new Turntable();\r\n\t this.addChild(turntable);\r\n\t };\r\n\t GameView.prototype.setPrizeData = function (res) {\r\n\t this._turntable.initData(res);\r\n\t };\r\n\t GameView.prototype.startDraw = function () {\r\n\t this._turntable.startDraw();\r\n\t };\r\n\t GameView.prototype.setRecordID = function (prizeID) {\r\n\t this._turntable.setRecordID(prizeID);\r\n\t };\r\n\t GameView.prototype.reset = function () {\r\n\t this._turntable.reset();\r\n\t };\r\n\t GameView.prototype.setSetup = function () {\r\n\t this._hasSetup = false;\r\n\t };\r\n\t return GameView;\r\n\t}(engine.Container));\r\n\t//# sourceMappingURL=GameView.js.map\n\n\tvar GameWrapper = (function (_super) {\r\n\t tslib.__extends(GameWrapper, _super);\r\n\t function GameWrapper() {\r\n\t var _this = _super.call(this) || this;\r\n\t engine.globalEvent.addEventListener('jiugong-turntable-change-init', _this.init, _this);\r\n\t engine.globalEvent.addEventListener('jiugong-turntable-change-prizeData', _this.initPrizeData, _this);\r\n\t engine.globalEvent.addEventListener('jiugong-turntable-change-start', _this.start, _this);\r\n\t engine.globalEvent.addEventListener('jiugong-turntable-change-winPrize', _this.winPrize, _this);\r\n\t engine.globalEvent.addEventListener('jiugong-turntable-change-reset', _this.reset, _this);\r\n\t engine.globalEvent.addEventListener('jiugong-turntable-change-abnormal', _this.reset, _this);\r\n\t return _this;\r\n\t }\r\n\t GameWrapper.prototype.init = function (event) {\r\n\t var gameView = this._gameView = new GameView();\r\n\t this.addChild(gameView);\r\n\t this._gameView.setup();\r\n\t };\r\n\t GameWrapper.prototype.initPrizeData = function (event) {\r\n\t this._gameView.setSetup();\r\n\t this._gameView.setPrizeData(event.data.resources);\r\n\t };\r\n\t GameWrapper.prototype.start = function (event) {\r\n\t this._gameView.startDraw();\r\n\t };\r\n\t GameWrapper.prototype.winPrize = function (event) {\r\n\t this._gameView.setRecordID(event.data.prizeID);\r\n\t };\r\n\t GameWrapper.prototype.reset = function () {\r\n\t this._gameView.reset();\r\n\t };\r\n\t return GameWrapper;\r\n\t}(engine.Container));\r\n\t//# sourceMappingURL=GameWrapper.js.map\n\n\tfunction index (props) {\r\n\t prepareProps();\r\n\t injectProps(props);\r\n\t var instance = new GameWrapper();\r\n\t return instance;\r\n\t}\r\n\t//# sourceMappingURL=index.js.map\n\n\treturn index;\n\n})));\n"
}
...@@ -46,6 +46,11 @@ ...@@ -46,6 +46,11 @@
"alias": "奖品Y轴偏移量(底框背景有透明)", "alias": "奖品Y轴偏移量(底框背景有透明)",
"type": "number", "type": "number",
"default": -20 "default": -20
},
"layer": {
"alias": "中奖标志是否在最下层",
"type": "boolean",
"default": false
} }
}, },
"assets": [ "assets": [
...@@ -93,5 +98,5 @@ ...@@ -93,5 +98,5 @@
} }
}, },
"id": "jiugong-turntable", "id": "jiugong-turntable",
"code": "(function (global, factory) {\n\ttypeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('tslib')) :\n\ttypeof define === 'function' && define.amd ? define(['tslib'], factory) :\n\t(global = global || self, global['jiugong-turntable'] = factory(global.tslib));\n}(this, (function (tslib) { 'use strict';\n\n\tfunction getTexture(uuid) {\r\n\t return engine.Texture.from(getAssetByUUID(uuid).uuid);\r\n\t}\r\n\tfunction getTextureByName(name) {\r\n\t return getTexture(engine.getAssetByName(name).uuid);\r\n\t}\r\n\t//# sourceMappingURL=utils.js.map\n\n\tvar props = {};\r\n\tfunction prepareProps() {\r\n\t var metaProps = getProps();\r\n\t engine.injectProp(props, metaProps);\r\n\t}\r\n\tfunction injectProps(p) {\r\n\t engine.injectProp(props, p);\r\n\t}\r\n\t//# sourceMappingURL=props.js.map\n\n\tvar Turntable = (function (_super) {\r\n\t tslib.__extends(Turntable, _super);\r\n\t function Turntable(res) {\r\n\t var _this = _super.call(this) || this;\r\n\t _this._vertical_Y = props.vertical || 20;\r\n\t _this._horizontal_X = props.horizontal || 20;\r\n\t _this._prizeIndex = 0;\r\n\t _this._boxArray = [];\r\n\t _this._boxIndex = 0;\r\n\t _this.tweenTime = props.tweenTime || 200;\r\n\t _this.slowTweenTime = props.slowTweenTime || 200;\r\n\t _this.circleNumber = 0;\r\n\t _this.turntableOrder = [1, 2, 3, 5, 8, 7, 6, 4];\r\n\t _this.recordID = -1;\r\n\t _this.boxPrizeIndex = -1;\r\n\t _this.slowDown = false;\r\n\t _this.isStop = false;\r\n\t _this.initTurntable(res);\r\n\t _this.setNodeOrder();\r\n\t return _this;\r\n\t }\r\n\t Turntable.prototype.initTurntable = function (res) {\r\n\t var turnTableNode = this._turnTableNode = new engine.Container();\r\n\t this.addChild(turnTableNode);\r\n\t for (var index_Y = 0; index_Y < 3; index_Y++) {\r\n\t var _loop_1 = function (index_X) {\r\n\t if (index_X == 1 && index_Y == 1)\r\n\t return \"continue\";\r\n\t var tmpNode = new engine.Container();\r\n\t var unchecked = this_1.getImage('unchecked', 1);\r\n\t var checked = this_1.getImage('checked', 0);\r\n\t tmpNode.width = Math.max(unchecked.width, checked.width);\r\n\t this_1._singleNodeWidth = this_1._singleNodeWidth ? this_1._singleNodeWidth : tmpNode.width;\r\n\t tmpNode.height = Math.max(unchecked.height, checked.height);\r\n\t tmpNode.x = index_X * (tmpNode.width + this_1._horizontal_X);\r\n\t tmpNode.y = index_Y * (tmpNode.height + this_1._vertical_Y);\r\n\t tmpNode.addChild(unchecked);\r\n\t tmpNode.addChild(checked);\r\n\t turnTableNode.addChild(tmpNode);\r\n\t var tmpTexture = engine.Texture.fromImage(res[this_1._prizeIndex].img, undefined);\r\n\t var prizeID = res[this_1._prizeIndex].id;\r\n\t tmpTexture.addEventListener('loaded', function () {\r\n\t var prize = new engine.Sprite(tmpTexture);\r\n\t prize.width = props.icon_width;\r\n\t prize.height = props.icon_height;\r\n\t prize.x = (tmpNode.width - prize.width) / 2 + props.icon_X;\r\n\t prize.y = (tmpNode.height - prize.height) / 2 + props.icon_Y;\r\n\t tmpNode.prizeID = prizeID;\r\n\t tmpNode.addChild(prize);\r\n\t }, this_1);\r\n\t this_1._prizeIndex++;\r\n\t this_1._boxArray.push(tmpNode);\r\n\t };\r\n\t var this_1 = this;\r\n\t for (var index_X = 0; index_X < 3; index_X++) {\r\n\t _loop_1(index_X);\r\n\t }\r\n\t }\r\n\t turnTableNode.x = (750 - (this._singleNodeWidth * 3 + this._horizontal_X * 2)) / 2;\r\n\t };\r\n\t Turntable.prototype.setNodeOrder = function () {\r\n\t var tmpNodeArray = [];\r\n\t for (var index = 0; index < this.turntableOrder.length; index++) {\r\n\t var order = this.turntableOrder[index];\r\n\t tmpNodeArray.push(this._boxArray[order - 1]);\r\n\t }\r\n\t this._boxArray = tmpNodeArray;\r\n\t };\r\n\t Turntable.prototype.getImage = function (resName, alpha) {\r\n\t var tmpImage = new engine.Sprite(getTextureByName(resName));\r\n\t tmpImage.x = 0;\r\n\t tmpImage.y = 0;\r\n\t tmpImage.alpha = alpha;\r\n\t tmpImage.name = resName;\r\n\t return tmpImage;\r\n\t };\r\n\t Turntable.prototype.startDraw = function () {\r\n\t var _this = this;\r\n\t var tmpCheckNode = this._boxArray[this._boxIndex].getChildByName('checked');\r\n\t if (this.isStop) {\r\n\t engine.Tween.removeTweens(tmpCheckNode);\r\n\t return;\r\n\t }\r\n\t if (this.slowDown) {\r\n\t if (this._boxIndex != this.getNodeIndexOFprize()) {\r\n\t this.tweenTime += this.slowTweenTime;\r\n\t }\r\n\t else {\r\n\t this.isStop = true;\r\n\t this.twinkle(tmpCheckNode);\r\n\t }\r\n\t }\r\n\t engine.Tween.get(tmpCheckNode)\r\n\t .to({ alpha: 1 }, this.tweenTime / 2)\r\n\t .to({ alpha: 0 }, this.tweenTime / 2)\r\n\t .call(function () {\r\n\t if (_this.circleNumber >= props.circleNumber && _this.getSlowStart() == _this._boxIndex) {\r\n\t _this.slowDown = true;\r\n\t }\r\n\t _this._boxIndex++;\r\n\t if (_this._boxIndex >= _this._boxArray.length) {\r\n\t _this._boxIndex = 0;\r\n\t _this.circleNumber++;\r\n\t }\r\n\t _this.startDraw();\r\n\t });\r\n\t };\r\n\t Turntable.prototype.getSlowStart = function () {\r\n\t if (this.recordID < 0)\r\n\t return -1;\r\n\t var tmpIndex = this.getNodeIndexOFprize();\r\n\t if (tmpIndex < 4) {\r\n\t return tmpIndex + 4;\r\n\t }\r\n\t else {\r\n\t return tmpIndex - 4;\r\n\t }\r\n\t };\r\n\t Turntable.prototype.getNodeIndexOFprize = function () {\r\n\t if (this.recordID < 0)\r\n\t return -1;\r\n\t for (var index = 0; index < this._boxArray.length; index++) {\r\n\t var element = this._boxArray[index];\r\n\t if (element.prizeID === this.recordID) {\r\n\t return index;\r\n\t }\r\n\t }\r\n\t return -1;\r\n\t };\r\n\t Turntable.prototype.twinkle = function (tmpNode) {\r\n\t engine.Tween.removeTweens(tmpNode);\r\n\t var twinkleTime = 1;\r\n\t engine.Tween.get(tmpNode, { loop: true })\r\n\t .to({ alpha: 0 }, 30)\r\n\t .to({ alpha: 1 }, 30)\r\n\t .call(function () {\r\n\t if (twinkleTime > 5) {\r\n\t engine.Tween.removeTweens(tmpNode);\r\n\t engine.globalEvent.dispatchEvent('jiugong-turntable-over');\r\n\t return;\r\n\t }\r\n\t else {\r\n\t twinkleTime++;\r\n\t }\r\n\t });\r\n\t };\r\n\t Turntable.prototype.setRecordID = function (prizeID) {\r\n\t this.recordID = prizeID;\r\n\t };\r\n\t Turntable.prototype.reset = function () {\r\n\t engine.Tween.removeAllTweens();\r\n\t this._boxIndex = 0;\r\n\t this.tweenTime = props.tweenTime || 200;\r\n\t this.slowTweenTime = props.slowTweenTime || 200;\r\n\t this.circleNumber = 0;\r\n\t this.recordID = -1;\r\n\t this.boxPrizeIndex = -1;\r\n\t this.slowDown = false;\r\n\t this.isStop = false;\r\n\t for (var index = 0; index < this._boxArray.length; index++) {\r\n\t var element = this._boxArray[index];\r\n\t element.getChildByName('checked').alpha = 0;\r\n\t }\r\n\t };\r\n\t return Turntable;\r\n\t}(engine.Container));\r\n\t//# sourceMappingURL=turntable.js.map\n\n\tvar GameView = (function (_super) {\r\n\t tslib.__extends(GameView, _super);\r\n\t function GameView() {\r\n\t return _super.call(this) || this;\r\n\t }\r\n\t GameView.prototype.setup = function (res) {\r\n\t if (this._hasSetup) {\r\n\t return;\r\n\t }\r\n\t this._hasSetup = true;\r\n\t var turntable = this._turntable = new Turntable(res);\r\n\t this.addChild(turntable);\r\n\t };\r\n\t GameView.prototype.startDraw = function () {\r\n\t this._turntable.startDraw();\r\n\t };\r\n\t GameView.prototype.setRecordID = function (prizeID) {\r\n\t this._turntable.setRecordID(prizeID);\r\n\t };\r\n\t GameView.prototype.reset = function () {\r\n\t this._turntable.reset();\r\n\t };\r\n\t return GameView;\r\n\t}(engine.Container));\r\n\t//# sourceMappingURL=GameView.js.map\n\n\tvar GameWrapper = (function (_super) {\r\n\t tslib.__extends(GameWrapper, _super);\r\n\t function GameWrapper() {\r\n\t var _this = _super.call(this) || this;\r\n\t engine.globalEvent.addEventListener('jiugong-turntable-init', _this.init, _this);\r\n\t engine.globalEvent.addEventListener('jiugong-turntable-start', _this.start, _this);\r\n\t engine.globalEvent.addEventListener('jiugong-turntable-winPrize', _this.winPrize, _this);\r\n\t engine.globalEvent.addEventListener('jiugong-turntable-reset', _this.reset, _this);\r\n\t engine.globalEvent.addEventListener('jiugong-turntable-abnormal', _this.reset, _this);\r\n\t return _this;\r\n\t }\r\n\t GameWrapper.prototype.init = function (event) {\r\n\t var gameView = this._gameView = new GameView();\r\n\t this.addChild(gameView);\r\n\t console.log('奖品图', event.data.resources);\r\n\t this._gameView.setup(event.data.resources);\r\n\t };\r\n\t GameWrapper.prototype.start = function (event) {\r\n\t this._gameView.startDraw();\r\n\t };\r\n\t GameWrapper.prototype.winPrize = function (event) {\r\n\t this._gameView.setRecordID(event.data.prizeID);\r\n\t };\r\n\t GameWrapper.prototype.reset = function () {\r\n\t this._gameView.reset();\r\n\t };\r\n\t return GameWrapper;\r\n\t}(engine.Container));\r\n\t//# sourceMappingURL=GameWrapper.js.map\n\n\tfunction index (props) {\r\n\t prepareProps();\r\n\t injectProps(props);\r\n\t var instance = new GameWrapper();\r\n\t return instance;\r\n\t}\r\n\t//# sourceMappingURL=index.js.map\n\n\treturn index;\n\n})));\n" "code": "(function (global, factory) {\n\ttypeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('tslib')) :\n\ttypeof define === 'function' && define.amd ? define(['tslib'], factory) :\n\t(global = global || self, global['jiugong-turntable'] = factory(global.tslib));\n}(this, (function (tslib) { 'use strict';\n\n\tfunction getTexture(uuid) {\r\n\t return engine.Texture.from(getAssetByUUID(uuid).uuid);\r\n\t}\r\n\tfunction getTextureByName(name) {\r\n\t return getTexture(engine.getAssetByName(name).uuid);\r\n\t}\r\n\t//# sourceMappingURL=utils.js.map\n\n\tvar props = {};\r\n\tfunction prepareProps() {\r\n\t var metaProps = getProps();\r\n\t engine.injectProp(props, metaProps);\r\n\t}\r\n\tfunction injectProps(p) {\r\n\t engine.injectProp(props, p);\r\n\t}\r\n\t//# sourceMappingURL=props.js.map\n\n\tvar Turntable = (function (_super) {\r\n\t tslib.__extends(Turntable, _super);\r\n\t function Turntable(res) {\r\n\t var _this = _super.call(this) || this;\r\n\t _this._vertical_Y = props.vertical || 20;\r\n\t _this._horizontal_X = props.horizontal || 20;\r\n\t _this._prizeIndex = 0;\r\n\t _this._boxArray = [];\r\n\t _this._boxIndex = 0;\r\n\t _this.tweenTime = props.tweenTime || 200;\r\n\t _this.slowTweenTime = props.slowTweenTime || 200;\r\n\t _this.circleNumber = 0;\r\n\t _this.turntableOrder = [1, 2, 3, 5, 8, 7, 6, 4];\r\n\t _this.recordID = -1;\r\n\t _this.boxPrizeIndex = -1;\r\n\t _this.slowDown = false;\r\n\t _this.isStop = false;\r\n\t _this.initTurntable(res);\r\n\t _this.setNodeOrder();\r\n\t return _this;\r\n\t }\r\n\t Turntable.prototype.initTurntable = function (res) {\r\n\t var turnTableNode = this._turnTableNode = new engine.Container();\r\n\t this.addChild(turnTableNode);\r\n\t for (var index_Y = 0; index_Y < 3; index_Y++) {\r\n\t for (var index_X = 0; index_X < 3; index_X++) {\r\n\t if (index_X == 1 && index_Y == 1)\r\n\t continue;\r\n\t var tmpNode = new engine.Container();\r\n\t var unchecked = this.getImage('unchecked', 1);\r\n\t var checked = this.getImage('checked', 0);\r\n\t tmpNode.width = Math.max(unchecked.width, checked.width);\r\n\t this._singleNodeWidth = this._singleNodeWidth ? this._singleNodeWidth : tmpNode.width;\r\n\t tmpNode.height = Math.max(unchecked.height, checked.height);\r\n\t tmpNode.x = index_X * (tmpNode.width + this._horizontal_X);\r\n\t tmpNode.y = index_Y * (tmpNode.height + this._vertical_Y);\r\n\t checked.x = (tmpNode.width - checked.width) / 2;\r\n\t checked.y = (tmpNode.height - checked.height) / 2;\r\n\t unchecked.x = (tmpNode.width - unchecked.width) / 2;\r\n\t unchecked.y = (tmpNode.height - unchecked.height) / 2;\r\n\t if (props.layer) {\r\n\t tmpNode.addChild(checked);\r\n\t tmpNode.addChild(unchecked);\r\n\t }\r\n\t else {\r\n\t tmpNode.addChild(unchecked);\r\n\t tmpNode.addChild(checked);\r\n\t }\r\n\t turnTableNode.addChild(tmpNode);\r\n\t var prize = new engine.Sprite(engine.Texture.fromImage(res[this._prizeIndex].img));\r\n\t var prizeID = res[this._prizeIndex].id;\r\n\t prize.width = props.icon_width;\r\n\t prize.height = props.icon_height;\r\n\t prize.x = (tmpNode.width - prize.width) / 2 + props.icon_X;\r\n\t prize.y = (tmpNode.height - prize.height) / 2 + props.icon_Y;\r\n\t tmpNode.prizeID = prizeID;\r\n\t tmpNode.addChild(prize);\r\n\t this._prizeIndex++;\r\n\t this._boxArray.push(tmpNode);\r\n\t }\r\n\t }\r\n\t turnTableNode.x = (750 - (this._singleNodeWidth * 3 + this._horizontal_X * 2)) / 2;\r\n\t };\r\n\t Turntable.prototype.setNodeOrder = function () {\r\n\t var tmpNodeArray = [];\r\n\t for (var index = 0; index < this.turntableOrder.length; index++) {\r\n\t var order = this.turntableOrder[index];\r\n\t tmpNodeArray.push(this._boxArray[order - 1]);\r\n\t }\r\n\t this._boxArray = tmpNodeArray;\r\n\t };\r\n\t Turntable.prototype.getImage = function (resName, alpha) {\r\n\t var tmpImage = new engine.Sprite(getTextureByName(resName));\r\n\t tmpImage.x = 0;\r\n\t tmpImage.y = 0;\r\n\t tmpImage.alpha = alpha;\r\n\t tmpImage.name = resName;\r\n\t return tmpImage;\r\n\t };\r\n\t Turntable.prototype.startDraw = function () {\r\n\t var _this = this;\r\n\t var tmpCheckNode = this._boxArray[this._boxIndex].getChildByName('checked');\r\n\t if (this.isStop) {\r\n\t engine.Tween.removeTweens(tmpCheckNode);\r\n\t return;\r\n\t }\r\n\t if (this.slowDown) {\r\n\t if (this._boxIndex != this.getNodeIndexOFprize()) {\r\n\t this.tweenTime += this.slowTweenTime;\r\n\t }\r\n\t else {\r\n\t this.isStop = true;\r\n\t this.twinkle(tmpCheckNode);\r\n\t }\r\n\t }\r\n\t engine.Tween.get(tmpCheckNode)\r\n\t .to({ alpha: 1 }, this.tweenTime / 2)\r\n\t .to({ alpha: 0 }, this.tweenTime / 2)\r\n\t .call(function () {\r\n\t if (_this.circleNumber >= props.circleNumber && _this.getSlowStart() == _this._boxIndex) {\r\n\t _this.slowDown = true;\r\n\t }\r\n\t _this._boxIndex++;\r\n\t if (_this._boxIndex >= _this._boxArray.length) {\r\n\t _this._boxIndex = 0;\r\n\t _this.circleNumber++;\r\n\t }\r\n\t _this.startDraw();\r\n\t });\r\n\t };\r\n\t Turntable.prototype.getSlowStart = function () {\r\n\t if (this.recordID < 0)\r\n\t return -1;\r\n\t var tmpIndex = this.getNodeIndexOFprize();\r\n\t if (tmpIndex < 4) {\r\n\t return tmpIndex + 4;\r\n\t }\r\n\t else {\r\n\t return tmpIndex - 4;\r\n\t }\r\n\t };\r\n\t Turntable.prototype.getNodeIndexOFprize = function () {\r\n\t if (this.recordID < 0)\r\n\t return -1;\r\n\t for (var index = 0; index < this._boxArray.length; index++) {\r\n\t var element = this._boxArray[index];\r\n\t if (element.prizeID === this.recordID) {\r\n\t return index;\r\n\t }\r\n\t }\r\n\t return -1;\r\n\t };\r\n\t Turntable.prototype.twinkle = function (tmpNode) {\r\n\t engine.Tween.removeTweens(tmpNode);\r\n\t var twinkleTime = 1;\r\n\t engine.Tween.get(tmpNode, { loop: true })\r\n\t .to({ alpha: 0 }, 30)\r\n\t .to({ alpha: 1 }, 30)\r\n\t .call(function () {\r\n\t if (twinkleTime > 5) {\r\n\t engine.Tween.removeTweens(tmpNode);\r\n\t engine.globalEvent.dispatchEvent('jiugong-turntable-over');\r\n\t return;\r\n\t }\r\n\t else {\r\n\t twinkleTime++;\r\n\t }\r\n\t });\r\n\t };\r\n\t Turntable.prototype.setRecordID = function (prizeID) {\r\n\t this.recordID = prizeID;\r\n\t };\r\n\t Turntable.prototype.reset = function () {\r\n\t engine.Tween.removeAllTweens();\r\n\t this._boxIndex = 0;\r\n\t this.tweenTime = props.tweenTime || 200;\r\n\t this.slowTweenTime = props.slowTweenTime || 200;\r\n\t this.circleNumber = 0;\r\n\t this.recordID = -1;\r\n\t this.boxPrizeIndex = -1;\r\n\t this.slowDown = false;\r\n\t this.isStop = false;\r\n\t for (var index = 0; index < this._boxArray.length; index++) {\r\n\t var element = this._boxArray[index];\r\n\t element.getChildByName('checked').alpha = 0;\r\n\t }\r\n\t };\r\n\t return Turntable;\r\n\t}(engine.Container));\n\n\tvar GameView = (function (_super) {\r\n\t tslib.__extends(GameView, _super);\r\n\t function GameView() {\r\n\t return _super.call(this) || this;\r\n\t }\r\n\t GameView.prototype.setup = function (res) {\r\n\t if (this._hasSetup) {\r\n\t return;\r\n\t }\r\n\t this._hasSetup = true;\r\n\t var turntable = this._turntable = new Turntable(res);\r\n\t this.addChild(turntable);\r\n\t };\r\n\t GameView.prototype.startDraw = function () {\r\n\t this._turntable.startDraw();\r\n\t };\r\n\t GameView.prototype.setRecordID = function (prizeID) {\r\n\t this._turntable.setRecordID(prizeID);\r\n\t };\r\n\t GameView.prototype.reset = function () {\r\n\t this._turntable.reset();\r\n\t };\r\n\t return GameView;\r\n\t}(engine.Container));\r\n\t//# sourceMappingURL=GameView.js.map\n\n\tvar GameWrapper = (function (_super) {\r\n\t tslib.__extends(GameWrapper, _super);\r\n\t function GameWrapper() {\r\n\t var _this = _super.call(this) || this;\r\n\t engine.globalEvent.addEventListener('jiugong-turntable-init', _this.init, _this);\r\n\t engine.globalEvent.addEventListener('jiugong-turntable-start', _this.start, _this);\r\n\t engine.globalEvent.addEventListener('jiugong-turntable-winPrize', _this.winPrize, _this);\r\n\t engine.globalEvent.addEventListener('jiugong-turntable-reset', _this.reset, _this);\r\n\t engine.globalEvent.addEventListener('jiugong-turntable-abnormal', _this.reset, _this);\r\n\t return _this;\r\n\t }\r\n\t GameWrapper.prototype.init = function (event) {\r\n\t var gameView = this._gameView = new GameView();\r\n\t this.addChild(gameView);\r\n\t console.log('奖品图', event.data.resources);\r\n\t this._gameView.setup(event.data.resources);\r\n\t };\r\n\t GameWrapper.prototype.start = function (event) {\r\n\t this._gameView.startDraw();\r\n\t };\r\n\t GameWrapper.prototype.winPrize = function (event) {\r\n\t this._gameView.setRecordID(event.data.prizeID);\r\n\t };\r\n\t GameWrapper.prototype.reset = function () {\r\n\t this._gameView.reset();\r\n\t };\r\n\t return GameWrapper;\r\n\t}(engine.Container));\r\n\t//# sourceMappingURL=GameWrapper.js.map\n\n\tfunction index (props) {\r\n\t prepareProps();\r\n\t injectProps(props);\r\n\t var instance = new GameWrapper();\r\n\t return instance;\r\n\t}\r\n\t//# sourceMappingURL=index.js.map\n\n\treturn index;\n\n})));\n"
} }
{
"name": "拼图",
"desc": "拼图模块1.0",
"props": {
"MAX_COL": {
"alias": "图片分成几列",
"type": "number",
"default": 3
},
"MAX_ROW": {
"alias": "图片分成几行",
"type": "number",
"default": 4
},
"W": {
"alias": "图片的宽度",
"type": "number",
"default": 618
},
"H": {
"alias": "图片的高度",
"type": "number",
"default": 827
},
"OFFSET_X": {
"alias": "OFFSET_X",
"type": "number",
"default": 0
},
"OFFSET_Y": {
"alias": "OFFSET_Y",
"type": "number",
"default": 0
},
"GAP": {
"alias": "图片间隙",
"type": "number",
"default": 0
},
"GAME_TIME": {
"alias": "游戏时间",
"type": "number",
"default": 10
}
},
"assets": [
{
"name": "block",
"url": "//yun.duiba.com.cn/aurora/assets/f91184b338ef9540b167eebe7d58e71402e8d9d9.png",
"uuid": "888",
"ext": ".png"
},
{
"name": "ball",
"url": "//yun.duiba.com.cn/aurora/assets/3dc11f2d91659b7e7e1d06a9853cbc9f818e1ea2.png",
"uuid": "999",
"ext": ".png"
}
],
"events": {
"in": {
"pictures-start": {
"alias": "开始",
"data": {
"picUrl": "图片路径",
"blockUrl": "blockUrl",
"row": "行",
"column": "列",
"gameTime": "游戏时间"
}
},
"pictures-stop": {
"alias": "停止"
}
},
"out": {
"pictures-time-update": {
"alias": "倒计时更新",
"data": {
"time": "剩余时间"
}
},
"pictures-game-fail": {
"alias": "游戏结束",
"data": {
"reason": "结束原因(1:时间到了)"
}
},
"pictures-game-success": {
"alias": "游戏成功",
"data": {
"time": "游戏消耗时间"
}
}
}
},
"id": "p2demo",
"code": "(function (global, factory) {\n\ttypeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('tslib')) :\n\ttypeof define === 'function' && define.amd ? define(['tslib'], factory) :\n\t(global = global || self, global.p2demo = factory(global.tslib));\n}(this, (function (tslib) { 'use strict';\n\n\tfunction getTexture(uuid) {\n\t return engine.Texture.from(getAssetByUUID(uuid).uuid);\n\t}\n\tfunction getTextureByName(name) {\n\t return getTexture(engine.getAssetByName(name).uuid);\n\t}\n\tvar OptionState;\n\t(function (OptionState) {\n\t OptionState[OptionState[\"CHOICE_RIGHT\"] = 0] = \"CHOICE_RIGHT\";\n\t OptionState[OptionState[\"CHOICE_WRONG\"] = 1] = \"CHOICE_WRONG\";\n\t OptionState[OptionState[\"CHOICE_SELECT\"] = 2] = \"CHOICE_SELECT\";\n\t})(OptionState || (OptionState = {}));\n\tvar GameState;\n\t(function (GameState) {\n\t GameState[GameState[\"STATE_START\"] = 0] = \"STATE_START\";\n\t GameState[GameState[\"STATE_END\"] = 1] = \"STATE_END\";\n\t})(GameState || (GameState = {}));\n\t//# sourceMappingURL=utils.js.map\n\n\tvar GameView = (function (_super) {\n\t tslib.__extends(GameView, _super);\n\t function GameView() {\n\t var _this = _super.call(this) || this;\n\t _this.factor = 10;\n\t _this.isDebug = 0;\n\t _this.once(engine.Event.ADDED_TO_STAGE, _this.setup, _this);\n\t return _this;\n\t }\n\t GameView.prototype.createBall = function (r) {\n\t var shape = new engine.Shape();\n\t shape.beginFill(0xfff000);\n\t shape.drawCircle(0, 0, r);\n\t shape.endFill();\n\t return shape;\n\t };\n\t GameView.prototype.start = function () {\n\t console.log('start');\n\t this.stage.addEventListener(engine.MouseEvent.CLICK, this.onClick, this);\n\t };\n\t GameView.prototype.createBitmapByName = function (name) {\n\t var imgContainer = new engine.Sprite();\n\t var img = new engine.Sprite(getTextureByName(name));\n\t img.anchorX = img.width / 2;\n\t img.anchorY = img.height / 2;\n\t img.x = -img.width / 2;\n\t img.y = -img.height / 2;\n\t imgContainer.addChild(img);\n\t return imgContainer;\n\t };\n\t GameView.prototype.createBox = function (width, height) {\n\t var shape = new engine.Shape();\n\t shape.beginFill(0xfff000);\n\t shape.drawRect(-width / 2, -height / 2, width, height);\n\t shape.endFill();\n\t return shape;\n\t };\n\t GameView.prototype.onClick = function (e) {\n\t var _a = this, world = _a.world, factor = _a.factor;\n\t var positionX = (e.stageX / factor);\n\t var positionY = ((engine.gameStage.stage.height - e.stageY) / factor);\n\t var display;\n\t if (Math.random() > .5) {\n\t var boxShape = new p2.Box({ width: 306 / factor, height: 172 / factor });\n\t var boxBody = new p2.Body({ mass: 1, position: [positionX, positionY], angularVelocity: 1 });\n\t boxBody.addShape(boxShape);\n\t world.addBody(boxBody);\n\t if (this.isDebug) {\n\t display = this.createBox(boxShape.width * factor, boxShape.height * factor);\n\t }\n\t else {\n\t display = this.createBitmapByName(\"block\");\n\t }\n\t }\n\t else {\n\t var boxShape = new p2.Circle({ radius: 120 / 2 / factor });\n\t var boxBody = new p2.Body({ mass: 1, position: [positionX, positionY] });\n\t boxBody.addShape(boxShape);\n\t world.addBody(boxBody);\n\t if (this.isDebug) {\n\t display = this.createBall(boxShape.radius * factor);\n\t }\n\t else {\n\t display = this.createBitmapByName(\"ball\");\n\t }\n\t }\n\t boxBody.displays = [display];\n\t this.addChild(display);\n\t };\n\t GameView.prototype.setup = function () {\n\t console.log('setup');\n\t var world = new p2.World({\n\t gravity: [0, -10],\n\t });\n\t world.sleepMode = p2.World.BODY_SLEEPING;\n\t var planeShape = new p2.Plane();\n\t var planeBody = new p2.Body();\n\t planeBody.addShape(planeShape);\n\t planeBody.displays = [];\n\t world.addBody(planeBody);\n\t this.world = world;\n\t this.stage.addEventListener(engine.Event.ENTER_FRAME, this.onEnterFrame, this);\n\t };\n\t GameView.prototype.onEnterFrame = function () {\n\t var _a = this, world = _a.world, factor = _a.factor;\n\t world.step(60 / 1000);\n\t var stageHeight = engine.gameStage.stage.height;\n\t var l = world.bodies.length;\n\t for (var i = 0; i < l; i++) {\n\t var boxBody = world.bodies[i];\n\t var box = boxBody.displays[0];\n\t if (box) {\n\t box.x = boxBody.position[0] * factor;\n\t box.y = stageHeight - boxBody.position[1] * factor;\n\t box.rotation = 360 - (boxBody.angle + boxBody.shapes[0].angle) * 180 / Math.PI;\n\t if (boxBody.sleepState == p2.Body.SLEEPING) {\n\t box.alpha = 0.5;\n\t }\n\t else {\n\t box.alpha = 1;\n\t }\n\t }\n\t }\n\t };\n\t return GameView;\n\t}(engine.Container));\n\n\tvar props = {};\n\tfunction prepareProps() {\n\t var metaProps = getProps();\n\t engine.injectProp(props, metaProps);\n\t}\n\tfunction injectProps(p) {\n\t engine.injectProp(props, p);\n\t}\n\t//# sourceMappingURL=props.js.map\n\n\tvar GameWrapper = (function (_super) {\n\t tslib.__extends(GameWrapper, _super);\n\t function GameWrapper() {\n\t var _this = _super.call(this) || this;\n\t engine.globalEvent.addEventListener('pictures-start', _this.start, _this);\n\t engine.globalEvent.addEventListener('pictures-stop', _this.stop, _this);\n\t var gameView = _this._gameView = new GameView();\n\t _this.addChild(gameView);\n\t return _this;\n\t }\n\t GameWrapper.prototype.start = function (event) {\n\t injectProps(event.data);\n\t this._gameView.start();\n\t };\n\t GameWrapper.prototype.stop = function (event) {\n\t };\n\t return GameWrapper;\n\t}(engine.Container));\n\t//# sourceMappingURL=GameWrapper.js.map\n\n\tfunction index (props) {\n\t prepareProps();\n\t injectProps(props);\n\t var instance = new GameWrapper();\n\t return instance;\n\t}\n\t//# sourceMappingURL=index.js.map\n\n\treturn index;\n\n})));\n"
}
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
"GAME_TIME": { "GAME_TIME": {
"alias": "游戏时间", "alias": "游戏时间",
"type": "number", "type": "number",
"default": 50 "default": 10
} }
}, },
"assets": [ "assets": [
...@@ -57,7 +57,10 @@ ...@@ -57,7 +57,10 @@
"alias": "开始", "alias": "开始",
"data": { "data": {
"picUrl": "图片路径", "picUrl": "图片路径",
"blockUrl": "blockUrl" "blockUrl": "blockUrl",
"row": "行",
"column": "列",
"gameTime": "游戏时间"
} }
}, },
"pictures-stop": { "pictures-stop": {
...@@ -86,5 +89,5 @@ ...@@ -86,5 +89,5 @@
} }
}, },
"id": "pictures", "id": "pictures",
"code": "\"use strict\";var tslib=require(\"tslib\"),props={};function prepareProps(){var t=getProps();engine.injectProp(props,t)}function injectProps(t){engine.injectProp(props,t)}var MAX_COL,MAX_ROW,W,H,GAP,GAME_TIME,w,h,picMap={},posMap={},qietu=function(n,r,o,a){if(picMap[r]){for(var t=0,e=picMap[r];t<e.length;t++){var i=e[t];n.addChild(i)}return[picMap[r],posMap[r]]}for(var p=props.W,h=props.H,c=props.GAP,d=[],u=[],s=function(s){for(var t=function(e){var i=engine.Sprite.fromImage(r);d.push(i),i.scaleX=1/o,i.scaleY=1/a,n.addChild(i),i.x=e*(p/o+c),i.y=s*(h/a+c),u.push([i.x,i.y]),i.addEventListener(engine.Event.COMPLETE,function(){var t=new Float32Array([e/o,s/a,(e+1)/o,s/a,(e+1)/o,(s+1)/a,e/o,(s+1)/a]);i.uvs=t})},e=0;e<o;e++)t(e)},g=0;g<a;g++)s(g);return picMap[r]=d.concat([]),posMap[r]=u.concat([]),[d,u]};function getIndexFromRC(t,e,i){return t*i+e}function getRandomArray(t){t.sort(function(){return.5-Math.random()})}var GameView=function(e){function t(){var t=e.call(this)||this;return t._timeCounter=0,t.listenStageOn=1,t.once(engine.Event.ADDED_TO_STAGE,t.setup,t),t}return tslib.__extends(t,e),t.prototype.start=function(){var t=this;if(this.guideHole||(this.guideHole=new engine.Image,this.guideHole.source=\"asset://\"+props.blockUrl,this.guideHole.mouseChildren=this.guideHole.mouseEnabled=!1),this.pictures)for(var e=0,i=this.pictures;e<i.length;e++){var s=i[e];s&&s.parent&&s.parent.removeChild(s)}console.log(\"on start\"),engine.globalEvent.dispatchEvent(\"pictures-time-update\",{second:this.getSecond()});var n=qietu(this.picturesWrapper,props.picUrl,MAX_COL,MAX_ROW);this.picturesWrapper.addChild(this.guideHole),console.log(this.picturesWrapper),this.pictures=n[0],this.rightList=this.pictures.concat([]);var r=n[1];getRandomArray(this.pictures);var o,a=0;for(o=this.pictures.length;a<o;a++){this.dragPic=this.pictures[a],this.pictures[a].addEventListener(engine.MouseEvent.MOUSE_DOWN,this.onDown,this);var p=r[a],h=p[0],c=p[1];this.dragPic.x=h,this.dragPic.y=c}this._timer=setInterval(function(){t.onTimer()},10)},t.prototype.onTimer=function(){GAME_TIME-=.01,(GAME_TIME=(GAME_TIME=this.afterPointTwo(GAME_TIME)).toFixed(2))<10&&(GAME_TIME=\"0\"+GAME_TIME),engine.globalEvent.dispatchEvent(\"pictures-time-update\",{second:this.getSecond()}),0==this.getSecond()&&(this.stop(),engine.globalEvent.dispatchEvent(\"pictures-game-fail\",{reason:1}))},t.prototype.afterPointTwo=function(t){var e=parseFloat(t);if(!isNaN(e))return e=Math.round(100*e)/100},t.prototype.getSecond=function(){return GAME_TIME},t.prototype.stop=function(){GAME_TIME=props.GAME_TIME,clearInterval(this._timer)},t.prototype.createRects=function(){},t.prototype.setup=function(){MAX_COL=props.MAX_COL,MAX_ROW=props.MAX_ROW,GAME_TIME=props.GAME_TIME,W=props.W,H=props.H,GAP=props.GAP,w=W/MAX_COL,h=H/MAX_ROW,console.log(\"onSteup\",props);var t=new engine.Sprite;this.picturesWrapper=t,this.addChild(t)},t.prototype.onDown=function(t){this.dragPic=t.target,this.picturesWrapper.addChild(this.dragPic),this.localPicX=t.localX/MAX_COL,this.localPicY=t.localY/MAX_ROW,this.distanceX=this.dragPic.x,this.distanceY=this.dragPic.y,this.indexJ=Math.floor(this.distanceX/(w+GAP)),this.indexI=Math.floor(this.distanceY/(h+GAP)),this.index=this.indexI*MAX_COL+this.indexJ,this.centerX=Math.floor(t.clientX/w)*w+w/2,this.centerY=Math.floor(t.clientY/h)*h+h/2,this.stage.addEventListener(engine.MouseEvent.MOUSE_MOVE,this.onMove,this),this.stage.addEventListener(engine.MouseEvent.MOUSE_UP,this.stageOnUp,this)},t.prototype.stageOnUp=function(t){this.stage.removeEventListener(engine.MouseEvent.MOUSE_MOVE,this.onMove,this),this.stage.removeEventListener(engine.MouseEvent.MOUSE_UP,this.stageOnUp,this),(this.centerY<0||this.centerX<0)&&(this.dragPic.x=this.distanceX,this.dragPic.y=this.distanceY),this.picturesWrapper.addChild(this.guideHole);var e=Math.floor(this.centerX/(w+GAP)),i=Math.floor(this.centerY/(h+GAP));if(e<MAX_COL&&i<MAX_ROW){var s=getIndexFromRC(i,e,MAX_COL),n=this.pictures[s],r=n.x,o=n.y;n.x=this.distanceX,n.y=this.distanceY,this.dragPic.x=r,this.dragPic.y=o;var a=this.pictures.indexOf(n),p=this.pictures.indexOf(this.dragPic);this.pictures[a]=this.dragPic,this.pictures[p]=n,p===a&&(this.dragPic.x=this.distanceX,this.dragPic.y=this.distanceY);for(var c=!0,d=0;d<this.rightList.length;d++)if(this.rightList[d]!=this.pictures[d]){c=!1;break}c&&this.onSuccess()}else this.dragPic.x=this.distanceX,this.dragPic.y=this.distanceY},t.prototype.onSuccess=function(){console.log(\"拼图成功!\"),engine.globalEvent.dispatchEvent(\"pictures-game-success\",{time:this._timeCounter}),this.stop()},t.prototype.onMove=function(t){this.dragPic.x=t.stageX-this.localPicX-(750-props.W)/2,this.dragPic.y=t.stageY-this.localPicY-(this.stage.height-props.H)/2,console.log(\"fuck on this.stage.height\",this.stage.height),this.centerX=this.dragPic.x+w/2,this.centerY=this.dragPic.y+h/2},t}(engine.Container),GameWrapper=function(i){function t(){var t=i.call(this)||this;engine.globalEvent.addEventListener(\"pictures-start\",t.start,t),engine.globalEvent.addEventListener(\"pictures-stop\",t.stop,t);var e=t._gameView=new GameView;return t.addChild(e),t}return tslib.__extends(t,i),t.prototype.start=function(t){injectProps(t.data),this._gameView.start()},t.prototype.stop=function(t){this._gameView.stop()},t}(engine.Container);function index(t){return prepareProps(),injectProps(t),new GameWrapper}module.exports=index;\n" "code": "(function (global, factory) {\n\ttypeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('tslib')) :\n\ttypeof define === 'function' && define.amd ? define(['tslib'], factory) :\n\t(global = global || self, global.pictures = factory(global.tslib));\n}(this, (function (tslib) { 'use strict';\n\n\tvar props = {};\r\n\tfunction prepareProps() {\r\n\t var metaProps = getProps();\r\n\t engine.injectProp(props, metaProps);\r\n\t}\r\n\tfunction injectProps(p) {\r\n\t engine.injectProp(props, p);\r\n\t}\n\n\tvar picMap = {};\r\n\tvar posMap = {};\r\n\tvar qietu = (function (parent, url, MAX_COL, MAX_ROW) {\r\n\t if (picMap[url]) {\r\n\t var pics = picMap[url];\r\n\t for (var _i = 0, pics_1 = pics; _i < pics_1.length; _i++) {\r\n\t var pic = pics_1[_i];\r\n\t parent.addChild(pic);\r\n\t }\r\n\t return [picMap[url], posMap[url]];\r\n\t }\r\n\t var W = props.W;\r\n\t var H = props.H;\r\n\t var GAP = props.GAP;\r\n\t var spr = [];\r\n\t var pos = [];\r\n\t var _loop_1 = function (row) {\r\n\t var _loop_2 = function (col) {\r\n\t var child = engine.Sprite.fromImage(url);\r\n\t spr.push(child);\r\n\t child.scaleX = 1 / MAX_COL;\r\n\t child.scaleY = 1 / MAX_ROW;\r\n\t parent.addChild(child);\r\n\t child.x = col * (W / MAX_COL + GAP);\r\n\t child.y = row * (H / MAX_ROW + GAP);\r\n\t pos.push([child.x, child.y]);\r\n\t child.addEventListener(engine.Event.COMPLETE, function () {\r\n\t var uvs = new Float32Array([\r\n\t col / MAX_COL,\r\n\t row / MAX_ROW,\r\n\t (col + 1) / MAX_COL,\r\n\t row / MAX_ROW,\r\n\t (col + 1) / MAX_COL,\r\n\t (row + 1) / MAX_ROW,\r\n\t col / MAX_COL,\r\n\t (row + 1) / MAX_ROW,\r\n\t ]);\r\n\t child.uvs = uvs;\r\n\t });\r\n\t };\r\n\t for (var col = 0; col < MAX_COL; col++) {\r\n\t _loop_2(col);\r\n\t }\r\n\t };\r\n\t for (var row = 0; row < MAX_ROW; row++) {\r\n\t _loop_1(row);\r\n\t }\r\n\t picMap[url] = spr.concat([]);\r\n\t posMap[url] = pos.concat([]);\r\n\t return [spr, pos];\r\n\t});\n\n\tfunction getIndexFromRC(row, col, maxCol) {\r\n\t var index;\r\n\t index = row * maxCol + col;\r\n\t return index;\r\n\t}\r\n\tfunction getRandomArray(array) {\r\n\t array.sort(function () {\r\n\t return .5 - Math.random();\r\n\t });\r\n\t}\n\n\tvar MAX_COL;\r\n\tvar MAX_ROW;\r\n\tvar W;\r\n\tvar H;\r\n\tvar GAP;\r\n\tvar GAME_TIME;\r\n\tvar w;\r\n\tvar h;\r\n\tvar GameView = (function (_super) {\r\n\t tslib.__extends(GameView, _super);\r\n\t function GameView() {\r\n\t var _this = _super.call(this) || this;\r\n\t _this._timeCounter = 0;\r\n\t _this.listenStageOn = 1;\r\n\t _this.once(engine.Event.ADDED_TO_STAGE, _this.setup, _this);\r\n\t return _this;\r\n\t }\r\n\t GameView.prototype.start = function () {\r\n\t var _this = this;\r\n\t MAX_COL = props.column || props.MAX_COL;\r\n\t MAX_ROW = props.row || props.MAX_ROW;\r\n\t GAME_TIME = props.gameTime || props.GAME_TIME;\r\n\t console.log('start', props.column, props.row, props.gameTime);\r\n\t if (!this.guideHole) {\r\n\t this.guideHole = new engine.Image();\r\n\t this.guideHole.source = 'asset://' + props.blockUrl;\r\n\t this.guideHole.mouseChildren = this.guideHole.mouseEnabled = false;\r\n\t }\r\n\t if (this.pictures) {\r\n\t for (var _i = 0, _a = this.pictures; _i < _a.length; _i++) {\r\n\t var pic = _a[_i];\r\n\t if (pic && pic.wrapper)\r\n\t pic.wrapper.removeChild(pic);\r\n\t }\r\n\t }\r\n\t console.log('on start');\r\n\t engine.globalEvent.dispatchEvent('pictures-time-update', {\r\n\t second: this.getSecond(),\r\n\t });\r\n\t var result = qietu(this.picturesWrapper, props.picUrl, MAX_COL, MAX_ROW);\r\n\t this.picturesWrapper.addChild(this.guideHole);\r\n\t console.log(this.picturesWrapper);\r\n\t this.pictures = result[0];\r\n\t this.rightList = this.pictures.concat([]);\r\n\t var posList = result[1];\r\n\t getRandomArray(this.pictures);\r\n\t var i = 0;\r\n\t var len;\r\n\t len = this.pictures.length;\r\n\t for (; i < len; i++) {\r\n\t this.dragPic = this.pictures[i];\r\n\t this.pictures[i].addEventListener(engine.MouseEvent.MOUSE_DOWN, this.onDown, this);\r\n\t var _b = posList[i], x = _b[0], y = _b[1];\r\n\t this.dragPic.x = x;\r\n\t this.dragPic.y = y;\r\n\t }\r\n\t this._timer = setInterval(function () {\r\n\t _this.onTimer();\r\n\t }, 10);\r\n\t this.date = new Date().getTime();\r\n\t };\r\n\t GameView.prototype.onTimer = function () {\r\n\t var date = new Date().getTime();\r\n\t var gap = ((date - this.date) / 1000);\r\n\t this.date = date;\r\n\t console.log(gap, \"gap\");\r\n\t GAME_TIME -= gap;\r\n\t if (GAME_TIME < 0) {\r\n\t GAME_TIME = 0;\r\n\t }\r\n\t GAME_TIME = this.afterPointTwo(GAME_TIME);\r\n\t GAME_TIME = GAME_TIME.toFixed(2);\r\n\t if (GAME_TIME < 10) {\r\n\t GAME_TIME = '0' + GAME_TIME;\r\n\t }\r\n\t console.log(GAME_TIME);\r\n\t engine.globalEvent.dispatchEvent('pictures-time-update', {\r\n\t second: this.getSecond(),\r\n\t });\r\n\t if (this.getSecond() == 0) {\r\n\t this.stop();\r\n\t engine.globalEvent.dispatchEvent('pictures-game-fail', {\r\n\t reason: 1\r\n\t });\r\n\t }\r\n\t };\r\n\t GameView.prototype.afterPointTwo = function (n) {\r\n\t var floatN = parseFloat(n);\r\n\t if (isNaN(floatN)) {\r\n\t return;\r\n\t }\r\n\t floatN = Math.round(floatN * 100) / 100;\r\n\t return floatN;\r\n\t };\r\n\t GameView.prototype.getSecond = function () {\r\n\t return GAME_TIME;\r\n\t };\r\n\t GameView.prototype.stop = function () {\r\n\t GAME_TIME = props.GAME_TIME;\r\n\t clearInterval(this._timer);\r\n\t var len = this.pictures.length;\r\n\t for (var i = 0; i < len; i++) {\r\n\t this.pictures[i].removeAllEventListener();\r\n\t }\r\n\t this.stage.removeEventListener(engine.MouseEvent.MOUSE_UP, this.stageOnUp, this);\r\n\t };\r\n\t GameView.prototype.createRects = function () { };\r\n\t GameView.prototype.setup = function () {\r\n\t MAX_COL = props.MAX_COL;\r\n\t MAX_ROW = props.MAX_ROW;\r\n\t GAME_TIME = props.GAME_TIME;\r\n\t W = props.W;\r\n\t H = props.H;\r\n\t GAP = props.GAP;\r\n\t w = W / MAX_COL;\r\n\t h = H / MAX_ROW;\r\n\t console.log('onSteup', props);\r\n\t var parent = new engine.Sprite();\r\n\t this.picturesWrapper = parent;\r\n\t this.addChild(parent);\r\n\t };\r\n\t GameView.prototype.onDown = function (e) {\r\n\t var stageLeft = (750 - props.W) / 2;\r\n\t var stageTop = (this.stage.height - props.H) / 2;\r\n\t this.dragPic = e.target;\r\n\t this.picturesWrapper.addChild(this.dragPic);\r\n\t this.localPicX = e.localX / MAX_COL;\r\n\t this.localPicY = e.localY / MAX_ROW;\r\n\t this.distanceX = this.dragPic.x;\r\n\t this.distanceY = this.dragPic.y;\r\n\t this.indexJ = Math.floor((this.distanceX) / (w + GAP));\r\n\t this.indexI = Math.floor((this.distanceY) / (h + GAP));\r\n\t this.index = (this.indexI) * MAX_COL + this.indexJ;\r\n\t this.centerX = Math.floor((e.clientX - stageLeft) / w) * w + w / 2;\r\n\t this.centerY = Math.floor((e.clientY - stageTop) / h) * h + h / 2;\r\n\t this.stage.addEventListener(engine.MouseEvent.MOUSE_MOVE, this.onMove, this);\r\n\t this.stage.addEventListener(engine.MouseEvent.MOUSE_UP, this.stageOnUp, this);\r\n\t };\r\n\t GameView.prototype.stageOnUp = function (e) {\r\n\t var stageLeft = (750 - props.W) / 2;\r\n\t var stageTop = (this.stage.height - props.H) / 2;\r\n\t this.stage.removeEventListener(engine.MouseEvent.MOUSE_MOVE, this.onMove, this);\r\n\t this.stage.removeEventListener(engine.MouseEvent.MOUSE_UP, this.stageOnUp, this);\r\n\t if (this.centerY < stageTop || this.centerX < stageLeft) {\r\n\t this.dragPic.x = this.distanceX;\r\n\t this.dragPic.y = this.distanceY;\r\n\t }\r\n\t var curJ = Math.floor(this.centerX / (w + GAP));\r\n\t var curI = Math.floor(this.centerY / (h + GAP));\r\n\t this.picturesWrapper.addChild(this.guideHole);\r\n\t if (0 <= curJ && curJ < (MAX_COL) && 0 <= curI && curI < (MAX_ROW)) {\r\n\t var index = getIndexFromRC(curI, curJ, MAX_COL);\r\n\t var dropPic = this.pictures[index];\r\n\t var dropPicX = dropPic.x + stageLeft;\r\n\t var dropPicy = dropPic.y + stageTop;\r\n\t dropPic.x = this.distanceX;\r\n\t dropPic.y = this.distanceY;\r\n\t this.dragPic.x = dropPicX - stageLeft;\r\n\t this.dragPic.y = dropPicy - stageTop;\r\n\t var dropPicIndex = this.pictures.indexOf(dropPic);\r\n\t var dragPicIndex = this.pictures.indexOf(this.dragPic);\r\n\t this.pictures[dropPicIndex] = this.dragPic;\r\n\t this.pictures[dragPicIndex] = dropPic;\r\n\t if (dragPicIndex === dropPicIndex) {\r\n\t this.dragPic.x = this.distanceX;\r\n\t this.dragPic.y = this.distanceY;\r\n\t }\r\n\t var result = true;\r\n\t for (var j = 0; j < this.rightList.length; j++) {\r\n\t if (this.rightList[j] != this.pictures[j]) {\r\n\t result = false;\r\n\t break;\r\n\t }\r\n\t }\r\n\t if (result) {\r\n\t this.onSuccess();\r\n\t }\r\n\t }\r\n\t else {\r\n\t this.dragPic.x = this.distanceX;\r\n\t this.dragPic.y = this.distanceY;\r\n\t }\r\n\t };\r\n\t GameView.prototype.onSuccess = function () {\r\n\t console.log('拼图成功!');\r\n\t engine.globalEvent.dispatchEvent('pictures-game-success', { time: GAME_TIME });\r\n\t this.stop();\r\n\t };\r\n\t GameView.prototype.onMove = function (e) {\r\n\t this.dragPic.x = e.stageX - this.localPicX - (750 - props.W) / 2;\r\n\t this.dragPic.y = e.stageY - this.localPicY - (this.stage.height - props.H) / 2;\r\n\t this.centerX = this.dragPic.x + w / 2;\r\n\t this.centerY = this.dragPic.y + h / 2;\r\n\t };\r\n\t return GameView;\r\n\t}(engine.Container));\n\n\tvar GameWrapper = (function (_super) {\r\n\t tslib.__extends(GameWrapper, _super);\r\n\t function GameWrapper() {\r\n\t var _this = _super.call(this) || this;\r\n\t engine.globalEvent.addEventListener('pictures-start', _this.start, _this);\r\n\t engine.globalEvent.addEventListener('pictures-stop', _this.stop, _this);\r\n\t var gameView = _this._gameView = new GameView();\r\n\t _this.addChild(gameView);\r\n\t return _this;\r\n\t }\r\n\t GameWrapper.prototype.start = function (event) {\r\n\t injectProps(event.data);\r\n\t this._gameView.start();\r\n\t };\r\n\t GameWrapper.prototype.stop = function (event) {\r\n\t this._gameView.stop();\r\n\t };\r\n\t return GameWrapper;\r\n\t}(engine.Container));\n\n\tfunction index (props) {\r\n\t prepareProps();\r\n\t injectProps(props);\r\n\t var instance = new GameWrapper();\r\n\t return instance;\r\n\t}\n\n\treturn index;\n\n})));\n"
} }
{
"name": "拼图",
"desc": "拼图模块1.0",
"props": {
"MAX_COL": {
"alias": "图片分成几列",
"type": "number",
"default": 3
},
"MAX_ROW": {
"alias": "图片分成几行",
"type": "number",
"default": 4
},
"W": {
"alias": "图片的宽度",
"type": "number",
"default": 618
},
"H": {
"alias": "图片的高度",
"type": "number",
"default": 827
},
"OFFSET_X": {
"alias": "OFFSET_X",
"type": "number",
"default": 0
},
"OFFSET_Y": {
"alias": "OFFSET_Y",
"type": "number",
"default": 0
},
"GAME_TIME": {
"alias": "游戏时间",
"type": "number",
"default": 30
},
"GAP": {
"alias": "图片间隙",
"type": "number",
"default": 0
}
},
"assets": [
{
"name": "遮罩",
"url": "//yun.duiba.com.cn/aurora/assets/5b3e30496b2d9fdafb0cf3835fd6704ce10e45b4.png",
"uuid": "888",
"ext": ".png"
},
{
"name": "背景",
"url": " //yun.duiba.com.cn/aurora/assets/57725dcf8cb23905afb87f42d7aba2ffa4c8d2d1.png",
"uuid": "308742a0-0ea2-4610-b34a-a230add82021",
"ext": ".png"
},
{
"name": "飞机",
"url": "//yun.duiba.com.cn/aurora/assets/1d2ba15cb8baf3e5783a9f865673dcf9a2421f19.png",
"uuid": "32ec481a-3f75-4c36-95ed-ee97aa936517",
"ext": ".png"
},
{
"name": "开始按钮",
"url": "//yun.duiba.com.cn/aurora/assets/2bed3a9e3cae15a6332397ca675c5d44849eaac2.png",
"uuid": "855e3d77-ffff-443d-b884-4f67a2ebe458",
"ext": ".png"
},
{
"name": "游戏背景",
"url": "//yun.duiba.com.cn/aurora/assets/5f56d60285f0e3b253716bc938a3c28cbb288cdf.png",
"uuid": "76820072-df5a-4ab7-8cb7-10c8cd8605c8",
"ext": ".png"
},
{
"name": "子弹",
"url": "//yun.duiba.com.cn/aurora/assets/06b3baba53973c01be8943b7a002e58de3bea7cf.png",
"uuid": "18852543-1f1d-498b-af64-88cd3b343758",
"ext": ".png"
},
{
"name": "敌机",
"url": "//yun.duiba.com.cn/aurora/assets/fc3b2a4349b098183b2b20c8a754b8b182d73806.png",
"uuid": "780b6b63-3abd-4246-94ba-2a3fbdb3c5af",
"ext": ".png"
},
{
"name": "small敌机",
"url": "//yun.duiba.com.cn/aurora/assets/1cded0d917c44d22ddce058f239e1cfac1b506c2.png",
"uuid": "57d4067e-c32f-4b12-a8fc-185753726fc6",
"ext": ".png"
},
{
"name": "击中",
"url": "//yun.duiba.com.cn/aurora/assets/251402a1991ef00a124ddd91f519a30147285e00.png",
"uuid": "38ec6627-efa8-4f7a-9bdc-3c73cea717f1",
"ext": ".png"
}
],
"events": {
"in": {
"pictures-start": {
"alias": "开始",
"data": {
"picUrl": "图片路径",
"blockUrl": "blockUrl",
"GAME_TIME": "每局的游戏时间",
"MAX_ROW": "行",
"MAX_COL": "列",
"W": "宽",
"H": "高",
"GAP": "图片间隙",
"OFFSET_X": "OFFSET_X",
"OFFSET_Y": "OFFSET_Y"
}
},
"pictures-stop": {
"alias": "停止"
}
},
"out": {
"pictures-time-update": {
"alias": "倒计时更新",
"data": {
"time": "剩余时间"
}
},
"pictures-game-fail": {
"alias": "游戏结束",
"data": {
"reason": "结束原因(1:时间到了)"
}
},
"pictures-game-success": {
"alias": "游戏成功",
"data": {
"time": "游戏消耗时间"
}
}
}
},
"id": "playWithPlane",
"code": "(function (global, factory) {\n\ttypeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('tslib')) :\n\ttypeof define === 'function' && define.amd ? define(['tslib'], factory) :\n\t(global = global || self, global.playWithPlane = factory(global.tslib));\n}(this, (function (tslib) { 'use strict';\n\n\tvar props = {};\r\n\tfunction prepareProps() {\r\n\t var metaProps = getProps();\r\n\t engine.injectProp(props, metaProps);\r\n\t}\r\n\tfunction injectProps(p) {\r\n\t engine.injectProp(props, p);\r\n\t}\r\n\t//# sourceMappingURL=props.js.map\n\n\tfunction getTexture(uuid) {\r\n\t return engine.Texture.from(getAssetByUUID(uuid).uuid);\r\n\t}\r\n\t//# sourceMappingURL=utils.js.map\n\n\tvar Ball = (function (_super) {\r\n\t tslib.__extends(Ball, _super);\r\n\t function Ball() {\r\n\t var _this = _super.call(this) || this;\r\n\t _this.plane = new engine.Sprite();\r\n\t _this.addChild(_this.plane);\r\n\t return _this;\r\n\t }\r\n\t Ball.prototype.setPosition = function () { };\r\n\t Ball.prototype.died = function () { };\r\n\t return Ball;\r\n\t}(engine.Container));\r\n\t//# sourceMappingURL=Ball.js.map\n\n\tvar SmallPlane = (function (_super) {\r\n\t tslib.__extends(SmallPlane, _super);\r\n\t function SmallPlane() {\r\n\t var _this = _super.call(this) || this;\r\n\t _this._life = 3;\r\n\t _this.smallPlane = new engine.Sprite(getTexture('57d4067e-c32f-4b12-a8fc-185753726fc6'));\r\n\t _this.life = 3;\r\n\t _this.name = \"smallBall\";\r\n\t _this.addChild(_this.smallPlane);\r\n\t return _this;\r\n\t }\r\n\t SmallPlane.prototype.setPosition = function () {\r\n\t this.x = Math.random() * (750 - this.width);\r\n\t this.y = Math.random() * (this.height);\r\n\t };\r\n\t SmallPlane.prototype.died = function () {\r\n\t };\r\n\t return SmallPlane;\r\n\t}(Ball));\r\n\t//# sourceMappingURL=SmallBall.js.map\n\n\tvar Bullets = (function (_super) {\r\n\t tslib.__extends(Bullets, _super);\r\n\t function Bullets(_harm) {\r\n\t if (_harm === void 0) { _harm = 1; }\r\n\t var _this = _super.call(this) || this;\r\n\t _this.bulletPic = new engine.Sprite(getTexture('18852543-1f1d-498b-af64-88cd3b343758'));\r\n\t _this.bullets = [];\r\n\t _this.harm = _harm;\r\n\t _this.addChild(_this.bulletPic);\r\n\t return _this;\r\n\t }\r\n\t Bullets.prototype.addBullet = function (planeModel) {\r\n\t var bullet = new engine.Sprite(getTexture('18852543-1f1d-498b-af64-88cd3b343758'));\r\n\t bullet.x = planeModel ? planeModel.x + planeModel.width / 2 - bullet.width / 2 : 375 - bullet.width / 2;\r\n\t bullet.y = 1150;\r\n\t return bullet;\r\n\t };\r\n\t Bullets.prototype.createBullet = function (planeModel) {\r\n\t this.x = planeModel.x + planeModel.width / 2 - this.bulletPic.width / 2;\r\n\t this.y = 1150;\r\n\t };\r\n\t Bullets.prototype.addBulletNum = function (w) {\r\n\t };\r\n\t return Bullets;\r\n\t}(engine.Container));\r\n\t//# sourceMappingURL=Bullets.js.map\n\n\tvar TestView = (function (_super) {\r\n\t tslib.__extends(TestView, _super);\r\n\t function TestView() {\r\n\t var _this = _super.call(this) || this;\r\n\t _this.planeArray = [\r\n\t {\r\n\t type: 'smallBall',\r\n\t enemyPlane: []\r\n\t },\r\n\t {\r\n\t type: 'middleBall',\r\n\t enemyPlane: []\r\n\t },\r\n\t {\r\n\t type: 'largeBall',\r\n\t enemyPlane: []\r\n\t }\r\n\t ];\r\n\t _this.bulletArray = [];\r\n\t _this.score = 0;\r\n\t _this.once(engine.Event.ADDED_TO_STAGE, _this.setup, _this);\r\n\t return _this;\r\n\t }\r\n\t TestView.prototype.setup = function () {\r\n\t this.stageBg = new engine.Sprite(getTexture('308742a0-0ea2-4610-b34a-a230add82021'));\r\n\t this.addChild(this.stageBg);\r\n\t this.gameBg = new engine.Sprite(getTexture('76820072-df5a-4ab7-8cb7-10c8cd8605c8'));\r\n\t this.startBtn = new engine.Sprite(getTexture('855e3d77-ffff-443d-b884-4f67a2ebe458'));\r\n\t this.startBtn.x = (750 - this.startBtn.width) / 2;\r\n\t this.startBtn.y = (this.stage.height - this.startBtn.height) / 2 + 300;\r\n\t this.stageBg.addChild(this.startBtn);\r\n\t this.startBtn.addEventListener(engine.MouseEvent.CLICK, this.onClick, this);\r\n\t };\r\n\t TestView.prototype.start = function () {\r\n\t var _this = this;\r\n\t this.planeModel = new engine.Sprite(getTexture('32ec481a-3f75-4c36-95ed-ee97aa936517'));\r\n\t this.planeModel.x = (750 - this.planeModel.width) / 2;\r\n\t this.planeModel.y = (this.stage.height - this.planeModel.height);\r\n\t this.planeModel.addEventListener(engine.MouseEvent.MOUSE_DOWN, this.onDown, this);\r\n\t this.gameBg.addChild(this.planeModel);\r\n\t var boom = new engine.Sprite(getTexture('38ec6627-efa8-4f7a-9bdc-3c73cea717f1'));\r\n\t setInterval(function () {\r\n\t var smallBall = new SmallPlane();\r\n\t smallBall.setPosition();\r\n\t console.log(_this.planeArray);\r\n\t for (var _i = 0, _a = _this.planeArray; _i < _a.length; _i++) {\r\n\t var planearray = _a[_i];\r\n\t if (planearray.type == smallBall.name) {\r\n\t console.log(planearray.enemyPlane);\r\n\t planearray.enemyPlane.push(smallBall);\r\n\t }\r\n\t }\r\n\t _this.gameBg.addChild(smallBall);\r\n\t }, 500);\r\n\t setInterval(function () {\r\n\t for (var _i = 0, _a = _this.planeArray; _i < _a.length; _i++) {\r\n\t var planearray = _a[_i];\r\n\t if (planearray.type === 'smallBall') {\r\n\t var _loop_1 = function (sball) {\r\n\t console.log(sball);\r\n\t sball.y += 1;\r\n\t if (sball.y > _this.stage.height) {\r\n\t _this.gameBg.removeChild(sball);\r\n\t var index_1 = planearray.enemyPlane.indexOf(sball);\r\n\t planearray.enemyPlane = planearray.enemyPlane.filter(function (ele, i) { return i != index_1; });\r\n\t }\r\n\t };\r\n\t for (var _b = 0, _c = planearray.enemyPlane; _b < _c.length; _b++) {\r\n\t var sball = _c[_b];\r\n\t _loop_1(sball);\r\n\t }\r\n\t }\r\n\t }\r\n\t }, 16);\r\n\t setInterval(function () {\r\n\t var bullet = new Bullets();\r\n\t bullet.createBullet(_this.planeModel);\r\n\t _this.bulletArray.push(bullet);\r\n\t _this.gameBg.addChild(bullet);\r\n\t }, 40);\r\n\t setInterval(function () {\r\n\t console.log(_this.score);\r\n\t var _loop_2 = function (bullet) {\r\n\t bullet.y -= 35;\r\n\t if (bullet.y < -40) {\r\n\t _this.gameBg.removeChild(bullet);\r\n\t var index_2 = _this.bulletArray.indexOf(bullet);\r\n\t _this.bulletArray = _this.bulletArray.filter(function (ele, i) { return i != index_2; });\r\n\t }\r\n\t for (var _i = 0, _a = _this.planeArray; _i < _a.length; _i++) {\r\n\t var planearray = _a[_i];\r\n\t if (planearray.type === 'smallBall') {\r\n\t var _loop_3 = function (splane) {\r\n\t var y = bullet.y - splane.y;\r\n\t var bulletRight = bullet.x + bullet.width;\r\n\t var planeRange = splane.x + splane.width;\r\n\t if (bulletRight > splane.x && bulletRight < planeRange || bullet.x > splane.x && bullet.x < planeRange) {\r\n\t if (y <= 0) {\r\n\t splane.life -= bullet.harm;\r\n\t _this.score += bullet.harm;\r\n\t _this.gameBg.removeChild(bullet);\r\n\t var index_3 = _this.bulletArray.indexOf(bullet);\r\n\t _this.bulletArray = _this.bulletArray.filter(function (ele, i) { return i != index_3; });\r\n\t if (splane.life === 0) {\r\n\t _this.gameBg.removeChild(splane);\r\n\t var ind_1 = planearray.enemyPlane.indexOf(splane);\r\n\t planearray.enemyPlane = planearray.enemyPlane.filter(function (ele, i) { return i != ind_1; });\r\n\t boom.x = splane.x;\r\n\t boom.y = splane.y;\r\n\t _this.gameBg.addChild(boom);\r\n\t setTimeout(function () {\r\n\t _this.gameBg.removeChild(boom);\r\n\t }, 1500);\r\n\t }\r\n\t }\r\n\t }\r\n\t };\r\n\t for (var _b = 0, _c = planearray.enemyPlane; _b < _c.length; _b++) {\r\n\t var splane = _c[_b];\r\n\t _loop_3(splane);\r\n\t }\r\n\t }\r\n\t }\r\n\t };\r\n\t for (var _i = 0, _a = _this.bulletArray; _i < _a.length; _i++) {\r\n\t var bullet = _a[_i];\r\n\t _loop_2(bullet);\r\n\t }\r\n\t }, 16);\r\n\t };\r\n\t TestView.prototype.onClick = function () {\r\n\t this.addChild(this.gameBg);\r\n\t this.gameBg.addChild(this.planeModel);\r\n\t };\r\n\t TestView.prototype.onDown = function (e) {\r\n\t this.mouseX = e.localX;\r\n\t this.mouseY = e.localY;\r\n\t this.stage.addEventListener(engine.MouseEvent.MOUSE_MOVE, this.onMove, this);\r\n\t this.planeModel.x = e.stageX - this.mouseX;\r\n\t this.planeCenterX = this.planeModel.x + this.planeModel.width / 2;\r\n\t };\r\n\t TestView.prototype.onMove = function (e) {\r\n\t this.centerX = this.planeModel.width / 2;\r\n\t var movedCenter = this.centerX + e.stageX - this.mouseX;\r\n\t if (movedCenter < 0) {\r\n\t this.planeModel.x = -this.centerX;\r\n\t }\r\n\t else if (movedCenter > 750) {\r\n\t this.planeModel.x = 750 - this.centerX;\r\n\t }\r\n\t else {\r\n\t this.planeModel.x = e.stageX - this.mouseX;\r\n\t this.planeCenterX = this.planeModel.x + this.planeModel.width / 2;\r\n\t }\r\n\t };\r\n\t TestView.prototype.stop = function () {\r\n\t };\r\n\t return TestView;\r\n\t}(engine.Container));\n\n\tvar GameWrapper = (function (_super) {\r\n\t tslib.__extends(GameWrapper, _super);\r\n\t function GameWrapper() {\r\n\t var _this = _super.call(this) || this;\r\n\t engine.globalEvent.addEventListener('pictures-start', _this.start, _this);\r\n\t engine.globalEvent.addEventListener('pictures-stop', _this.stop, _this);\r\n\t var testView = _this._testView = new TestView();\r\n\t _this.addChild(testView);\r\n\t return _this;\r\n\t }\r\n\t GameWrapper.prototype.start = function (event) {\r\n\t injectProps(event.data);\r\n\t this._testView.start();\r\n\t };\r\n\t GameWrapper.prototype.stop = function (event) {\r\n\t this._testView.stop();\r\n\t };\r\n\t return GameWrapper;\r\n\t}(engine.Container));\r\n\t//# sourceMappingURL=GameWrapper.js.map\n\n\tfunction index (props) {\r\n\t prepareProps();\r\n\t injectProps(props);\r\n\t var instance = new GameWrapper();\r\n\t return instance;\r\n\t}\r\n\t//# sourceMappingURL=index.js.map\n\n\treturn index;\n\n})));\n"
}
{
"name": "拼图",
"desc": "拼图模块1.0",
"props": {
"MAX_COL": {
"alias": "图片分成几列",
"type": "number",
"default": 3
},
"MAX_ROW": {
"alias": "图片分成几行",
"type": "number",
"default": 4
},
"W": {
"alias": "图片的宽度",
"type": "number",
"default": 618
},
"H": {
"alias": "图片的高度",
"type": "number",
"default": 827
},
"OFFSET_X": {
"alias": "OFFSET_X",
"type": "number",
"default": 0
},
"OFFSET_Y": {
"alias": "OFFSET_Y",
"type": "number",
"default": 0
},
"GAME_TIME": {
"alias": "游戏时间",
"type": "number",
"default": 30
},
"GAP": {
"alias": "图片间隙",
"type": "number",
"default": 0
}
},
"assets": [
{
"name": "遮罩",
"url": "//yun.duiba.com.cn/aurora/assets/5b3e30496b2d9fdafb0cf3835fd6704ce10e45b4.png",
"uuid": "888",
"ext": ".png"
}
],
"events": {
"in": {
"pictures-start": {
"alias": "开始",
"data": {
"picUrl": "图片路径",
"blockUrl": "blockUrl",
"GAME_TIME": "每局的游戏时间",
"MAX_ROW": "行",
"MAX_COL": "列",
"W": "宽",
"H": "高",
"GAP": "图片间隙",
"OFFSET_X": "OFFSET_X",
"OFFSET_Y": "OFFSET_Y"
}
},
"pictures-stop": {
"alias": "停止"
}
},
"out": {
"pictures-time-update": {
"alias": "倒计时更新",
"data": {
"time": "剩余时间"
}
},
"pictures-game-fail": {
"alias": "游戏结束",
"data": {
"reason": "结束原因(1:时间到了)"
}
},
"pictures-game-success": {
"alias": "游戏成功",
"data": {
"time": "游戏消耗时间"
}
}
}
},
"id": "rounds-pic",
"code": "(function (global, factory) {\n\ttypeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('tslib')) :\n\ttypeof define === 'function' && define.amd ? define(['tslib'], factory) :\n\t(global = global || self, global['rounds-pic'] = factory(global.tslib));\n}(this, (function (tslib) { 'use strict';\n\n\tvar props = {};\r\n\tfunction prepareProps() {\r\n\t var metaProps = getProps();\r\n\t engine.injectProp(props, metaProps);\r\n\t}\r\n\tfunction injectProps(p) {\r\n\t engine.injectProp(props, p);\r\n\t}\r\n\t//# sourceMappingURL=props.js.map\n\n\tvar qietu = (function (parent, url, MAX_COL, MAX_ROW) {\r\n\t var W = props.W;\r\n\t var H = props.H;\r\n\t var GAP = props.GAP;\r\n\t var spr = [];\r\n\t var pos = [];\r\n\t var _loop_1 = function (row) {\r\n\t var _loop_2 = function (col) {\r\n\t var child = new engine.Sprite();\r\n\t child.scaleX = 1 / MAX_COL;\r\n\t child.scaleY = 1 / MAX_ROW;\r\n\t parent.addChild(child);\r\n\t child.x = col * (W / MAX_COL + GAP);\r\n\t child.y = row * (H / MAX_ROW + GAP);\r\n\t pos.push([child.x, child.y]);\r\n\t spr.push(child);\r\n\t child.addEventListener(engine.Event.COMPLETE, function () {\r\n\t var uvs = new Float32Array([\r\n\t col / MAX_COL,\r\n\t row / MAX_ROW,\r\n\t (col + 1) / MAX_COL,\r\n\t row / MAX_ROW,\r\n\t (col + 1) / MAX_COL,\r\n\t (row + 1) / MAX_ROW,\r\n\t col / MAX_COL,\r\n\t (row + 1) / MAX_ROW,\r\n\t ]);\r\n\t child.uvs = uvs;\r\n\t });\r\n\t child.texture = engine.Texture.fromImage(url);\r\n\t };\r\n\t for (var col = 0; col < MAX_COL; col++) {\r\n\t _loop_2(col);\r\n\t }\r\n\t };\r\n\t for (var row = 0; row < MAX_ROW; row++) {\r\n\t _loop_1(row);\r\n\t }\r\n\t console.log(spr);\r\n\t return [spr, pos];\r\n\t});\r\n\t//# sourceMappingURL=qietu.js.map\n\n\tfunction getIndexFromRC(row, col, maxCol) {\r\n\t var index;\r\n\t index = row * maxCol + col;\r\n\t return index;\r\n\t}\r\n\tfunction getRandomArray(array) {\r\n\t array.sort(function () {\r\n\t return 0.5 - Math.random();\r\n\t });\r\n\t}\n\n\tvar MAX_COL;\r\n\tvar MAX_ROW;\r\n\tvar W;\r\n\tvar H;\r\n\tvar GAP;\r\n\tvar GAME_TIME;\r\n\tvar w;\r\n\tvar h;\r\n\tvar picUrl;\r\n\tvar GameView = (function (_super) {\r\n\t tslib.__extends(GameView, _super);\r\n\t function GameView() {\r\n\t var _this = _super.call(this) || this;\r\n\t _this._timeCounter = 0;\r\n\t _this._result = [];\r\n\t _this.listenStageOn = 1;\r\n\t _this.once(engine.Event.ADDED_TO_STAGE, _this.setup, _this);\r\n\t return _this;\r\n\t }\r\n\t GameView.prototype.start = function () {\r\n\t var _this = this;\r\n\t picUrl = props.picUrl;\r\n\t MAX_COL = props.MAX_COL;\r\n\t MAX_ROW = props.MAX_ROW;\r\n\t GAME_TIME = props.GAME_TIME;\r\n\t W = props.W;\r\n\t H = props.H;\r\n\t GAP = props.GAP;\r\n\t w = W / MAX_COL;\r\n\t h = H / MAX_ROW;\r\n\t console.log('on start');\r\n\t engine.globalEvent.dispatchEvent('pictures-time-update', {\r\n\t second: this.getSecond(),\r\n\t });\r\n\t if (this._result.length !== 0) {\r\n\t this._result = [];\r\n\t }\r\n\t this._result = qietu(this.picturesWrapper, picUrl, MAX_COL, MAX_ROW);\r\n\t this.pictures = this._result[0];\r\n\t if (this.rightList !== null) {\r\n\t this.rightList = [];\r\n\t }\r\n\t this.rightList = this.pictures.concat([]);\r\n\t var posList = this._result[1];\r\n\t getRandomArray(this.pictures);\r\n\t var i = 0;\r\n\t var len;\r\n\t len = this.pictures.length;\r\n\t for (; i < len; i++) {\r\n\t this.dragPic = this.pictures[i];\r\n\t this.pictures[i].addEventListener(engine.MouseEvent.MOUSE_DOWN, this.onDown, this);\r\n\t var _a = posList[i], x = _a[0], y = _a[1];\r\n\t this.dragPic.x = x;\r\n\t this.dragPic.y = y;\r\n\t }\r\n\t this._timer = setInterval(function () {\r\n\t _this.onTimer();\r\n\t }, 10);\r\n\t this.date = new Date().getTime();\r\n\t };\r\n\t GameView.prototype.onTimer = function () {\r\n\t var date = new Date().getTime();\r\n\t var gap = ((date - this.date) / 1000);\r\n\t this.date = date;\r\n\t GAME_TIME -= gap;\r\n\t if (GAME_TIME < 0) {\r\n\t GAME_TIME = 0;\r\n\t }\r\n\t GAME_TIME = this.afterPointTwo(GAME_TIME);\r\n\t GAME_TIME = GAME_TIME.toFixed(2);\r\n\t if (GAME_TIME < 10) {\r\n\t GAME_TIME = '0' + GAME_TIME;\r\n\t }\r\n\t engine.globalEvent.dispatchEvent('pictures-time-update', {\r\n\t second: this.getSecond(),\r\n\t });\r\n\t if (this.getSecond() == 0) {\r\n\t this.stop();\r\n\t engine.globalEvent.dispatchEvent('pictures-game-fail', {\r\n\t reason: 1\r\n\t });\r\n\t this.stage.removeEventListener(engine.MouseEvent.MOUSE_UP, this.stageOnUp, this);\r\n\t }\r\n\t };\r\n\t GameView.prototype.afterPointTwo = function (n) {\r\n\t var floatN = parseFloat(n);\r\n\t if (isNaN(floatN)) {\r\n\t return;\r\n\t }\r\n\t floatN = Math.round(floatN * 100) / 100;\r\n\t return floatN;\r\n\t };\r\n\t GameView.prototype.getSecond = function () {\r\n\t return GAME_TIME;\r\n\t };\r\n\t GameView.prototype.stop = function () {\r\n\t GAME_TIME = props.GAME_TIME;\r\n\t clearInterval(this._timer);\r\n\t var len = this.pictures.length;\r\n\t for (var i = 0; i < len; i++) {\r\n\t this.pictures[i].removeAllEventListener();\r\n\t }\r\n\t };\r\n\t GameView.prototype.createRects = function () { };\r\n\t GameView.prototype.setup = function () {\r\n\t console.log('onSteup', props);\r\n\t var parent = new engine.Sprite();\r\n\t this.picturesWrapper = parent;\r\n\t this.addChild(parent);\r\n\t };\r\n\t GameView.prototype.onDown = function (e) {\r\n\t var stageLeft = (750 - props.W) / 2;\r\n\t var stageTop = (this.stage.height - props.H) / 2;\r\n\t this.dragPic = e.target;\r\n\t this.picturesWrapper.addChild(this.dragPic);\r\n\t this.localPicX = e.localX / MAX_COL;\r\n\t this.localPicY = e.localY / MAX_ROW;\r\n\t this.distanceX = this.dragPic.x;\r\n\t this.distanceY = this.dragPic.y;\r\n\t this.indexJ = Math.floor((this.distanceX) / (w + GAP));\r\n\t this.indexI = Math.floor((this.distanceY) / (h + GAP));\r\n\t this.index = (this.indexI) * MAX_COL + this.indexJ;\r\n\t this.centerX = Math.floor((e.clientX - stageLeft) / w) * w + w / 2;\r\n\t this.centerY = Math.floor((e.clientY - stageTop) / h) * h + h / 2;\r\n\t this.stage.addEventListener(engine.MouseEvent.MOUSE_MOVE, this.onMove, this);\r\n\t this.stage.addEventListener(engine.MouseEvent.MOUSE_UP, this.stageOnUp, this);\r\n\t };\r\n\t GameView.prototype.stageOnUp = function (e) {\r\n\t var stageLeft = (750 - props.W) / 2;\r\n\t var stageTop = (this.stage.height - props.H) / 2;\r\n\t this.stage.removeEventListener(engine.MouseEvent.MOUSE_MOVE, this.onMove, this);\r\n\t this.stage.removeEventListener(engine.MouseEvent.MOUSE_UP, this.stageOnUp, this);\r\n\t if (this.centerY < stageTop || this.centerX < stageLeft) {\r\n\t this.dragPic.x = this.distanceX;\r\n\t this.dragPic.y = this.distanceY;\r\n\t }\r\n\t var curJ = Math.floor(this.centerX / (w + GAP));\r\n\t var curI = Math.floor(this.centerY / (h + GAP));\r\n\t if (0 <= curJ && curJ < (MAX_COL) && 0 <= curI && curI < (MAX_ROW)) {\r\n\t var index = getIndexFromRC(curI, curJ, MAX_COL);\r\n\t var dropPic = this.pictures[index];\r\n\t var dropPicX = dropPic.x + stageLeft;\r\n\t var dropPicy = dropPic.y + stageTop;\r\n\t dropPic.x = this.distanceX;\r\n\t dropPic.y = this.distanceY;\r\n\t this.dragPic.x = dropPicX - stageLeft;\r\n\t this.dragPic.y = dropPicy - stageTop;\r\n\t var dropPicIndex = this.pictures.indexOf(dropPic);\r\n\t var dragPicIndex = this.pictures.indexOf(this.dragPic);\r\n\t this.pictures[dropPicIndex] = this.dragPic;\r\n\t this.pictures[dragPicIndex] = dropPic;\r\n\t if (dragPicIndex === dropPicIndex) {\r\n\t this.dragPic.x = this.distanceX;\r\n\t this.dragPic.y = this.distanceY;\r\n\t }\r\n\t var result = true;\r\n\t for (var j = 0; j < this.rightList.length; j++) {\r\n\t if (this.rightList[j] != this.pictures[j]) {\r\n\t result = false;\r\n\t break;\r\n\t }\r\n\t }\r\n\t if (result) {\r\n\t this.onSuccess();\r\n\t }\r\n\t }\r\n\t else {\r\n\t this.dragPic.x = this.distanceX;\r\n\t this.dragPic.y = this.distanceY;\r\n\t }\r\n\t };\r\n\t GameView.prototype.onSuccess = function () {\r\n\t console.log('拼图成功!');\r\n\t engine.globalEvent.dispatchEvent('pictures-game-success', { time: GAME_TIME });\r\n\t this.stop();\r\n\t props.GAME_TIME *= 0.9;\r\n\t ++props.MAX_ROW;\r\n\t ++props.MAX_COL;\r\n\t };\r\n\t GameView.prototype.onMove = function (e) {\r\n\t this.dragPic.x = e.stageX - this.localPicX - (750 - props.W) / 2;\r\n\t this.dragPic.y = e.stageY - this.localPicY - (this.stage.height - props.H) / 2;\r\n\t this.centerX = this.dragPic.x + w / 2;\r\n\t this.centerY = this.dragPic.y + h / 2;\r\n\t };\r\n\t return GameView;\r\n\t}(engine.Container));\r\n\t//# sourceMappingURL=GameView.js.map\n\n\tvar GameWrapper = (function (_super) {\r\n\t tslib.__extends(GameWrapper, _super);\r\n\t function GameWrapper() {\r\n\t var _this = _super.call(this) || this;\r\n\t engine.globalEvent.addEventListener('pictures-start', _this.start, _this);\r\n\t engine.globalEvent.addEventListener('pictures-stop', _this.stop, _this);\r\n\t var gameView = _this._gameView = new GameView();\r\n\t _this.addChild(gameView);\r\n\t return _this;\r\n\t }\r\n\t GameWrapper.prototype.start = function (event) {\r\n\t injectProps(event.data);\r\n\t this._gameView.start();\r\n\t };\r\n\t GameWrapper.prototype.stop = function (event) {\r\n\t this._gameView.stop();\r\n\t };\r\n\t return GameWrapper;\r\n\t}(engine.Container));\r\n\t//# sourceMappingURL=GameWrapper.js.map\n\n\tfunction index (props) {\r\n\t prepareProps();\r\n\t injectProps(props);\r\n\t var instance = new GameWrapper();\r\n\t return instance;\r\n\t}\r\n\t//# sourceMappingURL=index.js.map\n\n\treturn index;\n\n})));\n"
}
{
"name": "海底",
"desc": "海底模块",
"props": {
"level_1": {
"alias": "第一关数据(第一个是当前关卡通过所需积分,第二个是炸弹个数,第三个是道具个数,第四个是关卡时间)",
"type": "array<number>",
"default": "5,1,9,60"
},
"level_2": {
"alias": "第一关数据(第一个是当前关卡通过所需积分,第二个是炸弹个数,第三个是道具个数,第四个是关卡时间)",
"type": "array<number>",
"default": "10,2,14,80"
},
"level_3": {
"alias": "第一关数据(第一个是当前关卡通过所需积分,第二个是炸弹个数,第三个是道具个数,第四个是关卡时间)",
"type": "array<number>",
"default": "15,3,19,110"
}
},
"assets": [
{
"name": "灯",
"url": "//yun.duiba.com.cn/aurora/assets/c0f7c4b4d650da31d9b23a9006bd0e58aaca95ad.png",
"uuid": "55a9e50c-c7bc-4bb1-8624-fdd7edb66f93",
"ext": ".png"
},
{
"name": "机子",
"url": "//yun.duiba.com.cn/aurora/assets/e07baecf71ed8ecd9429fbbebb064b3cd50658df.png",
"uuid": "dee8564f-e17a-4a78-87f7-bebeb83fd235",
"ext": ".png"
},
{
"name": "篮筐",
"url": "//yun.duiba.com.cn/aurora/assets/b6977968fa3cdefbe181adbe2a381df9e8402af5.png",
"uuid": "8b49fe91-f6b7-414c-81d1-a9689e473b29",
"ext": ".png"
},
{
"name": "右按钮",
"url": "//yun.duiba.com.cn/aurora/assets/e3b4d4c0e557529b8c383639acce3d2ac01bf9b3.png",
"uuid": "1b1acf4a-a1fb-427e-a8cd-48214f89ac46",
"ext": ".png"
},
{
"name": "左按钮",
"url": "//yun.duiba.com.cn/aurora/assets/4bc49a4477adbfcda25d348473504d4384ad3dd2.png",
"uuid": "d828d269-68e7-4801-a3b2-e4bb1c38592b",
"ext": ".png"
},
{
"name": "basket_bottom",
"url": "//yun.duiba.com.cn/aurora/assets/8003d15eda09a24c38fdf32d2b774fe9a16fcd81.png",
"uuid": "1bccf897-d37e-4dc7-814f-6b8caf27a03b",
"ext": ".png"
},
{
"name": "basket_top",
"url": "//yun.duiba.com.cn/aurora/assets/55596516d4d44685fe07be1fef2105c8186edcd7.png",
"uuid": "826c7811-2767-469f-bf6b-908f3d404a1d",
"ext": ".png"
},
{
"name": "coin_json",
"url": "//yun.duiba.com.cn/aurora/assets/4170985efa5fea693a27734d14250e3b5a49962b.json",
"uuid": "9a0265ec-d9e7-4d47-83c7-d775115df38e",
"ext": ".json"
},
{
"name": "coin",
"url": "//yun.duiba.com.cn/aurora/assets/d6a361f27ebb81dd444ac40e428dffd06a0aa4e3.png",
"uuid": "abe242de-cf82-46ec-8a40-fcd51b0ca13d",
"ext": ".png"
},
{
"name": "boom_json",
"url": "//yun.duiba.com.cn/aurora/assets/4da36db75239d5c4f7b89d5805429ad64f7a05d5.json",
"uuid": "b0f0ae6d-b7c7-4a35-8c5a-7c4249f011db",
"ext": ".json"
},
{
"name": "boom",
"url": "//yun.duiba.com.cn/aurora/assets/b4579f262046e16245df9982ef31c57e433b0ba7.png",
"uuid": "129aa5f7-e308-40ce-ba9b-3fdc733d4ecb",
"ext": ".png"
},
{
"name": "candy_json",
"url": "//yun.duiba.com.cn/aurora/assets/2512911b42641f570be929e686a17fa91582f411.json",
"uuid": "0f21fae8-08cb-4c41-bab5-993d98fd7070",
"ext": ".json"
},
{
"name": "candy",
"url": "//yun.duiba.com.cn/aurora/assets/a91c39b45b0aa042b112ac477bc5ab80f00e8816.png",
"uuid": "67c0717c-9b89-4b56-a61a-91c8c7a99e4c",
"ext": ".png"
},
{
"name": "egg_json",
"url": "//yun.duiba.com.cn/aurora/assets/d789e4167a136e889729dd97d4f8728517226c8a.json",
"uuid": "75ac3c28-f8a8-4609-b908-bb386a6ace2c",
"ext": ".json"
},
{
"name": "egg",
"url": "//yun.duiba.com.cn/aurora/assets/a9156427b733d959c473dc0e37c929f103f77174.png",
"uuid": "e2f61593-e082-405a-bf19-79c78e2c067a",
"ext": ".png"
},
{
"name": "fail_json",
"url": "//yun.duiba.com.cn/aurora/assets/be22c261821766b019138176658ea3857f7dc5c8.json",
"uuid": "96f6c48f-f01e-4d13-a058-0c082edc38fa",
"ext": ".json"
},
{
"name": "fail",
"url": "//yun.duiba.com.cn/aurora/assets/d5fff67caae5a86bc29969d1676b76b253eda701.png",
"uuid": "9473b143-bd58-4450-b7b9-cb18911f3ba3",
"ext": ".png"
},
{
"name": "gift_json",
"url": "//yun.duiba.com.cn/aurora/assets/9165343ca17a457133d227956c217e0a821a0cf3.json",
"uuid": "48347b92-7c99-4bf5-a67a-d535b4785b20",
"ext": ".json"
},
{
"name": "gift",
"url": "//yun.duiba.com.cn/aurora/assets/e47e2ebdbb9cc8fe1f9f0e941af3cbe92b08162b.png",
"uuid": "a3667116-4218-4b5f-a6ec-c1529ddb71cf",
"ext": ".png"
},
{
"name": "success_json",
"url": "//yun.duiba.com.cn/aurora/assets/a010032b62ec260b6ad0844b1eff530847954e10.json",
"uuid": "3a70f25d-03c0-483c-847b-88b6e4ed5dcf",
"ext": ".json"
},
{
"name": "success",
"url": "//yun.duiba.com.cn/aurora/assets/e6c6b8fff68fcbb2e30cbb50f5690d52be4d8c99.png",
"uuid": "0ec792be-6fcc-4c5b-bf8a-0e8406a5c34b",
"ext": ".png"
},
{
"name": "玻璃",
"url": "//yun.duiba.com.cn/aurora/assets/90edb55a1c5fb4b7baf689144b7c1f3508ecb7ff.png",
"uuid": "92d1a3d4-256b-467b-a9a2-4820c2c2c718",
"ext": ".png"
},
{
"name": "contPng",
"url": "//yun.duiba.com.cn/aurora/assets/a19ba2de0b7f11830700ed8122585a95ebef1757.png",
"uuid": "84e4f5dc-149d-4ace-a02c-8b2aaf6819b1",
"ext": ".png"
},
{
"name": "bubble",
"url": "//yun.duiba.com.cn/aurora/assets/f30c3b92eac79cdae679c48436eb4ef92b97ff6c.png",
"uuid": "28c4a8e4-9ff8-4962-842a-dd90d04a958c",
"ext": ".png"
},
{
"name": "倒计时",
"url": "//yun.duiba.com.cn/aurora/assets/a9b9490cd7ef4974c6ca5c34b3b4e4a2fdd1f8ca.png",
"uuid": "893a1116-1ddb-49e5-89bd-8f523ad56f81",
"ext": ".png"
},
{
"name": "awesome",
"url": "//yun.duiba.com.cn/aurora/assets/89de7d7785bb70a95b139fe444b90fbe5e802c80.png",
"uuid": "b7f19c22-22ea-419e-99d0-3b6959b59f88",
"ext": ".png"
},
{
"name": "cool",
"url": "//yun.duiba.com.cn/aurora/assets/5e1ce8651de0f67cf98220238db00ef6d46b1aeb.png",
"uuid": "585b11a0-8d5d-4265-8871-96d98c0a65cf",
"ext": ".png"
},
{
"name": "good",
"url": "//yun.duiba.com.cn/aurora/assets/49a5633dc8429fac1d59c7a55ba15f3386cdddc7.png",
"uuid": "bdbc7ff6-5b64-4878-bcb2-9b83a498206b",
"ext": ".png"
},
{
"name": "great",
"url": "//yun.duiba.com.cn/aurora/assets/ad47ea03239e36e09806a74cb4bd475a42edb00a.png",
"uuid": "bd1da4bb-1dbf-4b80-a6ea-eb4e50cf65aa",
"ext": ".png"
},
{
"name": "perfect",
"url": "//yun.duiba.com.cn/aurora/assets/b560b07e694a95ef6b40b6702cdfc8853eb73ec3.png",
"uuid": "63ce23dc-be8b-4222-a0a6-0fd5a27c0af6",
"ext": ".png"
},
{
"name": "unbelievable",
"url": "//yun.duiba.com.cn/aurora/assets/a436eb46836e45d8043721107e5f49a58367ac3f.png",
"uuid": "6f352da0-0522-4530-b064-9132b591b341",
"ext": ".png"
},
{
"name": "进度",
"url": "//yun.duiba.com.cn/aurora/assets/0a7f33bba28a882ea1ec436b73ecafbaed4542d5.png",
"uuid": "647dc81b-443d-446b-bcf6-8b95b8511470",
"ext": ".png"
},
{
"name": "点亮",
"url": "//yun.duiba.com.cn/aurora/assets/3e8ca3a3f044df467c76a7a0d5ebbd75520bda8e.png",
"uuid": "9808f74f-a474-4c10-a8c6-bb51663d1a8e",
"ext": ".png"
},
{
"name": "lv1",
"url": "//yun.duiba.com.cn/aurora/assets/76db0c80d7b8051d7de44e87cac763ce607d2c7a.png",
"uuid": "a9a91d6c-06b0-4fdf-bcb8-77abe9bc7d83",
"ext": ".png"
},
{
"name": "lv2",
"url": "//yun.duiba.com.cn/aurora/assets/c5f1c83c683c5703432cc615b2c206aee1c675e0.png",
"uuid": "de8b2a81-fb38-4128-b536-9ef03eb013df",
"ext": ".png"
},
{
"name": "lv3",
"url": "//yun.duiba.com.cn/aurora/assets/beed55701a29bfa9b49dca1d5a059b34d7702496.png",
"uuid": "710eed46-f371-4d85-9858-ad048c86fc74",
"ext": ".png"
},
{
"name": "lv_common",
"url": "//yun.duiba.com.cn/aurora/assets/0afe14fc04beb3c66ce9080502c7c381f4b658ea.png",
"uuid": "e53e80fd-80a6-4385-b296-a3f097eeb51a",
"ext": ".png"
},
{
"name": "dot",
"url": "//yun.duiba.com.cn/aurora/assets/b39a88200f27f65e9d8d3f2a98a671de979f3027.png",
"uuid": "b8acc117-7d3c-4bcb-aff9-b5f42b901edf",
"ext": ".png"
}
],
"events": {
"in": {
"seabed-game-start": {
"alias": "开始",
"data": {}
},
"seabed-game-startNextLevel": {
"alias": "开始下一关",
"data": {
"level": "关卡"
}
},
"seabed-game-revive": {
"alias": "复活",
"data": {}
},
"seabed-game-themeChange": {
"alias": "更换主题",
"data": {
"gameCountdownImage": "游戏页倒计时",
"leftButtonImage": "左按钮",
"rightButtonImage": "右按钮"
}
}
},
"out": {
"seabed-game-fail": {
"alias": "游戏结束",
"data": {
"score": "当前分数",
"level": "当前关卡"
}
},
"seabed-game-success": {
"alias": "游戏成功",
"data": {
"score": "当前分数",
"level": "当前关卡"
}
}
}
},
"id": "seabed-game",
"code": "(function (global, factory) {\n typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('tslib')) :\n typeof define === 'function' && define.amd ? define(['tslib'], factory) :\n (global = global || self, global['seabed-game'] = factory(global.tslib));\n}(this, (function (tslib) { 'use strict';\n\n var LabelType;\r\n (function (LabelType) {\r\n LabelType[\"boom\"] = \"boom\";\r\n LabelType[\"candy\"] = \"candy\";\r\n LabelType[\"coin\"] = \"coin\";\r\n LabelType[\"gift\"] = \"gift\";\r\n LabelType[\"egg\"] = \"egg\";\r\n })(LabelType || (LabelType = {}));\r\n var LabelType$1 = LabelType;\r\n //# sourceMappingURL=LabelType.js.map\n\n var props = {};\r\n function prepareProps() {\r\n var metaProps = getProps();\r\n engine.injectProp(props, metaProps);\r\n }\r\n function injectProps(p) {\r\n engine.injectProp(props, p);\r\n }\r\n //# sourceMappingURL=props.js.map\n\n var levels;\r\n var setlevelData = function () {\r\n levels = {\r\n '1': { max: props.level_1[0], items: [[LabelType$1.boom, props.level_1[1]], [LabelType$1.coin, props.level_1[2]]], time: props.level_1[3] },\r\n '2': { max: props.level_2[0], items: [[LabelType$1.boom, props.level_2[1]], [LabelType$1.coin, props.level_2[2]]], time: props.level_2[3] },\r\n '3': { max: props.level_3[0], items: [[LabelType$1.boom, props.level_3[1]], [LabelType$1.coin, props.level_3[2]]], time: props.level_3[3] },\r\n };\r\n };\r\n var touchEnabled = false;\r\n var getTouchEnabled = function () {\r\n return touchEnabled;\r\n };\r\n var setTouchEnabled = function (b) {\r\n touchEnabled = b;\r\n };\r\n //# sourceMappingURL=GoldData.js.map\n\n function getTexture(uuid) {\r\n return engine.Texture.from(getAssetByUUID(uuid).uuid);\r\n }\r\n function getTextureByName(name) {\r\n return getTexture(engine.getAssetByName(name).uuid);\r\n }\r\n //# sourceMappingURL=utils.js.map\n\n var Tool = (function () {\r\n function Tool() {\r\n }\r\n Tool.getLabel = function (txt, size, color, bold, align, x, y) {\r\n if (color === void 0) { color = \"#ffffff\"; }\r\n if (bold === void 0) { bold = false; }\r\n if (align === void 0) { align = engine.TEXT_ALIGN.LEFT; }\r\n if (x === void 0) { x = 0; }\r\n if (y === void 0) { y = 0; }\r\n var label = new engine.Label();\r\n label.fillColor = color;\r\n label.bold = bold;\r\n label.size = size;\r\n label.textAlign = align;\r\n label.x = x;\r\n label.y = y;\r\n label.text = txt;\r\n return label;\r\n };\r\n return Tool;\r\n }());\r\n //# sourceMappingURL=Tools.js.map\n\n var curScore;\r\n function getScore() {\r\n return curScore;\r\n }\r\n function addScore(addCount) {\r\n curScore += addCount;\r\n return curScore;\r\n }\r\n function setScore(scoreCount) {\r\n curScore = scoreCount;\r\n }\r\n var curLevel;\r\n function getCurLevel() {\r\n return curLevel;\r\n }\r\n function setCurLevel(level) {\r\n curLevel = level;\r\n return curLevel;\r\n }\r\n var levels$1;\r\n var setlevelData$1 = function () {\r\n levels$1 = {\r\n '1': { max: props.level_1[0], items: [[LabelType$1.boom, props.level_1[1]], [LabelType$1.coin, props.level_1[2]]], time: props.level_1[3] },\r\n '2': { max: props.level_2[0], items: [[LabelType$1.boom, props.level_2[1]], [LabelType$1.coin, props.level_2[2]]], time: props.level_2[3] },\r\n '3': { max: props.level_3[0], items: [[LabelType$1.boom, props.level_3[1]], [LabelType$1.coin, props.level_3[2]]], time: props.level_3[3] },\r\n };\r\n };\r\n var getLevelData = function () {\r\n if (!levels$1) {\r\n setlevelData$1();\r\n }\r\n return levels$1[getCurLevel()];\r\n };\r\n var getCurrentItems = function () {\r\n if (!levels$1) {\r\n setlevelData$1();\r\n }\r\n return getLevelData().items;\r\n };\r\n var getlevelTime = function () {\r\n if (!levels$1) {\r\n setlevelData$1();\r\n }\r\n return getLevelData().time;\r\n };\r\n var getlevelMax = function () {\r\n if (!levels$1) {\r\n setlevelData$1();\r\n }\r\n return getLevelData().max;\r\n };\r\n //# sourceMappingURL=goldData.js.map\n\n var GameData = (function (_super) {\r\n tslib.__extends(GameData, _super);\r\n function GameData(parentNode, color) {\r\n var _this = _super.call(this) || this;\r\n _this.starList = [];\r\n _this._parentNode = parentNode;\r\n _this._color = color;\r\n _this.init();\r\n return _this;\r\n }\r\n GameData.prototype.init = function () {\r\n var scoreCount = this._scoreCount = Tool.getLabel('', 36, \"#ffffff\", true);\r\n scoreCount.y = 48;\r\n this.addChild(scoreCount);\r\n var scorelabel = this._scorelabel = Tool.getLabel('分', 22, \"#ffffff\");\r\n scorelabel.y = 56;\r\n this.addChild(scorelabel);\r\n var progress = new engine.Sprite(getTextureByName('进度'));\r\n progress.x = 212;\r\n progress.y = 8;\r\n this.addChild(progress);\r\n var progressMask = this._progressMask = new engine.Rect();\r\n progressMask.fillColor = 0x000000;\r\n progressMask.width = 245;\r\n progressMask.height = 100;\r\n progressMask.x = 213;\r\n progressMask.y = 5;\r\n progressMask.scaleX = 0;\r\n this.addChild(progressMask);\r\n progress.mask = progressMask;\r\n var star1 = new engine.Sprite(getTextureByName('点亮'));\r\n star1.x = 270;\r\n star1.y = 6;\r\n star1.visible = false;\r\n this.addChild(star1);\r\n this.starList.push(star1);\r\n var star2 = new engine.Sprite(getTextureByName('点亮'));\r\n star2.x = 365;\r\n star2.y = 6;\r\n star2.visible = false;\r\n this.addChild(star2);\r\n this.starList.push(star2);\r\n var star3 = new engine.Sprite(getTextureByName('点亮'));\r\n star3.x = 435;\r\n star3.y = 50;\r\n star3.visible = false;\r\n this.addChild(star3);\r\n this.starList.push(star3);\r\n this.scorePosUpdate();\r\n var levelLabel = this._levelLabel = Tool.getLabel('', 28, this._color || \"#28c1ec\", false);\r\n levelLabel.y = 98;\r\n this.addChild(levelLabel);\r\n this.levelUpdate();\r\n this.updateProgressMask();\r\n };\r\n GameData.prototype.scorePosUpdate = function () {\r\n this._scoreCount.text = getScore();\r\n this._scoreCount.x = (this._parentNode.width - this._scoreCount.width - this._scorelabel.width - 5) / 2;\r\n this._scorelabel.x = this._scoreCount.x + this._scoreCount.width + 5;\r\n this.updateProgressMask();\r\n };\r\n GameData.prototype.levelUpdate = function (color) {\r\n this._levelLabel.text = \"\\u7B2C\" + getCurLevel() + \"/3\\u5173\";\r\n this._levelLabel.x = (this._parentNode.width - this._levelLabel.width) / 2;\r\n };\r\n GameData.prototype.updateProgressMask = function () {\r\n var ratio = getScore() / getlevelMax();\r\n this._progressMask.scaleX = ratio;\r\n if (ratio >= 0.35) {\r\n this.starList[0].visible = true;\r\n }\r\n if (ratio >= 0.75) {\r\n this.starList[1].visible = true;\r\n }\r\n if (ratio >= 1) {\r\n this.starList[2].visible = true;\r\n }\r\n };\r\n GameData.prototype.resetMask = function () {\r\n this.starList.forEach(function (element) {\r\n element.visible = false;\r\n });\r\n };\r\n return GameData;\r\n }(engine.Container));\r\n //# sourceMappingURL=gameData.js.map\n\n var BaseItem = (function (_super) {\r\n tslib.__extends(BaseItem, _super);\r\n function BaseItem(mc, type) {\r\n var _this = _super.call(this) || this;\r\n _this.type = type;\r\n _this._mc = mc;\r\n var bubble = getTextureByName('bubble');\r\n var bubblePic = new engine.Sprite(bubble);\r\n bubblePic.anchorTexture.set(0.5, 0.5);\r\n _this._mc.anchorTexture.set(0.5, 0.5);\r\n _this._mc.x = bubblePic.x / 4;\r\n _this._mc.y = bubblePic.y / 4;\r\n _this.addChild(bubblePic);\r\n _this.addChild(_this._mc);\r\n return _this;\r\n }\r\n Object.defineProperty(BaseItem.prototype, \"mc\", {\r\n get: function () { return this._mc; },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n return BaseItem;\r\n }(engine.Sprite));\r\n //# sourceMappingURL=BaseItem.js.map\n\n var EgretRender = (function () {\r\n function EgretRender(root, engine) {\r\n this._root = root;\r\n this._engine = engine;\r\n }\r\n EgretRender.prototype.addBody = function (body, display, x, y) {\r\n if (display) {\r\n body['display'] = display;\r\n this._root.addChildAt(display, 0);\r\n display.x = x;\r\n display.y = y;\r\n }\r\n return body;\r\n };\r\n EgretRender.prototype.remove = function (body) {\r\n this.removeBody(body);\r\n this.removeDisplay(body);\r\n };\r\n EgretRender.prototype.removeBody = function (body) {\r\n Matter.World.remove(this._engine.world, body);\r\n };\r\n EgretRender.prototype.removeDisplay = function (body) {\r\n var display = body['display'];\r\n if (display && display.parent)\r\n display.parent.removeChild(display);\r\n };\r\n EgretRender.prototype.run = function () {\r\n var bodies = Matter.Composite.allBodies(this._engine.world);\r\n for (var i = 0; i < bodies.length; i++) {\r\n var body = bodies[i];\r\n var display = body['display'];\r\n if (!display)\r\n continue;\r\n var x1 = Math.round(display.x);\r\n var x2 = Math.round(body.position.x);\r\n var y1 = Math.round(display.y);\r\n var y2 = Math.round(body.position.y);\r\n var distanceX = Math.abs(x1 - x2);\r\n var distanceY = Math.abs(y1 - y2);\r\n var precision = 1;\r\n if (distanceX > precision || distanceY > precision) {\r\n if (display instanceof BaseItem)\r\n display.mc.resume();\r\n }\r\n else {\r\n if (display instanceof BaseItem)\r\n display.mc.pause();\r\n }\r\n display.x = body.position.x;\r\n display.y = body.position.y;\r\n display.rotation = this.getRotation(body.angle);\r\n }\r\n };\r\n EgretRender.prototype.rectangle = function (x, y, width, height, display, options) {\r\n var body = this.rectangleToRender(x, y, width, height, display, options);\r\n this.addBodyToWorld(body);\r\n return body;\r\n };\r\n EgretRender.prototype.circle = function (x, y, radius, display, options) {\r\n var body = this.circleToRender(x, y, radius, display, options);\r\n this.addBodyToWorld(body);\r\n return body;\r\n };\r\n EgretRender.prototype.addBodyToWorld = function (body) {\r\n Matter.World.add(this._engine.world, body);\r\n return body;\r\n };\r\n EgretRender.prototype.rectangleToRender = function (x, y, width, height, display, options) {\r\n var body = Matter.Bodies.rectangle(x, y, width, height, options);\r\n this.addBody(body, display, x, y);\r\n return body;\r\n };\r\n EgretRender.prototype.circleToRender = function (x, y, radius, display, options) {\r\n var body = Matter.Bodies.circle(x, y, radius, options);\r\n this.addBody(body, display, x, y);\r\n return body;\r\n };\r\n EgretRender.prototype.getRotation = function (angle) {\r\n return angle / Math.PI / 2 * 360;\r\n };\r\n return EgretRender;\r\n }());\r\n //# sourceMappingURL=EgretRender.js.map\n\n var wall = 1;\r\n var basket = 2;\r\n var award = 4;\r\n var bubble = 8;\r\n var bubbleStandby = 16;\r\n var bubbleGroup = -1;\r\n var bubbleStandbyGroup = -2;\r\n var wallMask = award + bubble + bubbleStandby;\r\n var basketMask = award + bubble + bubbleStandby;\r\n var awardMask = wall + basket + bubble;\r\n var bubbleMask = wall + basket + award;\r\n var bubbleStandbyMask = wall + basket;\r\n //# sourceMappingURL=collisionConfig.js.map\n\n var vibrate = (function (view, count, strength) {\r\n if (count === void 0) { count = 2; }\r\n if (strength === void 0) { strength = 10; }\r\n return new Promise(function (r) {\r\n var pos = [\r\n { x: strength, y: 0 },\r\n { x: 0, y: -strength },\r\n { x: -strength, y: 0 },\r\n { x: 0, y: strength },\r\n { x: 0, y: 0 },\r\n ];\r\n var list = [];\r\n for (var i = 0; i < count; i++) {\r\n list = list.concat(pos);\r\n }\r\n var x0 = view.x;\r\n var y0 = view.y;\r\n var counter = list.length;\r\n var _loop_1 = function (i) {\r\n var element = list[i];\r\n setTimeout(function () {\r\n view.x = element.x + x0;\r\n view.y = element.y + y0;\r\n counter--;\r\n if (counter == 0) {\r\n view.x = x0;\r\n view.y = y0;\r\n r();\r\n }\r\n }, 1000 / 60 * i);\r\n };\r\n for (var i = 0; i < list.length; i++) {\r\n _loop_1(i);\r\n }\r\n });\r\n });\r\n //# sourceMappingURL=vibrate.js.map\n\n var MovieClip = (function (_super) {\r\n tslib.__extends(MovieClip, _super);\r\n function MovieClip(_a) {\r\n var spritesheet = _a.spritesheet, frames = _a.frames, scale = _a.scale, position = _a.position, _b = _a.keys, keys = _b === void 0 ? null : _b, _c = _a.autoplay, autoplay = _c === void 0 ? true : _c, _d = _a.loop, loop = _d === void 0 ? true : _d, anchor = _a.anchor, _e = _a.frameInterval, frameInterval = _e === void 0 ? 1 : _e, _f = _a.callBack, callBack = _f === void 0 ? null : _f;\r\n var _this = _super.call(this) || this;\r\n _this.frames = frames;\r\n _this.frameInterval = frameInterval;\r\n _this.keys = keys;\r\n _this.autoplay = autoplay;\r\n _this.loop = loop;\r\n _this.anchorXtmp = anchor;\r\n _this.anchorYtmp = anchor;\r\n _this._callBack = callBack;\r\n if (Array.isArray(anchor)) {\r\n _this.anchorXtmp = anchor[0];\r\n _this.anchorYtmp = anchor[1];\r\n }\r\n _this.x = position[0];\r\n _this.y = position[1];\r\n _this.spritesheet = spritesheet;\r\n if (_this.autoplay) {\r\n _this.play();\r\n }\r\n _this.scaleX = _this.scaleY = scale;\r\n return _this;\r\n }\r\n MovieClip.prototype.pause = function () {\r\n this.removeEventListener(engine.Event.ENTER_FRAME, this.onTick, this);\r\n };\r\n MovieClip.prototype.resume = function () {\r\n this.addEventListener(engine.Event.ENTER_FRAME, this.onTick, this);\r\n };\r\n MovieClip.prototype.play = function (start) {\r\n if (start === void 0) { start = 0; }\r\n this.goto(start);\r\n this.currentFrame = 0;\r\n this.counter = 0;\r\n this.addEventListener(engine.Event.ENTER_FRAME, this.onTick, this);\r\n };\r\n MovieClip.prototype.goto = function (frame) {\r\n this.texture = this.textures[frame];\r\n };\r\n MovieClip.prototype.onTick = function () {\r\n this.counter++;\r\n if (this.counter == this.frameInterval) {\r\n this.counter = 0;\r\n this.currentFrame++;\r\n this.goto(this.currentFrame);\r\n if (this.currentFrame == this.frames.length - 1) {\r\n if (this.loop) {\r\n this.currentFrame = 0;\r\n }\r\n else {\r\n this.stop();\r\n if (this._callBack) {\r\n this._callBack();\r\n this._callBack = null;\r\n }\r\n }\r\n }\r\n }\r\n return false;\r\n };\r\n MovieClip.prototype.stop = function () {\r\n this.currentFrame = 0;\r\n this.removeEventListener(engine.Event.ENTER_FRAME, this.onTick, this);\r\n };\r\n Object.defineProperty(MovieClip.prototype, \"spritesheet\", {\r\n set: function (value) {\r\n this.textures = this.frames.map(function (frame) { return value[frame]; });\r\n this.anchorTexture.set(this.anchorXtmp, this.anchorYtmp);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(MovieClip.prototype, \"textureItemWidth\", {\r\n get: function () { return this.textures[0].width; },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(MovieClip.prototype, \"textureItemHeight\", {\r\n get: function () { return this.textures[0].height; },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n return MovieClip;\r\n }(engine.Image));\r\n //# sourceMappingURL=MovieClip.js.map\n\n var wait = function (duration) { return tslib.__awaiter(void 0, void 0, void 0, function () {\r\n return tslib.__generator(this, function (_a) {\r\n return [2, new Promise(function (resolve) { return setTimeout(resolve, duration); })];\r\n });\r\n }); };\r\n //# sourceMappingURL=wait.js.map\n\n var josnData = {};\r\n function getJsonAsset(name) {\r\n var config = engine.getAssetByName(name + '_json');\r\n var tmpJosnData = engine.globalLoader.get(config.uuid);\r\n if (tmpJosnData) {\r\n josnData[name] = convert(tmpJosnData);\r\n }\r\n }\r\n function convert(data) {\r\n var frames = data.frames;\r\n var jsonName = data.file.split('.')[0];\r\n var obj = {};\r\n for (var key in frames) {\r\n var f = frames[key];\r\n obj[jsonName + key + \".png\"] = {\r\n \"x\": f.x,\r\n \"y\": f.y,\r\n \"w\": f.w,\r\n \"h\": f.h,\r\n \"ox\": f.offX,\r\n \"oy\": f.offY,\r\n \"sw\": f.sourceW,\r\n \"sh\": f.sourceH,\r\n \"ro\": false,\r\n };\r\n }\r\n return obj || null;\r\n }\r\n function getJosnData(jsonName) {\r\n return josnData[jsonName] || null;\r\n }\r\n //# sourceMappingURL=JsonTools.js.map\n\n function createTextureSheet(baseTexture, altaData) {\r\n var frames = altaData;\r\n var frameKeys = Object.keys(frames);\r\n var frameIndex = 0;\r\n var textures = {};\r\n while (frameIndex < frameKeys.length) {\r\n var i = frameKeys[frameIndex];\r\n var data = frames[i];\r\n var frame = null;\r\n var trim = null;\r\n var orig = new engine.Rectangle(0, 0, Math.floor(data.sw), Math.floor(data.sh));\r\n if (data.ro) {\r\n frame = new engine.Rectangle(Math.floor(data.x), Math.floor(data.y), Math.floor(data.h), Math.floor(data.w));\r\n }\r\n else {\r\n frame = new engine.Rectangle(Math.floor(data.x), Math.floor(data.y), Math.floor(data.w), Math.floor(data.h));\r\n }\r\n if (data.ox || data.oy) {\r\n trim = new engine.Rectangle(Math.floor(data.ox), Math.floor(data.oy), Math.floor(data.w), Math.floor(data.h));\r\n }\r\n var texture = new engine.Texture(baseTexture, frame, orig, trim, data.ro ? 2 : 0);\r\n engine.Texture.addToCache(texture, i);\r\n textures[i] = texture;\r\n frameIndex++;\r\n }\r\n return textures;\r\n }\r\n //# sourceMappingURL=createTextureSheet.js.map\n\n function playMovieClip(parent, key, frames, frameInterval) {\r\n if (frameInterval === void 0) { frameInterval = 5; }\r\n return tslib.__awaiter(this, void 0, void 0, function () {\r\n var _this = this;\r\n return tslib.__generator(this, function (_a) {\r\n return [2, new Promise(function (r) { return tslib.__awaiter(_this, void 0, void 0, function () {\r\n var josnData, texture;\r\n var _this = this;\r\n return tslib.__generator(this, function (_a) {\r\n switch (_a.label) {\r\n case 0:\r\n josnData = getJosnData(key);\r\n if (!josnData) {\r\n getJsonAsset(key);\r\n josnData = getJosnData(key);\r\n }\r\n texture = createTextureSheet(getTextureByName(key).baseTexture, josnData);\r\n if (!texture) return [3, 2];\r\n return [4, createMc(parent, texture, frames, frameInterval)];\r\n case 1:\r\n _a.sent();\r\n r(1);\r\n return [3, 3];\r\n case 2:\r\n wait(300).then(function () { return tslib.__awaiter(_this, void 0, void 0, function () {\r\n var josnData;\r\n return tslib.__generator(this, function (_a) {\r\n switch (_a.label) {\r\n case 0:\r\n josnData = getJosnData(key);\r\n if (!josnData) {\r\n getJsonAsset(key);\r\n josnData = getJosnData(key);\r\n }\r\n texture = createTextureSheet(getTextureByName(key).baseTexture, josnData);\r\n if (!texture) return [3, 2];\r\n return [4, createMc(parent, texture, frames, frameInterval)];\r\n case 1:\r\n _a.sent();\r\n r(1);\r\n return [3, 3];\r\n case 2:\r\n r(0);\r\n _a.label = 3;\r\n case 3: return [2];\r\n }\r\n });\r\n }); });\r\n _a.label = 3;\r\n case 3: return [2];\r\n }\r\n });\r\n }); })];\r\n });\r\n });\r\n }\r\n function createMc(parent, spritesheet, frames, frameInterval) {\r\n if (frameInterval === void 0) { frameInterval = 5; }\r\n return new Promise(function (r) {\r\n var movieclip = new MovieClip({\r\n spritesheet: spritesheet,\r\n frameInterval: frameInterval,\r\n frames: frames,\r\n position: [0, 150],\r\n scale: 1,\r\n anchor: [0, 0],\r\n loop: false,\r\n callBack: function () {\r\n setTimeout(function () {\r\n parent.removeChild(movieclip);\r\n r(1);\r\n }, 100);\r\n }\r\n });\r\n parent.addChild(movieclip);\r\n });\r\n }\r\n var playBoom = function (parent) {\r\n return playMovieClip(parent, 'fail', ['fail1.png', 'fail2.png', 'fail3.png', 'fail4.png', 'fail5.png', 'fail6.png', 'fail7.png', 'fail8.png'], 5);\r\n };\r\n var playSuccess = function (parent) {\r\n return playMovieClip(parent, 'success', ['success1.png', 'success2.png', 'success3.png', 'success4.png', 'success5.png', 'success6.png', 'success7.png', 'success8.png', 'success9.png'], 5);\r\n };\r\n //# sourceMappingURL=playMovieClip.js.map\n\n var createCoin = function (scale) {\r\n var josnData = getJosnData('coin');\r\n if (!josnData) {\r\n getJsonAsset('coin');\r\n josnData = getJosnData('coin');\r\n }\r\n var texture = createTextureSheet(getTextureByName('coin').baseTexture, josnData);\r\n var animation = createMovieClip(texture, 0.6);\r\n var baseItem = new BaseItem(animation, LabelType$1.coin);\r\n baseItem.scaleX = baseItem.scaleY = scale;\r\n return baseItem;\r\n };\r\n var createMovieClip = function (spritesheet, scale) {\r\n if (scale === void 0) { scale = 1; }\r\n var list = ['coin1.png', 'coin2.png', 'coin3.png', 'coin4.png', 'coin5.png', 'coin6.png', 'coin7.png', 'coin8.png'];\r\n var movieclip = new MovieClip({\r\n spritesheet: spritesheet,\r\n frameInterval: 6,\r\n frames: list,\r\n position: [0, 0],\r\n scale: scale,\r\n anchor: [.5, .5]\r\n });\r\n return movieclip;\r\n };\r\n //# sourceMappingURL=createCoin.js.map\n\n var createBoom = function (scale) {\r\n var josnData = getJosnData('boom');\r\n if (!josnData) {\r\n getJsonAsset('boom');\r\n josnData = getJosnData('boom');\r\n }\r\n var boomTexture = createTextureSheet(getTextureByName('boom').baseTexture, josnData);\r\n var animation = createMovieClip$1(boomTexture);\r\n var baseItem = new BaseItem(animation, LabelType$1.boom);\r\n baseItem.scaleX = baseItem.scaleY = scale;\r\n return baseItem;\r\n };\r\n var createMovieClip$1 = function (spritesheet, scale) {\r\n if (scale === void 0) { scale = 1; }\r\n var list = ['boom1.png', 'boom2.png', 'boom3.png', 'boom4.png', 'boom5.png', 'boom6.png', 'boom7.png', 'boom8.png', 'boom9.png', 'boom10.png'];\r\n var movieclip = new MovieClip({\r\n spritesheet: spritesheet,\r\n frameInterval: 5,\r\n frames: list,\r\n position: [0, 0],\r\n scale: scale,\r\n anchor: [.5, .5]\r\n });\r\n return movieclip;\r\n };\r\n //# sourceMappingURL=createBoom.js.map\n\n var createGift = function (scale) {\r\n var josnData = getJosnData('gift');\r\n if (!josnData) {\r\n getJsonAsset('gift');\r\n josnData = getJosnData('gift');\r\n }\r\n var texture = createTextureSheet(getTextureByName('gift').baseTexture, josnData);\r\n var animation = createMovieClip$2(texture, 0.6);\r\n var baseItem = new BaseItem(animation, LabelType$1.gift);\r\n baseItem.scaleX = baseItem.scaleY = scale;\r\n return baseItem;\r\n };\r\n var createMovieClip$2 = function (spritesheet, scale) {\r\n if (scale === void 0) { scale = 1; }\r\n var list = ['gift1.png', 'gift2.png', 'gift3.png', 'gift4.png', 'gift5.png', 'gift6.png', 'gift7.png', 'gift8.png', 'gift9.png', 'gift10.png'];\r\n var movieclip = new MovieClip({\r\n spritesheet: spritesheet,\r\n frameInterval: 5,\r\n frames: list,\r\n position: [0, 0],\r\n scale: scale,\r\n anchor: [.5, .5]\r\n });\r\n return movieclip;\r\n };\r\n //# sourceMappingURL=createGift.js.map\n\n var createCandy = function (scale) {\r\n var josnData = getJosnData('candy');\r\n if (!josnData) {\r\n getJsonAsset('candy');\r\n josnData = getJosnData('candy');\r\n }\r\n var boomTexture = createTextureSheet(getTextureByName('candy').baseTexture, josnData);\r\n var animation = createMovieClip$3(boomTexture);\r\n var baseItem = new BaseItem(animation, LabelType$1.candy);\r\n baseItem.scaleX = baseItem.scaleY = scale;\r\n return baseItem;\r\n };\r\n var createMovieClip$3 = function (spritesheet, scale) {\r\n if (scale === void 0) { scale = 1; }\r\n var list = ['candy1.png', 'candy2.png', 'candy3.png', 'candy4.png', 'candy5.png', 'candy6.png', 'candy7.png', 'candy8.png'];\r\n var movieclip = new MovieClip({\r\n spritesheet: spritesheet,\r\n frameInterval: 6,\r\n frames: list,\r\n position: [0, 0],\r\n scale: scale,\r\n anchor: [.5, .5]\r\n });\r\n return movieclip;\r\n };\r\n //# sourceMappingURL=createCandy.js.map\n\n var createEgg = function (scale) {\r\n var josnData = getJosnData('egg');\r\n if (!josnData) {\r\n getJsonAsset('gift');\r\n josnData = getJosnData('egg');\r\n }\r\n var texture = createTextureSheet(getTextureByName('egg').baseTexture, josnData);\r\n var animation = createMovieClip$4(texture, 0.6);\r\n var baseItem = new BaseItem(animation, LabelType$1.egg);\r\n baseItem.scaleX = baseItem.scaleY = scale;\r\n return baseItem;\r\n };\r\n var createMovieClip$4 = function (spritesheet, scale) {\r\n if (scale === void 0) { scale = 1; }\r\n var list = ['egg1.png', 'egg2.png', 'egg3.png', 'egg4.png', 'egg5.png', 'egg6.png', 'egg7.png', 'egg8.png', 'egg9.png'];\r\n var movieclip = new MovieClip({\r\n spritesheet: spritesheet,\r\n frameInterval: 5,\r\n frames: list,\r\n position: [0, 0],\r\n scale: scale,\r\n anchor: [.5, .5]\r\n });\r\n return movieclip;\r\n };\r\n //# sourceMappingURL=createEgg.js.map\n\n var createItem = function (scale, type) {\r\n var funcs = {\r\n 'boom': createBoom,\r\n 'gift': createGift,\r\n 'candy': createCandy,\r\n 'egg': createEgg,\r\n 'coin': createCoin\r\n };\r\n var func = funcs[type];\r\n return func(scale);\r\n };\r\n //# sourceMappingURL=createItem.js.map\n\n var createBubble = function (_this, type, x, y, force, density) {\r\n if (force === void 0) { force = { x: 0, y: 0 }; }\r\n if (density === void 0) { density = 0.001; }\r\n var scale;\r\n var size = random(85, 100);\r\n var maxsize = 100;\r\n scale = size / maxsize;\r\n var baseItem = createItem(scale, type);\r\n var angle;\r\n angle = 0;\r\n _this._egretRender.circle(x, y, (size - 17) / 2, baseItem, {\r\n frictionAir: 0,\r\n collisionFilter: { group: award, category: award, mask: awardMask },\r\n angle: angle,\r\n label: baseItem.type,\r\n friction: 0,\r\n force: force,\r\n density: density\r\n });\r\n };\r\n var random = function (start, end) {\r\n var n = end - start;\r\n return Math.random() * n + start;\r\n };\r\n var createItems = (function (_this) {\r\n var score = getScore();\r\n var items = getCurrentItems();\r\n var list = [];\r\n for (var _i = 0, items_1 = items; _i < items_1.length; _i++) {\r\n var item = items_1[_i];\r\n var type = item[0];\r\n var nums = item[1];\r\n if (type == LabelType$1.coin)\r\n nums = nums - score;\r\n for (var i = 0; i < nums; i++) {\r\n list.push(type);\r\n }\r\n }\r\n var count = 0;\r\n var coinsFall = setInterval(function () {\r\n if (count <= list.length - 1) {\r\n var type = list[count];\r\n createBubble(_this, type, 375 + Math.random() * 200 - 100, 400 + 200 + 200);\r\n count++;\r\n }\r\n }, 100);\r\n });\r\n //# sourceMappingURL=createItems.js.map\n\n var clear = function (that) {\r\n TextList.forEach(function (i) {\r\n engine.Tween.removeTweens(that.gameHint[i]);\r\n that.gameHint[i].alpha = 0;\r\n });\r\n };\r\n var playgreat = function (image) {\r\n engine.Tween.get(image).set({ x: 750, alpha: 1, scaleX: .9, scaleY: .9, rotation: 20 }).to({ x: 540.5, scaleX: 1, scaleY: 1, rotation: 0 }, 200, engine.Ease.getBackOut(2)).wait(500).to({ alpha: 0 }, 200);\r\n };\r\n var playcool = function (image) {\r\n engine.Tween.get(image).set({ x: 750, alpha: 1, scaleX: .9, scaleY: .9, rotation: 60 }).to({ x: 526.09, scaleX: 1, scaleY: 1, rotation: 0 }, 200, engine.Ease.getBackOut(7)).wait(500).to({ alpha: 0 }, 200);\r\n };\r\n var playperfect = function (image) {\r\n engine.Tween.get(image).set({ scaleX: 0, scaleY: 0, alpha: 1, }).to({ scaleX: 1, scaleY: 1 }, 200, engine.Ease.getBackOut(10)).wait(500).to({ alpha: 0 }, 200);\r\n };\r\n var playawesome = function (image) {\r\n engine.Tween.get(image).set({ scaleX: 0, scaleY: 0, alpha: 1, rotation: -20 }).to({ scaleX: 1, scaleY: 1, rotation: 0 }, 200, engine.Ease.getBackOut(20)).wait(500).to({ alpha: 0 }, 200);\r\n };\r\n var playunbelievable = function (image) {\r\n engine.Tween.get(image).set({ scaleX: 0, scaleY: 0, alpha: 1, rotation: -60 }).to({ scaleX: 1, scaleY: 1, rotation: 0 }, 200, engine.Ease.getBackOut(40)).wait(500).to({ alpha: 0 }, 200);\r\n };\r\n var funcs = [playgreat, playcool, playperfect, playawesome, playunbelievable];\r\n var cdtimer;\r\n var count = 0;\r\n var playTextAni = function (that) { return tslib.__awaiter(void 0, void 0, void 0, function () {\r\n var image;\r\n return tslib.__generator(this, function (_a) {\r\n clear(that);\r\n count++;\r\n if (count >= TextList.length)\r\n count = TextList.length;\r\n console.log(count);\r\n image = that.gameHint[TextList[count - 1]];\r\n image.visible = true;\r\n funcs[count - 1](image);\r\n if (cdtimer > 0)\r\n clearTimeout(cdtimer);\r\n cdtimer = setTimeout(function () {\r\n count = 0;\r\n console.log('clear');\r\n }, 5000);\r\n return [2];\r\n });\r\n }); };\r\n var TextList = ['great', 'cool', 'perfect', 'awesome', 'unbelievable'];\r\n //# sourceMappingURL=playTextAni.js.map\n\n function check(_this) {\r\n var egretRenderContainer = _this.egretRenderContainer;\r\n var center = 375;\r\n var paddingX = 50;\r\n var ypos = 570;\r\n var h = 40;\r\n var bodies = Matter.Composite.allBodies(_this._engine.world);\r\n var isAward = function (i) { return i.collisionFilter.group == award; };\r\n bodies.forEach(function (i) {\r\n if (!isAward(i))\r\n return;\r\n if (i['timer']) {\r\n var t0 = Date.now() - i['timer'];\r\n if (t0 > 3000) {\r\n delete i['timer'];\r\n }\r\n }\r\n var _a = i.position, x = _a.x, y = _a.y;\r\n var xResult = x > (center - paddingX) && x < (center + paddingX);\r\n var yResult = y > ypos && y < (ypos + h);\r\n if (xResult && yResult && i.velocity.y > 0 && !i['timer']) {\r\n i['timer'] = Date.now();\r\n if (i.label == LabelType$1.boom) {\r\n _this._egretRender.remove(i);\r\n vibrate(_this, 2);\r\n playBoom(egretRenderContainer);\r\n _this.onBoom();\r\n }\r\n else if (i.label == LabelType$1.egg) {\r\n _this._egretRender.remove(i);\r\n }\r\n else if (i.label == LabelType$1.candy) {\r\n _this._egretRender.remove(i);\r\n }\r\n else if (i.label == LabelType$1.gift) {\r\n _this._egretRender.remove(i);\r\n }\r\n else {\r\n playSuccess(_this.egretRenderContainer);\r\n _this._egretRender.remove(i);\r\n _this.addScore();\r\n playTextAni(_this);\r\n }\r\n }\r\n });\r\n }\r\n //# sourceMappingURL=check.js.map\n\n var createBox = function (_this) {\r\n var path1 = Matter.Vertices.fromPath('385 370 630 380 670 728 620 1080 370 1100 109 1090 57 728 108 370 0 370 0 1624 750 1624 750 0', null);\r\n var body = Matter.Bodies.fromVertices(400, 880, [path1], { isStatic: true, collisionFilter: { group: wall, category: wall, mask: wallMask } }, true);\r\n Matter.World.add(_this._engine.world, body);\r\n var path2 = Matter.Vertices.fromPath('108 370 385 370 385 300', null);\r\n var body2 = Matter.Bodies.fromVertices(296, 365, [path2], { isStatic: true, collisionFilter: { group: wall, category: wall, mask: wallMask } }, true);\r\n Matter.World.add(_this._engine.world, body2);\r\n var basketpath1 = Matter.Vertices.fromPath('290 560 324 600 326 600 313 565', null);\r\n var basketbody1 = Matter.Bodies.fromVertices(305, 575, [basketpath1], { isStatic: true, friction: 0, collisionFilter: { group: basket, category: basket, mask: basketMask } }, true);\r\n Matter.World.add(_this._engine.world, basketbody1);\r\n var basketpath2 = Matter.Vertices.fromPath('465 563 443 605 441 605 456 560', null);\r\n var basketbody2 = Matter.Bodies.fromVertices(453, 570, [basketpath2], { isStatic: true, friction: 0, collisionFilter: { group: basket, category: basket, mask: basketMask } }, true);\r\n Matter.World.add(_this._engine.world, basketbody2);\r\n var basketLeft = Matter.Bodies.circle(285, 560, 12, { isStatic: true, friction: 0, collisionFilter: { group: basket, category: basket, mask: basketMask } });\r\n Matter.World.add(_this._engine.world, basketLeft);\r\n var basketRight = Matter.Bodies.circle(461, 560, 12, { isStatic: true, friction: 0, collisionFilter: { group: basket, category: basket, mask: basketMask } });\r\n Matter.World.add(_this._engine.world, basketRight);\r\n var w = 100;\r\n var h = 50;\r\n var rect = _this._egretRender.rectangle(180, 1080, w, h, null, { isStatic: true, collisionFilter: { group: wall, category: wall, mask: wallMask } });\r\n var rect2 = _this._egretRender.rectangle(560, 1080, w, h, null, { isStatic: true, collisionFilter: { group: wall, category: wall, mask: wallMask } });\r\n var w2 = 300;\r\n var h2 = 10;\r\n var rect3 = _this._egretRender.rectangle(375, 1100, w2, h2, null, { isStatic: true, collisionFilter: { group: wall, category: wall, mask: wallMask } });\r\n };\r\n //# sourceMappingURL=createBox.js.map\n\n var createBubblePic = function (r) {\r\n var bubbleTexture = getTextureByName('bubble');\r\n var bubblePic = new engine.Sprite(bubbleTexture);\r\n bubblePic.scaleX = bubblePic.scaleY = r * 2 / 100;\r\n return bubblePic;\r\n };\r\n //# sourceMappingURL=createBubblePic.js.map\n\n var timerLeft;\r\n var timerRight;\r\n var startStandbyBubblesLeft = function (egretRender) {\r\n timerLeft = setInterval(function () {\r\n var scale = 0.2;\r\n var p1 = { x: 180, y: 1050 };\r\n var r = random$1(8, 10);\r\n var bubblePic = createBubblePic(r);\r\n var body = egretRender.circle(p1.x, p1.y, r, bubblePic, {\r\n restitution: 0,\r\n frictionAir: 0,\r\n force: { x: random$1(-0.005, 0.005) * scale, y: -0.02 * scale },\r\n collisionFilter: { group: bubbleStandbyGroup, category: bubbleStandby, mask: bubbleStandbyMask }\r\n });\r\n setTimeout(function () {\r\n egretRender.remove(body);\r\n }, 1000);\r\n }, 700);\r\n };\r\n var startStandbyBubblesRight = function (egretRender) {\r\n timerRight = setInterval(function () {\r\n var scale = 0.2;\r\n var p2 = { x: 560, y: 1050 };\r\n var r2 = random$1(8, 10);\r\n var bubblePic2 = createBubblePic(r2);\r\n var body2 = egretRender.circle(p2.x, p2.y, r2, bubblePic2, {\r\n restitution: 0,\r\n frictionAir: 0,\r\n force: { x: random$1(-0.005, 0.005) * scale, y: -0.02 * scale },\r\n collisionFilter: { group: bubbleStandbyGroup, category: bubbleStandby, mask: bubbleStandbyMask }\r\n });\r\n setTimeout(function () {\r\n egretRender.remove(body2);\r\n }, 1000);\r\n }, 700);\r\n };\r\n var stopStandbyBubblesLeft = function () {\r\n clearInterval(timerLeft);\r\n };\r\n var stopStandbyBubblesRight = function () {\r\n clearInterval(timerRight);\r\n };\r\n var random$1 = function (start, end) {\r\n var n = end - start;\r\n return Math.random() * n + start;\r\n };\r\n //# sourceMappingURL=standbyBubbles.js.map\n\n var createBtns = (function (that) {\r\n var createShape = function () {\r\n var shape = new engine.Shape();\r\n shape.beginFill(0, .6);\r\n shape.drawCircle(0, 0, that._leftBtn.width / 2);\r\n shape.endFill();\r\n return shape;\r\n };\r\n [that._leftBtn, that._rightBtn].forEach(function (btn) {\r\n btn.addEventListener(engine.MouseEvent.MOUSE_DOWN, function (e) {\r\n var btn = e.target;\r\n engine.Tween.removeTweens(btn);\r\n engine.Tween.get(btn)\r\n .to({ scaleY: 0.9 }, 200);\r\n }, that);\r\n });\r\n [that._leftBtn, that._rightBtn].forEach(function (btn) {\r\n btn.addEventListener(engine.MouseEvent.MOUSE_UP, function (e) {\r\n var btn = e.target;\r\n engine.Tween.removeTweens(btn);\r\n engine.Tween.get(btn)\r\n .to({ scaleX: 1, scaleY: 1 }, 200);\r\n }, that);\r\n });\r\n [that._leftBtn, that._rightBtn].forEach(function (btn) {\r\n btn.addEventListener(engine.MouseEvent.MOUSE_OUT, function (e) {\r\n var btn = e.target;\r\n engine.Tween.removeTweens(btn);\r\n engine.Tween.get(btn)\r\n .to({ scaleX: 1, scaleY: 1 }, 200);\r\n }, that);\r\n });\r\n var shapeLeft = createShape();\r\n shapeLeft.x = that._leftBtn.width / 2;\r\n shapeLeft.y = that._leftBtn.height / 2;\r\n that._leftBtn.addChild(shapeLeft);\r\n var shapeR = createShape();\r\n shapeR.x = that._rightBtn.width / 2;\r\n shapeR.y = that._rightBtn.height / 2;\r\n that._rightBtn.addChild(shapeR);\r\n shapeLeft.alpha = shapeR.alpha = 0;\r\n });\r\n //# sourceMappingURL=createBtns.js.map\n\n var GameView = (function (_super) {\r\n tslib.__extends(GameView, _super);\r\n function GameView() {\r\n var _this = _super.call(this) || this;\r\n _this.gameHint = {};\r\n _this.addForce = false;\r\n _this.stageX = 0;\r\n _this.stageY = 0;\r\n _this._frameCount = 0;\r\n return _this;\r\n }\r\n GameView.prototype.start = function (color) {\r\n return tslib.__awaiter(this, void 0, void 0, function () {\r\n var a, gameNode, contPng, leftBtn, rightBtn, light, basket_bottom, tmpRect, basket_top, glass, gameData, countDown, countDownLabel;\r\n return tslib.__generator(this, function (_a) {\r\n a = new engine.Shape();\r\n this.addChild(a);\r\n engine.globalLoader.loadImage('//yun.duiba.com.cn/aurora/assets/66ab48ff49a741f0c93335d4eb0c9e50b7ab6e1e.png', 'bg_dot')\r\n .then(function (img) {\r\n a.beginBitmapFill(img, null);\r\n a.drawRect(0, 0, 750, 1624);\r\n a.endFill();\r\n });\r\n gameNode = this._gameNode = new engine.Sprite(getTextureByName('机子'));\r\n gameNode.y = 260;\r\n this.addChild(gameNode);\r\n contPng = new engine.Image(getTextureByName('contPng'));\r\n contPng.x = (750 - contPng.width) / 2;\r\n contPng.y = 215;\r\n this.addChild(contPng);\r\n leftBtn = this._leftBtn = new engine.Sprite(getTextureByName('左按钮'));\r\n leftBtn.anchorY = leftBtn.height - 50;\r\n leftBtn.x = 83;\r\n leftBtn.y = 920;\r\n gameNode.addChild(leftBtn);\r\n rightBtn = this._rightBtn = new engine.Sprite(getTextureByName('右按钮'));\r\n rightBtn.anchorY = rightBtn.height - 50;\r\n rightBtn.x = 400;\r\n rightBtn.y = 920;\r\n gameNode.addChild(rightBtn);\r\n light = this._light = new engine.Sprite(getTextureByName('灯'));\r\n light.x = 12;\r\n light.y = 44;\r\n gameNode.addChild(light);\r\n basket_bottom = this._basket_bottom = new engine.Sprite(getTextureByName('basket_bottom'));\r\n basket_bottom.x = (contPng.width - basket_bottom.width) / 2;\r\n basket_bottom.y = 85;\r\n contPng.addChild(basket_bottom);\r\n tmpRect = new engine.Rect();\r\n tmpRect.x = 230;\r\n tmpRect.y = 372;\r\n tmpRect.width = 300;\r\n tmpRect.height = 300;\r\n this.addChild(tmpRect);\r\n basket_bottom.mask = tmpRect;\r\n basket_top = this._basket_top = new engine.Sprite(getTextureByName('basket_top'));\r\n basket_top.x = 287;\r\n basket_top.y = 485;\r\n this.addChild(basket_top);\r\n glass = this._basket_top = new engine.Sprite(getTextureByName('玻璃'));\r\n glass.x = (750 - glass.width) / 2;\r\n glass.y = 340;\r\n this.addChild(glass);\r\n gameData = this._gameData = new GameData(contPng, color);\r\n contPng.addChild(gameData);\r\n countDown = this._countDown = new engine.Sprite(getTextureByName('倒计时'));\r\n countDown.x = 5;\r\n countDown.y = 180;\r\n this.addChild(countDown);\r\n this._curLevelTime = getlevelTime();\r\n countDownLabel = this._countDownLabel = Tool.getLabel(this._curLevelTime, 48, \"#ffffff\");\r\n countDownLabel.x = (countDown.width - countDownLabel.width) / 2;\r\n countDownLabel.y = (countDown.height - countDownLabel.height) / 2 - 5;\r\n countDown.addChild(countDownLabel);\r\n this.initGameHint();\r\n this.startHandle();\r\n this.levelHint();\r\n return [2];\r\n });\r\n });\r\n };\r\n GameView.prototype.levelHint = function () {\r\n var lvBg = this._lvbg = new engine.Rect();\r\n lvBg.fillColor = 0x000000;\r\n lvBg.alpha = 0.7;\r\n lvBg.width = 750;\r\n lvBg.height = 1624;\r\n lvBg.x = lvBg.y = 0;\r\n lvBg.visible = false;\r\n this.addChild(lvBg);\r\n var lv_common = this._lv_common = new engine.Sprite(getTextureByName('lv_common'));\r\n lv_common.x = (750 - lv_common.width) / 2;\r\n lv_common.y = 500;\r\n lv_common.visible = false;\r\n this.addChild(lv_common);\r\n var lv1 = this._lv = new engine.Sprite(getTextureByName('lv1'));\r\n lv1.anchorTexture.set(0.5, 0.5);\r\n lv1.x = lv_common.width / 2;\r\n lv1.y = 80;\r\n lv_common.addChild(lv1);\r\n var lv1_label = this._lv_label = Tool.getLabel(\"5\", 38, \"#28c1ec\", true, engine.TEXT_ALIGN.CENTER);\r\n lv1_label.width = 100;\r\n lv1_label.x = 205;\r\n lv1_label.y = 205;\r\n lv1_label.fillColor = 0xffffff;\r\n lv_common.addChild(lv1_label);\r\n };\r\n GameView.prototype.initGameHint = function () {\r\n var awesome = new engine.Sprite(getTextureByName('awesome'));\r\n awesome.anchorTexture.set(0.5, 0.5);\r\n awesome.x = 520;\r\n awesome.y = 490;\r\n awesome.alpha = 0;\r\n this.addChild(awesome);\r\n this.gameHint['awesome'] = awesome;\r\n var cool = new engine.Sprite(getTextureByName('cool'));\r\n cool.anchorTexture.set(0.5, 0.5);\r\n cool.x = 520;\r\n cool.y = 490;\r\n cool.alpha = 0;\r\n this.addChild(cool);\r\n this.gameHint['cool'] = cool;\r\n var good = new engine.Sprite(getTextureByName('good'));\r\n good.anchorTexture.set(0.5, 0.5);\r\n good.x = 520;\r\n good.y = 490;\r\n good.alpha = 0;\r\n this.addChild(good);\r\n this.gameHint['good'] = good;\r\n var great = new engine.Sprite(getTextureByName('great'));\r\n great.anchorTexture.set(0.5, 0.5);\r\n great.x = 520;\r\n great.y = 490;\r\n great.alpha = 0;\r\n this.addChild(great);\r\n this.gameHint['great'] = great;\r\n var perfect = new engine.Sprite(getTextureByName('perfect'));\r\n perfect.anchorTexture.set(0.5, 0.5);\r\n perfect.x = 530;\r\n perfect.y = 490;\r\n perfect.alpha = 0;\r\n this.addChild(perfect);\r\n this.gameHint['perfect'] = perfect;\r\n var unbelievable = new engine.Sprite(getTextureByName('unbelievable'));\r\n unbelievable.anchorTexture.set(0.5, 0.5);\r\n unbelievable.x = 480;\r\n unbelievable.y = 460;\r\n unbelievable.alpha = 0;\r\n this.addChild(unbelievable);\r\n this.gameHint['unbelievable'] = unbelievable;\r\n };\r\n GameView.prototype.startNextLevel = function () {\r\n this.clearAwardBody();\r\n this.playLevelAni();\r\n setTouchEnabled(true);\r\n createItems(this);\r\n this._gameData.scorePosUpdate();\r\n this._gameData.resetMask();\r\n this._gameData.levelUpdate();\r\n this._curLevelTime = getlevelTime();\r\n this._countDownLabel.text = this._curLevelTime;\r\n this._countDownLabel.x = (this._countDown.width - this._countDownLabel.width) / 2;\r\n this.runEngine();\r\n };\r\n GameView.prototype.themeChange = function (data) {\r\n this._countDown.texture = engine.Texture.fromImage(data.gameCountdownImage);\r\n this._leftBtn.texture = engine.Texture.fromImage(data.leftButtonImage);\r\n this._leftBtn.anchorY = this._leftBtn.height - 50;\r\n this._leftBtn.x = 83;\r\n this._leftBtn.y = 920;\r\n this._rightBtn.texture = engine.Texture.fromImage(data.rightButtonImage);\r\n this._rightBtn.anchorY = this._rightBtn.height - 50;\r\n this._rightBtn.x = 400;\r\n this._rightBtn.y = 920;\r\n };\r\n GameView.prototype.revive = function () {\r\n setTouchEnabled(true);\r\n this.runEngine();\r\n };\r\n GameView.prototype.startHandle = function () {\r\n var engineMatter = Matter.Engine.create();\r\n this._engine = engineMatter;\r\n this._engine.world.gravity.y = 0.2;\r\n this.egretRenderContainer = new engine.Sprite();\r\n this.addChild(this.egretRenderContainer);\r\n this._egretRender = new EgretRender(this.egretRenderContainer, this._engine);\r\n var options = {\r\n width: 750,\r\n height: 1624,\r\n wireframes: !1,\r\n };\r\n var render = Matter.Render.create({\r\n element: document.getElementById('debugCanvas'),\r\n engine: engineMatter,\r\n options: options\r\n });\r\n Matter.Render.run(render);\r\n this.runGame();\r\n };\r\n GameView.prototype.runGame = function () {\r\n var _this = this;\r\n createBox(this);\r\n Matter.Events.on(this._engine, 'beforeUpdate', function () {\r\n if (!_this.addForce)\r\n return;\r\n _this.addForce = false;\r\n var isleft = _this.stageX < 375;\r\n var start = isleft ? { x: 180, y: 1050 } : { x: 560, y: 1050 };\r\n var scale = 2.2;\r\n for (var i = 0; i < 15; i++) {\r\n setTimeout(function () {\r\n var r = _this.random(10, 14);\r\n var bubblePic;\r\n bubblePic = createBubblePic(r);\r\n var basex = 0.02;\r\n var xoffset = 0.007;\r\n var fx = isleft ? _this.random(-basex, basex) : _this.random(-basex, basex);\r\n var padding = 50;\r\n var startx = _this.random(start.x - padding, start.x + padding);\r\n if (fx < -xoffset || fx > xoffset)\r\n bubblePic = null;\r\n var body = _this._egretRender.circle(startx, start.y, r, bubblePic, {\r\n density: 0.001 * 3,\r\n restitution: 1,\r\n force: { x: fx * scale, y: -0.02 * scale },\r\n collisionFilter: { group: bubbleGroup, category: bubble, mask: bubbleMask }\r\n });\r\n setTimeout(function () {\r\n _this._egretRender.remove(body);\r\n }, 1000);\r\n }, Math.random() * 200);\r\n }\r\n var _loop_1 = function (j) {\r\n var start_1 = isleft ? { x: 180 + 50, y: 1050 + 30 } : { x: 560 - 50, y: 1050 + 30 };\r\n var r = _this.random(10, 14);\r\n var body = _this._egretRender.circle(start_1.x, start_1.y, r, null, {\r\n density: 0.001 * 3,\r\n restitution: 1,\r\n force: { x: (isleft ? 1 : -1) * 0.02 * 1.7, y: 0 },\r\n collisionFilter: { group: bubbleGroup, category: bubble, mask: bubbleMask }\r\n });\r\n setTimeout(function () {\r\n _this._egretRender.remove(body);\r\n }, 1000);\r\n };\r\n for (var j = 0; j < 1; j++) {\r\n _loop_1();\r\n }\r\n });\r\n this._leftBtn.addEventListener(engine.MouseEvent.CLICK, function (e) {\r\n if (!getTouchEnabled())\r\n return;\r\n _this.addForce = true;\r\n _this.stageX = e.stageX;\r\n stopStandbyBubblesLeft();\r\n clearTimeout(_this._startStandbyBubblesLeft);\r\n _this._startStandbyBubblesLeft = setTimeout(function () {\r\n startStandbyBubblesLeft(_this._egretRender);\r\n }, 1000);\r\n }, this);\r\n this._rightBtn.addEventListener(engine.MouseEvent.CLICK, function (e) {\r\n if (!getTouchEnabled())\r\n return;\r\n _this.addForce = true;\r\n _this.stageX = e.stageX;\r\n stopStandbyBubblesRight();\r\n clearTimeout(_this._startStandbyBubblesRight);\r\n _this._startStandbyBubblesRight = setTimeout(function () {\r\n startStandbyBubblesRight(_this._egretRender);\r\n }, 1000);\r\n }, this);\r\n createBtns(this);\r\n startStandbyBubblesLeft(this._egretRender);\r\n startStandbyBubblesRight(this._egretRender);\r\n };\r\n GameView.prototype.enterFrame = function () {\r\n var now = Date.now();\r\n var deltaTime = this.lastTime ? now - this.lastTime : 16.7;\r\n this.lastTime = now;\r\n this._frameCount += deltaTime;\r\n if (this._frameCount >= 1000) {\r\n this._frameCount = 0;\r\n this.updateCountDown();\r\n }\r\n if (deltaTime > 20)\r\n deltaTime = 20;\r\n Matter.Engine.update(this._engine, deltaTime);\r\n this._egretRender.run();\r\n check(this);\r\n return false;\r\n };\r\n GameView.prototype.random = function (start, end) {\r\n var n = end - start;\r\n return Math.random() * n + start;\r\n };\r\n GameView.prototype.runEngine = function () {\r\n engine.gameStage.addEventListener(engine.Event.ENTER_FRAME, this.enterFrame, this);\r\n };\r\n GameView.prototype.updateCountDown = function () {\r\n this._curLevelTime--;\r\n this._countDownLabel.text = this._curLevelTime;\r\n this._countDownLabel.x = (this._countDown.width - this._countDownLabel.width) / 2;\r\n if (this._curLevelTime <= 0) {\r\n this.end();\r\n console.log('时间结束');\r\n }\r\n };\r\n GameView.prototype.onBoom = function () {\r\n this.end();\r\n };\r\n GameView.prototype.addScore = function () {\r\n addScore(1);\r\n if (getScore() >= getlevelMax()) {\r\n setTouchEnabled(false);\r\n engine.gameStage.removeEventListener(engine.Event.ENTER_FRAME, this.enterFrame, this);\r\n engine.globalEvent.dispatchEvent('seabed-game-success', { level: getCurLevel(), score: getScore() });\r\n }\r\n this._gameData.scorePosUpdate();\r\n };\r\n GameView.prototype.playLevelAni = function () {\r\n var _this = this;\r\n var lv = getCurLevel();\r\n this._lv.texture = getTextureByName(\"lv\" + lv);\r\n this._lv_label.text = getlevelMax() + '';\r\n this._lvbg.visible = true;\r\n this._lv_common.visible = true;\r\n engine.Tween.get(this._lv_common).set({ y: 500 - 1624 }).to({ y: 500 }, 700, engine.Ease.backOut)\r\n .wait(1000).to({ y: 1624 + 500 }, 500, engine.Ease.backIn)\r\n .call(function () {\r\n _this._lvbg.visible = false;\r\n });\r\n };\r\n GameView.prototype.clearAwardBody = function () {\r\n var _this = this;\r\n var bodies = Matter.Composite.allBodies(this._engine.world);\r\n var isAward = function (i) { return i.collisionFilter.group == award; };\r\n bodies.forEach(function (i) {\r\n if (isAward(i))\r\n _this._egretRender.remove(i);\r\n });\r\n };\r\n GameView.prototype.end = function () {\r\n engine.gameStage.removeEventListener(engine.Event.ENTER_FRAME, this.enterFrame, this);\r\n engine.globalEvent.dispatchEvent('seabed-game-fail', { level: getCurLevel(), score: getScore(), time: this._curLevelTime });\r\n setTouchEnabled(false);\r\n };\r\n return GameView;\r\n }(engine.Container));\r\n //# sourceMappingURL=GameView.js.map\n\n var GameWrapper = (function (_super) {\r\n tslib.__extends(GameWrapper, _super);\r\n function GameWrapper() {\r\n var _this = _super.call(this) || this;\r\n engine.globalEvent.addEventListener('seabed-game-start', _this.start, _this);\r\n engine.globalEvent.addEventListener('seabed-game-revive', _this.revive, _this);\r\n engine.globalEvent.addEventListener('seabed-game-startNextLevel', _this.startNextLevel, _this);\r\n engine.globalEvent.addEventListener('seabed-game-themeChange', _this.themeChange, _this);\r\n var gameView = _this._gameView = new GameView();\r\n _this.addChild(gameView);\r\n return _this;\r\n }\r\n GameWrapper.prototype.start = function (event) {\r\n setlevelData();\r\n this.initData();\r\n this._gameView.start(event.data.color);\r\n ['coin', 'boom', 'fail', 'success'].forEach(function (element) {\r\n getJsonAsset(element);\r\n });\r\n };\r\n GameWrapper.prototype.startNextLevel = function (event) {\r\n setScore(0);\r\n setCurLevel(parseInt(event.data.level));\r\n this._gameView.startNextLevel();\r\n };\r\n GameWrapper.prototype.initData = function () {\r\n setScore(0);\r\n setCurLevel(1);\r\n };\r\n GameWrapper.prototype.revive = function () {\r\n this._gameView.revive();\r\n };\r\n GameWrapper.prototype.themeChange = function (event) {\r\n this._gameView.themeChange(event.data.resData);\r\n };\r\n return GameWrapper;\r\n }(engine.Container));\n\n function index (props) {\r\n prepareProps();\r\n injectProps(props);\r\n var instance = new GameWrapper();\r\n return instance;\r\n }\r\n //# sourceMappingURL=index.js.map\n\n return index;\n\n})));\n"
}
/**
* Created by renjianfeng on 2020-03-13.
*/
const customId = 'basket';
(async function () {
let customModule = await fetch(`../meta.json`);
customModule = await customModule.json();
console.log(customModule);
await loadAssets(customModule.assets);
launchWithCustomModule(customModule);
})();
function launchWithCustomModule(customModule) {
//engine.registerCustomCodeModule(customModule);
engine.registerCustomModule(customId, window[customId]);
const { props: propsOption, assets } = customModule;
let props = engine.computeProps(customModuleProps, propsOption);
const customModuleIns = {
id: customId,
props,
assets,
};
engine.registerCustomModules([customModuleIns]);
engine.launchWithConfig({
options: {
entrySceneView: 'entry',
},
assets: [],
views: [{
name: 'entry',
type: 'node',
properties: {
x: 0,
y: 0,
}
}],
customs: [],
}, null, function () {
setTimeout(() => {
engine.addCustomModule(customId, engine.gameStage.sceneContainer.getChildAt(0));
}, 100);
// setTimeout(() => {
// engine.globalEvent.dispatchEvent('cloud-game-reset', {
// });
// engine.globalEvent.dispatchEvent('pictures-start', {
// });
// }, 1000);
});
// engine.globalEvent.addEventListener('cloud-time-update', (e) => {
// // console.log(e.type, e.data);
// });
// engine.globalEvent.addEventListener('cloud-game-fail', (e) => {
// console.log(e.type, e.data);
// });
// engine.globalEvent.addEventListener('cloud-game-success', (e) => {
// console.log(e.type, e.data);
// });
// engine.globalEvent.addEventListener('cloud-game-reset', (e) => {
// console.log(e.type, e.data);
// });
}
function getAssetByUUID(uuid) {
return engine.resolveCustomAsset(customId, uuid);
}
function getProps() {
return engine.getProps(customId);
}
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<title>美食从天而降</title>
<meta name="viewport"
content="width=device-width,initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no"/>
<meta name="apple-mobile-web-app-capable" content="yes"/>
<meta name="full-screen" content="true"/>
<meta name="screen-orientation" content="portrait"/>
<meta name="x5-fullscreen" content="true"/>
<meta name="360-fullscreen" content="true"/>
<style>
html,
body {
padding: 0;
margin: 0;
border: 0;
width: 100%;
height: 100%;
overflow: hidden;
position: absolute;
background-color: gray;
}
.game-container{
width: 100%;
height: 100%;
line-height:0;
font-size:0;
}
</style>
</head>
<body>
<div id="game-container" class="game-container"></div>
<!-- <script crossorigin="anonymous" src="//yun.duiba.com.cn/editor/zeroing/libs/engine.1de84ff79dba19e949088de63aa75af51a515e5c.js"></script>
<script crossorigin="anonymous" src="//yun.duiba.com.cn/editor/zeroing/libs/svga.fd3923ae6e664251ca7981801a65809cc5f36bc3.js"></script> -->
<script crossorigin="anonymous" src="//yun.duiba.com.cn/editor/zeroing/libs/engine.cba09e24bd26909e1a67685a889d4799f4c2597a.js"></script>
<script crossorigin="anonymous" src="//yun.duiba.com.cn/editor/zeroing/libs/svga.bbb584f45f3ee647d0611653cb854c5d5bb8fb47.js"></script>
<script src="//yun.duiba.com.cn/js-libs/p2.js/0.7.1/p2.min.js"></script>
<!-- <script src="//yun.duiba.com.cn/editor/zeroing/libs/engine.ebc906f6b50b8da0a669f77027981d5f3cb560ce.js"></script> -->
<!-- <script src="http://localhost:4002/debug/engine.js"></script>
<script src="http://localhost:4003/debug/engine-svga.js"></script> -->
<!--<script src="//yun.duiba.com.cn/editor/zeroing/libs/engine.9a9dbfda4cb2dd5508ecddfe3d95dfd88063f7b5.js"></script>-->
<script src="app.js"></script>
<script src="props.js"></script>
<script src="load-assets.js"></script>
<script src="main.js"></script>
<script>
</script>
</body>
/**
* Created by rockyl on 2020-01-21.
*/
const assets = [
{
"name": "背景",
"url": "//yun.duiba.com.cn/aurora/assets/b7708649be2270379bd764e25ee2e783a7d49f7a.jpg",
"uuid": "a880ee6b-c6d1-4d8f-8734-367f368a1803",
"ext": ".jpg"
},
{
"name": "篮板",
"url": "//yun.duiba.com.cn/aurora/assets/13fd42607d6a79c9a8d0d053962d926fa45fa0c9.png",
"uuid": "a1c6f4d9-8f9a-4267-b701-d2a7e9ff5b1b",
"ext": ".png"
},
{
"name": "球网前",
"url": "//yun.duiba.com.cn/aurora/assets/6c94fab92bc10e8716a4d90666b96d73603b8e59.png",
"uuid": "882618a9-2cc9-498e-a764-268c6cfe6c99",
"ext": ".png"
},
{
"name": "球网后",
"url": "//yun.duiba.com.cn/aurora/assets/2a3596dd0291a20fcee55445752dc38634074c59.png",
"uuid": "0680dba9-757b-443b-8d0f-0d5811254c7d",
"ext": ".png"
},
{
"name": "篮球",
"url": "//yun.duiba.com.cn/aurora/assets/3dc11f2d91659b7e7e1d06a9853cbc9f818e1ea2.png",
"uuid": "270bbac6-b59e-4692-80c9-a95aa0b03c17",
"ext": ".png"
}
];
function loadAssets(customModuleAssets, onProgress, onComplete){
return engine.loadAssets(assets.concat(...customModuleAssets), onProgress, onComplete);
}
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('tslib')) :
typeof define === 'function' && define.amd ? define(['tslib'], factory) :
(global = global || self, global.basket = factory(global.tslib));
}(this, (function (tslib) { 'use strict';
function getTexture(uuid) {
return engine.Texture.from(getAssetByUUID(uuid).uuid);
}
function getTextureByName(name) {
return getTexture(engine.getAssetByName(name).uuid);
}
//# sourceMappingURL=utils.js.map
var BasketBoard = (function (_super) {
tslib.__extends(BasketBoard, _super);
function BasketBoard() {
var _this = _super.call(this) || this;
_this.board = new engine.Sprite(getTextureByName('篮板'));
_this.netFront = new engine.Sprite(getTextureByName('球网前'));
_this.netBack = new engine.Sprite(getTextureByName('球网后'));
_this.config = {
boardBody: {
x: 0,
y: 0,
width: 0.3,
height: 2
},
insidePointBody: {
x: 15,
y: 65,
radius: 0.07
},
outsidePointBody: {
x: 180,
y: 65,
radius: 0.05
},
upSensorBody: {
x: 100,
y: 65,
radius: 0.05
},
downSensorBody: {
x: 100,
y: 65 + 80,
radius: 0.05
}
};
_this.addChild(_this.board);
var shape = new engine.Shape();
shape.beginFill(0xff0000, 0.5);
shape.drawEllipse(50, 150, 200, 80);
shape.endFill();
_this.board.addChild(shape);
return _this;
}
BasketBoard.prototype.setPosition = function (x, y) {
this.x = x;
this.y = y;
};
return BasketBoard;
}(engine.Container));
//# sourceMappingURL=basketBoard.js.map
var GameView = (function (_super) {
tslib.__extends(GameView, _super);
function GameView() {
var _this = _super.call(this) || this;
_this.basketBoard = new BasketBoard();
_this.pool = {};
_this.horizontal = [74, 676];
_this.verticalArea = [200, 600];
_this.verticalInit = 462 - 45;
_this.positionInitBall = {
x: 551,
y: 805,
};
_this.vertical = _this.verticalInit;
_this.isRight = false;
_this.saleX = _this.isRight ? 1 : -1;
_this.config = {
net: {
x: 9.5,
y: 19 + 45,
},
insidePointBody: {
x: 15,
y: 65,
radius: 0.07,
},
outsidePointBody: {
x: 180,
y: 65,
radius: 0.05,
},
boardBody: {
x: 0,
y: 0,
width: 0.3,
height: 2,
},
upSensorBody: {
x: 100,
y: 65,
radius: 0.05,
},
downSensorBody: {
x: 100,
y: 65 + 80,
radius: 0.05,
},
};
_this.toRo = 180 / Math.PI;
_this.loopMark = false;
_this.guideMark = false;
_this.inPointMark = false;
_this.outPointMark = false;
_this.boardMark = false;
_this.pointMark = false;
_this.planeMark = false;
_this.stringMark = "";
_this.ballAddSpeedX = -40;
_this.ballAddSpeedY = -80;
_this.gravity = -5;
_this.stepSpeed = [0.5, 3.5];
_this.detaTimeEf = _this.stepSpeed[1];
_this.ballSpeedLimitX = 3;
_this.planeHeight = 1100;
_this.brokeMark = false;
_this.doubleHit = 0;
_this.timeLimit = window["timeLimit"] ? window["timeLimit"] : 5;
_this.timeMark = false;
_this.timeCount = _this.timeLimit;
_this.timeSpeed = 1 / 60;
_this.clickMark = false;
_this.once(engine.Event.ADDED_TO_STAGE, _this.start, _this);
var p2 = window["p2"];
_this.world = new p2.World();
_this.world.sleepMode = p2.World.BODY_SLEEPING;
_this.world.gravity = [0, 10];
var box = new p2.Box({
width: 20,
height: 200,
material: materialBoard,
});
_this.boxBody = new p2.Body({
mass: 0,
type: p2.Body.STATIC,
position: [20, 400],
});
_this.boxBody.addShape(box);
_this.box = _this.createBox(0, -100, 20, 200);
_this.boxBody.displays = [_this.box];
_this.world.addBody(_this.boxBody);
_this.world.defaultContactMaterial.friction = 0.1;
_this.world.defaultContactMaterial.restitution = 1;
_this.world.setGlobalStiffness(1e5);
var materialBall = new p2.Material(2);
var materialPoint = new p2.Material(2);
var materialBoard = new p2.Material(2);
var materialPlane = new p2.Material(2);
var contactMaterialBallPoint = new p2.ContactMaterial(materialBall, materialPoint, {
friction: 0.3,
restitution: 0.5,
});
var contactMaterialBallBoard = new p2.ContactMaterial(materialBall, materialBoard, {
friction: 0.1,
restitution: 1,
});
var contactMaterialBallPlane = new p2.ContactMaterial(materialBall, materialPlane, {
friction: 0.1,
restitution: 1,
});
_this.world.addContactMaterial(contactMaterialBallPoint);
_this.world.addContactMaterial(contactMaterialBallBoard);
_this.world.addContactMaterial(contactMaterialBallPlane);
var circleShape = new p2.Circle({
radius: 1,
material: materialPoint,
});
var circleBody = _this.circleBody = new p2.Body({
mass: 0,
position: [60, 500],
type: p2.Body.STATIC,
});
circleBody.addShape(circleShape);
_this.world.addBody(circleBody);
var ellipse = _this.createBox(0, 0, 20, 20);
circleBody.displays = [ellipse];
var circleShape1 = new p2.Circle({
radius: 1,
material: materialPoint,
});
var circleBody1 = _this.circleBody1 = new p2.Body({
mass: 0,
position: [200, 500],
type: p2.Body.STATIC,
});
circleBody1.addShape(circleShape1);
_this.world.addBody(circleBody1);
var ellipse2 = _this.createBox(0, 0, 20, 20);
circleBody1.displays = [ellipse2];
var ball = new p2.Circle({ radius: 60 });
var basketball = _this.basketball = new p2.Body({
mass: 1,
position: [300, 250],
velocity: [0, 40],
material: materialBall,
});
_this.basketball.addShape(ball);
_this.world.addBody(_this.basketball);
_this.ball = _this.createCircle();
_this.basketball.displays = [_this.ball];
var stringMark = _this.stringMark;
var self = _this;
var plane = new p2.Plane();
_this.planeBody = new p2.Body({
position: [engine.gameStage.width, engine.gameStage.height - 200],
material: materialPlane,
});
_this.planeBody.angle = Math.PI;
_this.planeBody.addShape(plane);
_this.world.addBody(_this.planeBody);
_this.plane = _this.createPlane();
_this.planeBody.displays = [_this.plane];
_this.world.on('beginContact', function (e) {
if (e.bodyA == circleBody || e.bodyA == circleBody1) {
if (basketball.position[0] > circleBody.position[0] &&
basketball.position[0] < circleBody1.position[0]) {
if (basketball.position[1] > circleBody.position[1] || basketball.position[1] > circleBody1.position[1]) {
console.log("上往下");
self.isRight = !self.isRight;
self.changePosition();
}
}
}
});
_this.addEventListener(engine.Event.ENTER_FRAME, _this.onEnterFrame, _this);
return _this;
}
GameView.prototype.onEnterFrame = function () {
this.world.step(60 / 1000);
var len = this.world.bodies.length;
for (var i = 0; i < len; i++) {
var body = this.world.bodies[i];
var display = body.displays[0];
display.x = body.position[0];
display.y = body.position[1];
display.rotation = (body.angle * 180) / Math.PI;
}
if (this.basketball.position[0] < -120) {
this.basketball.position[0] = 750;
}
if (this.basketball.position[0] > 750 + 120) {
this.basketball.position[0] = -120;
}
};
GameView.prototype.createBox = function (x, y, w, h) {
var sp = new engine.Shape();
sp.beginFill(0x0000ff);
sp.drawRect(x, y, w, h);
sp.endFill();
sp.anchorX = sp.width / 2;
sp.anchorY = sp.height / 2;
this.addChild(sp);
return sp;
};
GameView.prototype.createPlane = function () {
var sp = new engine.Shape();
sp.beginFill(0x0000ff, 1);
sp.drawRect(0, -10, engine.gameStage.width, 10);
sp.endFill();
sp.anchorX = sp.width / 2;
sp.anchorY = sp.height / 2;
this.addChild(sp);
return sp;
};
GameView.prototype.createCircle = function () {
var sp = new engine.Shape();
sp.beginFill(0xff0000, 0.7);
sp.drawCircle(0, 0, 60);
sp.endFill();
sp.anchorX = sp.width / 2;
sp.anchorY = sp.height / 2;
this.addChild(sp);
return sp;
};
GameView.prototype.createEclipse = function () {
var sp = new engine.Shape();
sp.beginFill(0x00ff00, 0.4);
sp.drawEllipse(0, 0, 200, 80);
sp.endFill();
this.addChild(sp);
return sp;
};
GameView.prototype.changePosition = function () {
this.boxBody.position[0] = 740;
this.boxBody.position[1] = 400;
this.circleBody.position[0] = 540;
this.circleBody.position[1] = 400;
this.circleBody1.position[0] = 700;
this.circleBody1.position[1] = 400;
};
GameView.prototype.onMouseDown = function (e) {
var direction = this.isRight ? -1 : 1;
this.basketball.velocity[0] = this.ballAddSpeedX * direction;
this.basketball.velocity[1] = this.ballAddSpeedY;
this.basketball.angularVelocity = -2 * direction;
};
GameView.prototype.addEvent = function () {
this.addEventListener(engine.Event.ENTER_FRAME, (this.onEnterFrameBind = this.onEnterFrame.bind(this)));
};
GameView.prototype.removeEvent = function () {
this.removeEventListener(engine.Event.ENTER_FRAME, this.onEnterFrameBind);
};
GameView.prototype.start = function () {
this.stage.addEventListener(engine.MouseEvent.CLICK, this.onMouseDown, this);
console.log(this.world);
};
GameView.prototype.stop = function () { };
return GameView;
}(engine.Container));
var props = {};
function prepareProps() {
var metaProps = getProps();
engine.injectProp(props, metaProps);
}
function injectProps(p) {
engine.injectProp(props, p);
}
//# sourceMappingURL=props.js.map
var GameWrapper = (function (_super) {
tslib.__extends(GameWrapper, _super);
function GameWrapper() {
var _this = _super.call(this) || this;
engine.globalEvent.addEventListener('game-start', _this.start, _this);
engine.globalEvent.addEventListener('game-stop', _this.stop, _this);
var gameView = _this._gameView = new GameView();
_this.addChild(gameView);
return _this;
}
GameWrapper.prototype.start = function (event) {
injectProps(event.data);
this._gameView.start();
};
GameWrapper.prototype.stop = function (event) {
this._gameView.stop();
};
return GameWrapper;
}(engine.Container));
//# sourceMappingURL=GameWrapper.js.map
function index (props) {
prepareProps();
injectProps(props);
var instance = new GameWrapper();
return instance;
}
//# sourceMappingURL=index.js.map
return index;
})));
//# sourceMappingURL=main.js.map
\ No newline at end of file
{"version":3,"file":"index.js","sources":["src/custom/basket/src/game/utils.ts","src/custom/basket/src/game/basketBoard.ts","src/custom/basket/src/game/GameView.ts","src/custom/basket/src/props.ts","src/custom/basket/src/game/GameWrapper.ts","src/custom/basket/src/index.ts"],"sourcesContent":["/**\r\n * Created by rockyl on 2020-01-21.\r\n */\r\n\r\nexport function getTexture(uuid) {\r\n\treturn engine.Texture.from(getAssetByUUID(uuid).uuid);\r\n}\r\n\r\nexport function getTextureByName(name) {\r\n\treturn getTexture(engine.getAssetByName(name).uuid);\r\n}\r\n\r\nexport function playSound(name) {\r\n\tengine.playSound(engine.getAssetByName(name).uuid, {keep: true});\r\n}\r\nexport function createSvga(name, anchorName?) {\r\n\tlet inst = new svga.Svga();\r\n\tinst.source = 'asset://' + engine.getAssetByName(name).uuid;\r\n\treturn inst;\r\n}\r\n\r\n\r\n\r\nexport function getIndexFromRC(row,col,maxCol){\r\n\tlet index;\r\n\tindex = row * maxCol + col ;\r\n\treturn index\r\n}\r\n\r\n\r\n\r\n\r\nexport function getRandomArray(array){\r\n\tarray.sort(function() {\r\n\t\treturn .5 - Math.random();\r\n\t});\r\n}","import {getTextureByName} from './utils'\r\n\r\nexport default class BasketBoard extends engine.Container{\r\n board:engine.Sprite = new engine.Sprite(getTextureByName('篮板'));\r\n netFront:engine.Sprite = new engine.Sprite(getTextureByName('球网前'));\r\n netBack:engine.Sprite = new engine.Sprite(getTextureByName('球网后'));\r\n\r\n // 篮筐传感,圆环\r\n private config = {\r\n boardBody:{\r\n x:0,\r\n y:0,\r\n width:0.3,\r\n height:2\r\n },\r\n insidePointBody: {\r\n x: 15,\r\n y: 65,\r\n radius: 0.07\r\n },\r\n outsidePointBody: {\r\n x: 180,\r\n y: 65,\r\n radius: 0.05\r\n },\r\n upSensorBody: {\r\n x: 100,\r\n y: 65,\r\n radius: 0.05\r\n },\r\n downSensorBody: {\r\n x: 100,\r\n y: 65 + 80,\r\n radius: 0.05\r\n }\r\n }\r\n\r\n \r\n\r\n constructor(){\r\n super();\r\n this.addChild(this.board);\r\n\r\n // 椭圆\r\n let shape = new engine.Shape();\r\n shape.beginFill(0xff0000,0.5);\r\n shape.drawEllipse(50,150,200,80);\r\n shape.endFill();\r\n\r\n this.board.addChild(shape)\r\n\r\n\r\n \r\n }\r\n\r\n setPosition(x,y){\r\n this.x = x;\r\n this.y = y;\r\n }\r\n\r\n}","import { getTextureByName, getTexture } from \"./utils\";\r\nimport BasketBoard from \"./basketBoard\";\r\nimport Basketball from \"./Basketball\";\r\nexport default class GameView extends engine.Container {\r\n private world: p2.World;\r\n private boxBody: p2.Body;\r\n private planeBody: p2.Body;\r\n private basketball: p2.Body;\r\n private ball: engine.Sprite;\r\n private plane: engine.Sprite;\r\n private box: engine.Sprite;\r\n\r\n private circleBody:p2.Body;\r\n private circleBody1:p2.Body;\r\n\r\n basketBoard: BasketBoard = new BasketBoard();\r\n\r\n private pool = {};\r\n private horizontal = [74, 676]; //二值\r\n private verticalArea = [200, 600]; //范围\r\n\r\n private verticalInit = 462 - 45;\r\n private positionInitBall = {\r\n x: 551,\r\n y: 805,\r\n };\r\n private vertical = this.verticalInit;\r\n private isRight = false;\r\n private saleX = this.isRight ? 1 : -1;\r\n\r\n private config = {\r\n net: {\r\n x: 9.5,\r\n y: 19 + 45,\r\n },\r\n insidePointBody: {\r\n x: 15,\r\n y: 65,\r\n radius: 0.07,\r\n },\r\n outsidePointBody: {\r\n x: 180,\r\n y: 65,\r\n radius: 0.05,\r\n },\r\n boardBody: {\r\n x: 0,\r\n y: 0,\r\n // length: 2,\r\n // radius: 0.1,\r\n width: 0.3,\r\n height: 2,\r\n },\r\n upSensorBody: {\r\n x: 100,\r\n y: 65,\r\n radius: 0.05,\r\n },\r\n downSensorBody: {\r\n x: 100,\r\n y: 65 + 80,\r\n radius: 0.05,\r\n },\r\n };\r\n private onEnterFrameBind: Function;\r\n\r\n private view;\r\n // private basketball;\r\n private direction;\r\n private toRo = 180 / Math.PI;\r\n private loopMark = false;\r\n private guideMark = false;\r\n\r\n //碰撞标志位\r\n private inPointMark = false;\r\n private outPointMark = false;\r\n private boardMark = false;\r\n private pointMark = false;\r\n private planeMark = false;\r\n private stringMark = \"\";\r\n\r\n private ballAddSpeedX = -40;\r\n private ballAddSpeedY = -80;\r\n private gravity = -5;\r\n private stepSpeed = [0.5, 3.5]; //3.5正常速度,2慢速播放\r\n private detaTimeEf = this.stepSpeed[1];\r\n private ballSpeedLimitX = 3;\r\n private planeHeight = 1100;\r\n\r\n private brokeMark = false;\r\n private doubleHit = 0;\r\n private timeLimit = window[\"timeLimit\"] ? window[\"timeLimit\"] : 5;\r\n private timeMark = false;\r\n private timeCount = this.timeLimit;\r\n private timeSpeed = 1 / 60;\r\n\r\n private clickMark = false;\r\n\r\n constructor() {\r\n super();\r\n this.once(engine.Event.ADDED_TO_STAGE, this.start, this);\r\n\r\n var p2 = window[\"p2\"];\r\n\r\n this.world = new p2.World();\r\n this.world.sleepMode = p2.World.BODY_SLEEPING;\r\n\r\n this.world.gravity = [0, 10];\r\n // this.world.gravity = [0,-5];\r\n //创建box\r\n var box: p2.Box = new p2.Box({\r\n width: 20,\r\n height: 200,\r\n material: materialBoard,\r\n });\r\n // var box:p2.Box = new p2.Box({width:this.config.boardBody.width, height:this.config.boardBody.height,material:materialBoard});\r\n // this.boxBody = new p2.Body({mass:10, angularVelocity:1, position:[200,200]});\r\n\r\n this.boxBody = new p2.Body({\r\n mass: 0,\r\n type: p2.Body.STATIC,\r\n position: [20, 400],\r\n });\r\n this.boxBody.addShape(box);\r\n // 添加图片\r\n this.box = this.createBox(0, -100, 20, 200);\r\n this.boxBody.displays = [this.box];\r\n\r\n // let display = new engine.Texture(getTextureByName('篮板'));\r\n // let displays = new engine.Sprite(display)\r\n // this.addChild(displays)\r\n // this.boxBody.displays = [displays];\r\n\r\n this.world.addBody(this.boxBody);\r\n // 设置摩擦和回弹系数\r\n this.world.defaultContactMaterial.friction = 0.1;\r\n this.world.defaultContactMaterial.restitution = 1;\r\n this.world.setGlobalStiffness(1e5);\r\n\r\n // material\r\n var materialBall = new p2.Material(2); //参数id:number\r\n var materialPoint = new p2.Material(2);\r\n var materialBoard = new p2.Material(2);\r\n var materialPlane = new p2.Material(2);\r\n\r\n // 不同material碰撞系数\r\n var contactMaterialBallPoint = new p2.ContactMaterial(\r\n materialBall,\r\n materialPoint,\r\n {\r\n friction: 0.3,\r\n restitution: 0.5,\r\n }\r\n );\r\n var contactMaterialBallBoard = new p2.ContactMaterial(\r\n materialBall,\r\n materialBoard,\r\n {\r\n friction: 0.1,\r\n restitution: 1,\r\n }\r\n );\r\n var contactMaterialBallPlane = new p2.ContactMaterial(\r\n materialBall,\r\n materialPlane,\r\n {\r\n friction: 0.1,\r\n restitution: 1,\r\n }\r\n );\r\n this.world.addContactMaterial(contactMaterialBallPoint);\r\n this.world.addContactMaterial(contactMaterialBallBoard);\r\n this.world.addContactMaterial(contactMaterialBallPlane);\r\n\r\n // 框点\r\n var circleShape = new p2.Circle({\r\n // radius: this.config.outsidePointBody.radius,\r\n radius: 1,\r\n material: materialPoint,\r\n });\r\n var circleBody = this.circleBody = new p2.Body({\r\n mass: 0,\r\n // position: [5.65, -5.5],\r\n position: [60, 500],\r\n type: p2.Body.STATIC,\r\n });\r\n circleBody.addShape(circleShape);\r\n this.world.addBody(circleBody);\r\n var ellipse = this.createBox(0, 0, 20, 20);\r\n circleBody.displays = [ellipse];\r\n\r\n var circleShape1 = new p2.Circle({\r\n // radius: this.config.insidePointBody.radius,\r\n radius: 1,\r\n material: materialPoint,\r\n });\r\n var circleBody1 = this.circleBody1 = new p2.Body({\r\n mass: 0,\r\n // position: [5.65, -5.5],\r\n position: [200, 500],\r\n type: p2.Body.STATIC,\r\n });\r\n circleBody1.addShape(circleShape1);\r\n this.world.addBody(circleBody1);\r\n var ellipse2 = this.createBox(0, 0, 20, 20);\r\n circleBody1.displays = [ellipse2];\r\n\r\n // 球体\r\n var ball = new p2.Circle({ radius: 60 });\r\n var basketball = this.basketball = new p2.Body({\r\n mass: 1,\r\n position: [300, 250],\r\n velocity: [0, 40],\r\n // type:p2.Body.DYNAMIC,\r\n material: materialBall,\r\n });\r\n this.basketball.addShape(ball);\r\n this.world.addBody(this.basketball);\r\n\r\n this.ball = this.createCircle();\r\n this.basketball.displays = [this.ball];\r\n\r\n // let balldisplay = new engine.Texture(getTextureByName('篮球'));\r\n // let balldisplays = new engine.Sprite(balldisplay);\r\n // balldisplays.width = 120;\r\n // balldisplays.height = 120\r\n // this.addChild(balldisplays)\r\n // this.basketball.displays = [balldisplays];\r\n\r\n //进球感应区域\r\n // var sensorShape = new p2.Circle({\r\n // radius: this.config.upSensorBody.radius\r\n // });\r\n // sensorShape.sensor = true;\r\n // var sensorBody = new p2.Body({\r\n // position: [this.config.upSensorBody.x, this.config.upSensorBody.y]\r\n // });\r\n // sensorBody.damping = 0;\r\n // sensorBody.addShape(sensorShape);\r\n // this.world.addBody(sensorBody);\r\n\r\n // var sensorShape1 = new p2.Circle({\r\n // radius: this.config.downSensorBody.radius\r\n // });\r\n // sensorShape1.sensor = true;\r\n // var sensorBody1 = new p2.Body({\r\n // position: [this.config.downSensorBody.x, this.config.downSensorBody.y]\r\n // });\r\n // sensorBody1.damping = 0;\r\n // sensorBody1.addShape(sensorShape1);\r\n // this.world.addBody(sensorBody1);\r\n\r\n //contactPointA 相对于bodyA的碰撞点位置,\r\n //contactPointB 相对于bodyB的碰撞点位置,\r\n\r\n let stringMark = this.stringMark;\r\n let self = this;\r\n let boardMarkSetTime;\r\n let pointMarkSetTime;\r\n\r\n //创建plane Plane shape class. The plane is facing in the Y direction.\r\n var plane: p2.Plane = new p2.Plane();\r\n this.planeBody = new p2.Body({\r\n position: [engine.gameStage.width, engine.gameStage.height - 200],\r\n material: materialPlane,\r\n }); //GameConst.stage保存全局静态变量stage\r\n this.planeBody.angle = Math.PI;\r\n\r\n this.planeBody.addShape(plane);\r\n\r\n this.world.addBody(this.planeBody);\r\n this.plane = this.createPlane();\r\n this.planeBody.displays = [this.plane];\r\n\r\n // 碰撞\r\n this.world.on('beginContact',function(e){\r\n // let direction = self.isRight ? 1 : -1;\r\n \r\n if(e.bodyA == circleBody || e.bodyA == circleBody1){\r\n if (\r\n basketball.position[0] > circleBody.position[0] &&\r\n basketball.position[0] < circleBody1.position[0]\r\n ) {\r\n if (basketball.position[1] > circleBody.position[1] || basketball.position[1] > circleBody1.position[1]) {\r\n console.log(\"上往下\");\r\n self.isRight = !self.isRight;\r\n // 移动刚体\r\n self.changePosition()\r\n }\r\n }\r\n }\r\n \r\n\r\n })\r\n\r\n //每帧更新\r\n this.addEventListener(\r\n engine.Event.ENTER_FRAME,\r\n this.onEnterFrame,\r\n this\r\n );\r\n }\r\n\r\n private onEnterFrame() {\r\n // this.basketball.position[0] = this.basketball.interpolatedPosition[0] * 100;\r\n // this.basketball.position[1] = -this.basketball.interpolatedPosition[1] * 100;\r\n // this.basketball.rotation = -this.basketball.interpolatedAngle * this.toRo;\r\n\r\n //更新物理世界\r\n this.world.step(60 / 1000);\r\n var len: number = this.world.bodies.length;\r\n for (var i: number = 0; i < len; i++) {\r\n var body: p2.Body = this.world.bodies[i];\r\n var display: engine.DisplayObject = body.displays[0];\r\n display.x = body.position[0]; //同步刚体和egret显示对象的位置和旋转角度\r\n display.y = body.position[1];\r\n display.rotation = (body.angle * 180) / Math.PI;\r\n }\r\n\r\n if (this.basketball.position[0] < -120) {\r\n this.basketball.position[0] = 750;\r\n }\r\n if (this.basketball.position[0] > 750 + 120) {\r\n this.basketball.position[0] = - 120;\r\n }\r\n\r\n }\r\n private createBox(x, y, w, h) {\r\n // var sp:engine.Sprite = new engine.Sprite();\r\n var sp = new engine.Shape();\r\n sp.beginFill(0x0000ff);\r\n sp.drawRect(x, y, w, h);\r\n sp.endFill();\r\n sp.anchorX = sp.width / 2;\r\n sp.anchorY = sp.height / 2;\r\n this.addChild(sp);\r\n return sp;\r\n }\r\n private createPlane() {\r\n // var sp:engine.Sprite = new engine.Sprite();\r\n var sp = new engine.Shape();\r\n // sp.lineStyle(10, 0x00ff00);\r\n sp.beginFill(0x0000ff, 1);\r\n // sp.moveTo(0, 0);\r\n // sp.lineTo(engine.gameStage.width,0);\r\n sp.drawRect(0, -10, engine.gameStage.width, 10);\r\n sp.endFill();\r\n sp.anchorX = sp.width / 2;\r\n sp.anchorY = sp.height / 2;\r\n this.addChild(sp);\r\n return sp;\r\n }\r\n\r\n private createCircle() {\r\n var sp = new engine.Shape();\r\n sp.beginFill(0xff0000, 0.7);\r\n sp.drawCircle(0, 0, 60);\r\n sp.endFill();\r\n sp.anchorX = sp.width / 2;\r\n sp.anchorY = sp.height / 2;\r\n this.addChild(sp);\r\n return sp;\r\n }\r\n\r\n private createEclipse() {\r\n var sp = new engine.Shape();\r\n sp.beginFill(0x00ff00, 0.4);\r\n sp.drawEllipse(0, 0, 200, 80);\r\n sp.endFill();\r\n this.addChild(sp);\r\n return sp;\r\n }\r\n\r\n changePosition(){\r\n this.boxBody.position[0] = 740;\r\n this.boxBody.position[1] = 400;\r\n\r\n this.circleBody.position[0] = 540;\r\n this.circleBody.position[1] = 400;\r\n this.circleBody1.position[0] = 700;\r\n this.circleBody1.position[1] = 400;\r\n\r\n }\r\n\r\n onMouseDown(e: engine.MouseEvent) {\r\n var direction = this.isRight ? -1 : 1;\r\n this.basketball.velocity[0] = this.ballAddSpeedX * direction;\r\n this.basketball.velocity[1] = this.ballAddSpeedY;\r\n this.basketball.angularVelocity = -2 * direction;\r\n }\r\n\r\n addEvent() {\r\n this.addEventListener(\r\n engine.Event.ENTER_FRAME,\r\n (this.onEnterFrameBind = this.onEnterFrame.bind(this))\r\n );\r\n }\r\n removeEvent() {\r\n this.removeEventListener(\r\n engine.Event.ENTER_FRAME,\r\n this.onEnterFrameBind\r\n );\r\n }\r\n\r\n start() {\r\n // let gameBg = new engine.Sprite(\r\n // getTexture(\"a880ee6b-c6d1-4d8f-8734-367f368a1803\")\r\n // );\r\n // this.addChild(gameBg);\r\n\r\n this.stage.addEventListener(\r\n engine.MouseEvent.CLICK,\r\n this.onMouseDown,\r\n this\r\n );\r\n\r\n console.log(this.world);\r\n\r\n // this.basketBoard.setPosition(0,100);\r\n // this.addChild(this.basketBoard)\r\n // console.log('1')\r\n\r\n // this.basketball.initPos(400,200);\r\n // this.addChild(this.basketball);\r\n }\r\n\r\n stop() {}\r\n}\r\n","\r\n\r\nexport let props: any = {};\r\n\r\nexport function prepareProps() {\r\n\tlet metaProps = getProps();\r\n\r\n\tengine.injectProp(props, metaProps);\r\n}\r\n\r\nexport function injectProps(p) {\r\n\tengine.injectProp(props, p);\r\n}\r\n","\r\nimport GameView from \"./GameView\";\r\n\r\nimport { injectProps } from \"../props\";\r\n\r\n\r\nexport class GameWrapper extends engine.Container {\r\n\t// private _status;\r\n\tprivate _gameView: GameView;\r\n\r\n\tconstructor() {\r\n\t\tsuper();\r\n\r\n\t\tengine.globalEvent.addEventListener('game-start', this.start, this);\r\n\t\tengine.globalEvent.addEventListener('game-stop', this.stop, this);\r\n\r\n\t\t//创建实例\r\n\t\tlet gameView = this._gameView = new GameView();\r\n\t\tthis.addChild(gameView);\r\n\r\n\t}\r\n\r\n\tstart(event: engine.Event) {\r\n\t\tinjectProps(event.data);\r\n\r\n\t\t// this._status = 1;\r\n\r\n\t\tthis._gameView.start();\r\n\t}\r\n\tstop(event: engine.Event) {\r\n\t\t\r\n\t\tthis._gameView.stop();\r\n\t}\r\n\r\n\t// reset(event:engine.Event){\r\n\t// \tthis._gameView.reset();\r\n\t// }\r\n}\r\n","\r\n\r\nimport {GameWrapper} from \"./game/GameWrapper\";\r\nimport {injectProps, prepareProps} from \"./props\";\r\n\r\nexport default function (props) {\r\n\tprepareProps();\r\n\tinjectProps(props);\r\n\r\n\tlet instance = new GameWrapper();\r\n\t\r\n\treturn instance;\r\n}\r\n"],"names":["__extends"],"mappings":";;;;;;UAIgB,UAAU,CAAC,IAAI;KAC9B,OAAO,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;CACvD,CAAC;UAEe,gBAAgB,CAAC,IAAI;KACpC,OAAO,UAAU,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;CACrD,CAAC;;;CCRD;KAAyCA,qCAAgB;KAqCrD;SAAA,YACI,iBAAO,SAaV;SAlDD,WAAK,GAAiB,IAAI,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC;SAChE,cAAQ,GAAiB,IAAI,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC,CAAC;SACpE,aAAO,GAAiB,IA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IAAI,QAAQ,GAAG,KAAI,CAAC,SAAS,GAAG,IAAI,QAAQ,EAAE,CAAC;SAC/C,KAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;;MAExB;KAED,2BAAK,GAAL,UAAM,KAAmB;SACxB,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;SAIxB,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;MACvB;KACD,0BAAI,GAAJ,UAAK,KAAmB;SAEvB,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;MACtB;KAKF,kBAAC;CAAD,CAAC,CA/BgC,MAAM,CAAC,SAAS,GA+BhD;;;iBChCwB,KAAK;KAC7B,YAAY,EAAE,CAAC;KACf,WAAW,CAAC,KAAK,CAAC,CAAC;KAEnB,IAAI,QAAQ,GAAG,IAAI,WAAW,EAAE,CAAC;KAEjC,OAAO,QAAQ,CAAC;CACjB,CAAC;;;;;;;;;"}
\ No newline at end of file
/**
* Created by rockyl on 2020-01-21.
*/
let customModuleProps = {
};
{
"name": "拼图",
"desc": "拼图模块1.0",
"props": {
"OFFSET_X": {
"alias": "OFFSET_X",
"type": "number",
"default": 0
},
"OFFSET_Y": {
"alias": "OFFSET_Y",
"type": "number",
"default": 0
},
"GAME_TIME": {
"alias": "游戏时间",
"type": "number",
"default": 20
},
"moistPercent": {
"alias": "湿润度",
"type": "number",
"default": 0
}
},
"assets": [
{
"name": "背景",
"url": "//yun.duiba.com.cn/aurora/assets/b7708649be2270379bd764e25ee2e783a7d49f7a.jpg",
"uuid": "a880ee6b-c6d1-4d8f-8734-367f368a1803",
"ext": ".jpg"
},
{
"name": "篮板",
"url": "//yun.duiba.com.cn/aurora/assets/13fd42607d6a79c9a8d0d053962d926fa45fa0c9.png",
"uuid": "a1c6f4d9-8f9a-4267-b701-d2a7e9ff5b1b",
"ext": ".png"
},
{
"name": "球网前",
"url": "//yun.duiba.com.cn/aurora/assets/6c94fab92bc10e8716a4d90666b96d73603b8e59.png",
"uuid": "882618a9-2cc9-498e-a764-268c6cfe6c99",
"ext": ".png"
},
{
"name": "球网后",
"url": "//yun.duiba.com.cn/aurora/assets/2a3596dd0291a20fcee55445752dc38634074c59.png",
"uuid": "0680dba9-757b-443b-8d0f-0d5811254c7d",
"ext": ".png"
},
{
"name": "篮球",
"url": "//yun.duiba.com.cn/aurora/assets/3dc11f2d91659b7e7e1d06a9853cbc9f818e1ea2.png",
"uuid": "270bbac6-b59e-4692-80c9-a95aa0b03c17",
"ext": ".png"
}
],
"events": {
"in": {
"game-reset":{
"alias": "重置"
},
"game-start": {
"alias": "开始",
"data": {
"picUrl":"图片路径",
"blockUrl":"blockUrl",
"GAME_TIME":"每局的游戏时间",
"MAX_ROW":"行",
"MAX_COL":"列",
"W":"宽",
"H":"高",
"GAP":"图片间隙",
"OFFSET_X":"OFFSET_X",
"OFFSET_Y":"OFFSET_Y"
}
},
"game-stop": {
"alias": "停止"
}
},
"out": {
"cloud-time-update": {
"alias": "倒计时更新",
"data": {
"time":"剩余时间"
}
},
"cloud-game-fail": {
"alias": "游戏结束",
"data": {
"reason": "结束原因(1:时间到了)"
}
},
"cloud-game-success": {
"alias": "游戏成功",
"data": {
"time": "游戏消耗时间"
}
}
}
}
}
\ No newline at end of file
import {getTextureByName} from './utils'
export default class BasketBoard extends engine.Container{
board:engine.Sprite = new engine.Sprite(getTextureByName('篮板'));
netFront:engine.Sprite = new engine.Sprite(getTextureByName('球网前'));
netBack:engine.Sprite = new engine.Sprite(getTextureByName('球网后'));
// 篮筐传感,圆环
private config = {
boardBody:{
x:0,
y:0,
width:0.3,
height:2
},
insidePointBody: {
x: 15,
y: 65,
radius: 0.07
},
outsidePointBody: {
x: 180,
y: 65,
radius: 0.05
},
upSensorBody: {
x: 100,
y: 65,
radius: 0.05
},
downSensorBody: {
x: 100,
y: 65 + 80,
radius: 0.05
}
}
constructor(){
super();
this.addChild(this.board);
// 椭圆
let shape = new engine.Shape();
shape.beginFill(0xff0000,0.5);
shape.drawEllipse(50,150,200,80);
shape.endFill();
this.board.addChild(shape)
}
setPosition(x,y){
this.x = x;
this.y = y;
}
}
\ No newline at end of file
export default class Basketball extends engine.Container{
ball:engine.Shape
gravity = -5;
constructor(){
super()
this.ball = new engine.Shape();
this.ball.beginFill(0x0000ff,0.7);
this.ball.drawCircle(0,0,60);
this.ball.endFill();
this.addChild(this.ball);
}
initPos(x,y){
this.x = x;
this.y = y;
}
updatePos(){
}
}
\ No newline at end of file
import { getTextureByName, getTexture } from "./utils";
import BasketBoard from "./basketBoard";
import Basketball from "./Basketball";
export default class GameView extends engine.Container {
private world: p2.World;
private boxBody: p2.Body;
private planeBody: p2.Body;
private basketball: p2.Body;
private ball: engine.Sprite;
private plane: engine.Sprite;
private box: engine.Sprite;
private circleBody:p2.Body;
private circleBody1:p2.Body;
basketBoard: BasketBoard = new BasketBoard();
private pool = {};
private horizontal = [74, 676]; //二值
private verticalArea = [200, 600]; //范围
private verticalInit = 462 - 45;
private positionInitBall = {
x: 551,
y: 805,
};
private vertical = this.verticalInit;
private isRight = false;
private saleX = this.isRight ? 1 : -1;
private config = {
net: {
x: 9.5,
y: 19 + 45,
},
insidePointBody: {
x: 15,
y: 65,
radius: 0.07,
},
outsidePointBody: {
x: 180,
y: 65,
radius: 0.05,
},
boardBody: {
x: 0,
y: 0,
// length: 2,
// radius: 0.1,
width: 0.3,
height: 2,
},
upSensorBody: {
x: 100,
y: 65,
radius: 0.05,
},
downSensorBody: {
x: 100,
y: 65 + 80,
radius: 0.05,
},
};
private onEnterFrameBind: Function;
private view;
// private basketball;
private direction;
private toRo = 180 / Math.PI;
private loopMark = false;
private guideMark = false;
//碰撞标志位
private inPointMark = false;
private outPointMark = false;
private boardMark = false;
private pointMark = false;
private planeMark = false;
private stringMark = "";
private ballAddSpeedX = -40;
private ballAddSpeedY = -80;
private gravity = -5;
private stepSpeed = [0.5, 3.5]; //3.5正常速度,2慢速播放
private detaTimeEf = this.stepSpeed[1];
private ballSpeedLimitX = 3;
private planeHeight = 1100;
private brokeMark = false;
private doubleHit = 0;
private timeLimit = window["timeLimit"] ? window["timeLimit"] : 5;
private timeMark = false;
private timeCount = this.timeLimit;
private timeSpeed = 1 / 60;
private clickMark = false;
constructor() {
super();
this.once(engine.Event.ADDED_TO_STAGE, this.start, this);
var p2 = window["p2"];
this.world = new p2.World();
this.world.sleepMode = p2.World.BODY_SLEEPING;
this.world.gravity = [0, 10];
// this.world.gravity = [0,-5];
//创建box
var box: p2.Box = new p2.Box({
width: 20,
height: 200,
material: materialBoard,
});
// var box:p2.Box = new p2.Box({width:this.config.boardBody.width, height:this.config.boardBody.height,material:materialBoard});
// this.boxBody = new p2.Body({mass:10, angularVelocity:1, position:[200,200]});
this.boxBody = new p2.Body({
mass: 0,
type: p2.Body.STATIC,
position: [20, 400],
});
this.boxBody.addShape(box);
// 添加图片
this.box = this.createBox(0, -100, 20, 200);
this.boxBody.displays = [this.box];
// let display = new engine.Texture(getTextureByName('篮板'));
// let displays = new engine.Sprite(display)
// this.addChild(displays)
// this.boxBody.displays = [displays];
this.world.addBody(this.boxBody);
// 设置摩擦和回弹系数
this.world.defaultContactMaterial.friction = 0.1;
this.world.defaultContactMaterial.restitution = 1;
this.world.setGlobalStiffness(1e5);
// material
var materialBall = new p2.Material(2); //参数id:number
var materialPoint = new p2.Material(2);
var materialBoard = new p2.Material(2);
var materialPlane = new p2.Material(2);
// 不同material碰撞系数
var contactMaterialBallPoint = new p2.ContactMaterial(
materialBall,
materialPoint,
{
friction: 0.3,
restitution: 0.5,
}
);
var contactMaterialBallBoard = new p2.ContactMaterial(
materialBall,
materialBoard,
{
friction: 0.1,
restitution: 1,
}
);
var contactMaterialBallPlane = new p2.ContactMaterial(
materialBall,
materialPlane,
{
friction: 0.1,
restitution: 1,
}
);
this.world.addContactMaterial(contactMaterialBallPoint);
this.world.addContactMaterial(contactMaterialBallBoard);
this.world.addContactMaterial(contactMaterialBallPlane);
// 框点
var circleShape = new p2.Circle({
// radius: this.config.outsidePointBody.radius,
radius: 1,
material: materialPoint,
});
var circleBody = this.circleBody = new p2.Body({
mass: 0,
// position: [5.65, -5.5],
position: [60, 500],
type: p2.Body.STATIC,
});
circleBody.addShape(circleShape);
this.world.addBody(circleBody);
var ellipse = this.createBox(0, 0, 20, 20);
circleBody.displays = [ellipse];
var circleShape1 = new p2.Circle({
// radius: this.config.insidePointBody.radius,
radius: 1,
material: materialPoint,
});
var circleBody1 = this.circleBody1 = new p2.Body({
mass: 0,
// position: [5.65, -5.5],
position: [200, 500],
type: p2.Body.STATIC,
});
circleBody1.addShape(circleShape1);
this.world.addBody(circleBody1);
var ellipse2 = this.createBox(0, 0, 20, 20);
circleBody1.displays = [ellipse2];
// 球体
var ball = new p2.Circle({ radius: 60 });
var basketball = this.basketball = new p2.Body({
mass: 1,
position: [300, 250],
velocity: [0, 40],
// type:p2.Body.DYNAMIC,
material: materialBall,
});
this.basketball.addShape(ball);
this.world.addBody(this.basketball);
this.ball = this.createCircle();
this.basketball.displays = [this.ball];
// let balldisplay = new engine.Texture(getTextureByName('篮球'));
// let balldisplays = new engine.Sprite(balldisplay);
// balldisplays.width = 120;
// balldisplays.height = 120
// this.addChild(balldisplays)
// this.basketball.displays = [balldisplays];
//进球感应区域
// var sensorShape = new p2.Circle({
// radius: this.config.upSensorBody.radius
// });
// sensorShape.sensor = true;
// var sensorBody = new p2.Body({
// position: [this.config.upSensorBody.x, this.config.upSensorBody.y]
// });
// sensorBody.damping = 0;
// sensorBody.addShape(sensorShape);
// this.world.addBody(sensorBody);
// var sensorShape1 = new p2.Circle({
// radius: this.config.downSensorBody.radius
// });
// sensorShape1.sensor = true;
// var sensorBody1 = new p2.Body({
// position: [this.config.downSensorBody.x, this.config.downSensorBody.y]
// });
// sensorBody1.damping = 0;
// sensorBody1.addShape(sensorShape1);
// this.world.addBody(sensorBody1);
//contactPointA 相对于bodyA的碰撞点位置,
//contactPointB 相对于bodyB的碰撞点位置,
let stringMark = this.stringMark;
let self = this;
let boardMarkSetTime;
let pointMarkSetTime;
//创建plane Plane shape class. The plane is facing in the Y direction.
var plane: p2.Plane = new p2.Plane();
this.planeBody = new p2.Body({
position: [engine.gameStage.width, engine.gameStage.height - 200],
material: materialPlane,
}); //GameConst.stage保存全局静态变量stage
this.planeBody.angle = Math.PI;
this.planeBody.addShape(plane);
this.world.addBody(this.planeBody);
this.plane = this.createPlane();
this.planeBody.displays = [this.plane];
// 碰撞
this.world.on('beginContact',function(e){
// let direction = self.isRight ? 1 : -1;
if(e.bodyA == circleBody || e.bodyA == circleBody1){
if (
basketball.position[0] > circleBody.position[0] &&
basketball.position[0] < circleBody1.position[0]
) {
if (basketball.position[1] > circleBody.position[1] || basketball.position[1] > circleBody1.position[1]) {
console.log("上往下");
self.isRight = !self.isRight;
// 移动刚体
self.changePosition()
}
}
}
})
//每帧更新
this.addEventListener(
engine.Event.ENTER_FRAME,
this.onEnterFrame,
this
);
}
private onEnterFrame() {
// this.basketball.position[0] = this.basketball.interpolatedPosition[0] * 100;
// this.basketball.position[1] = -this.basketball.interpolatedPosition[1] * 100;
// this.basketball.rotation = -this.basketball.interpolatedAngle * this.toRo;
//更新物理世界
this.world.step(60 / 1000);
var len: number = this.world.bodies.length;
for (var i: number = 0; i < len; i++) {
var body: p2.Body = this.world.bodies[i];
var display: engine.DisplayObject = body.displays[0];
display.x = body.position[0]; //同步刚体和egret显示对象的位置和旋转角度
display.y = body.position[1];
display.rotation = (body.angle * 180) / Math.PI;
}
if (this.basketball.position[0] < -120) {
this.basketball.position[0] = 750;
}
if (this.basketball.position[0] > 750 + 120) {
this.basketball.position[0] = - 120;
}
}
private createBox(x, y, w, h) {
// var sp:engine.Sprite = new engine.Sprite();
var sp = new engine.Shape();
sp.beginFill(0x0000ff);
sp.drawRect(x, y, w, h);
sp.endFill();
sp.anchorX = sp.width / 2;
sp.anchorY = sp.height / 2;
this.addChild(sp);
return sp;
}
private createPlane() {
// var sp:engine.Sprite = new engine.Sprite();
var sp = new engine.Shape();
// sp.lineStyle(10, 0x00ff00);
sp.beginFill(0x0000ff, 1);
// sp.moveTo(0, 0);
// sp.lineTo(engine.gameStage.width,0);
sp.drawRect(0, -10, engine.gameStage.width, 10);
sp.endFill();
sp.anchorX = sp.width / 2;
sp.anchorY = sp.height / 2;
this.addChild(sp);
return sp;
}
private createCircle() {
var sp = new engine.Shape();
sp.beginFill(0xff0000, 0.7);
sp.drawCircle(0, 0, 60);
sp.endFill();
sp.anchorX = sp.width / 2;
sp.anchorY = sp.height / 2;
this.addChild(sp);
return sp;
}
private createEclipse() {
var sp = new engine.Shape();
sp.beginFill(0x00ff00, 0.4);
sp.drawEllipse(0, 0, 200, 80);
sp.endFill();
this.addChild(sp);
return sp;
}
changePosition(){
this.boxBody.position[0] = 740;
this.boxBody.position[1] = 400;
this.circleBody.position[0] = 540;
this.circleBody.position[1] = 400;
this.circleBody1.position[0] = 700;
this.circleBody1.position[1] = 400;
}
onMouseDown(e: engine.MouseEvent) {
var direction = this.isRight ? -1 : 1;
this.basketball.velocity[0] = this.ballAddSpeedX * direction;
this.basketball.velocity[1] = this.ballAddSpeedY;
this.basketball.angularVelocity = -2 * direction;
}
addEvent() {
this.addEventListener(
engine.Event.ENTER_FRAME,
(this.onEnterFrameBind = this.onEnterFrame.bind(this))
);
}
removeEvent() {
this.removeEventListener(
engine.Event.ENTER_FRAME,
this.onEnterFrameBind
);
}
start() {
// let gameBg = new engine.Sprite(
// getTexture("a880ee6b-c6d1-4d8f-8734-367f368a1803")
// );
// this.addChild(gameBg);
this.stage.addEventListener(
engine.MouseEvent.CLICK,
this.onMouseDown,
this
);
console.log(this.world);
// this.basketBoard.setPosition(0,100);
// this.addChild(this.basketBoard)
// console.log('1')
// this.basketball.initPos(400,200);
// this.addChild(this.basketball);
}
stop() {}
}
import GameView from "./GameView";
import { injectProps } from "../props";
export class GameWrapper extends engine.Container {
// private _status;
private _gameView: GameView;
constructor() {
super();
engine.globalEvent.addEventListener('game-start', this.start, this);
engine.globalEvent.addEventListener('game-stop', this.stop, this);
//创建实例
let gameView = this._gameView = new GameView();
this.addChild(gameView);
}
start(event: engine.Event) {
injectProps(event.data);
// this._status = 1;
this._gameView.start();
}
stop(event: engine.Event) {
this._gameView.stop();
}
// reset(event:engine.Event){
// this._gameView.reset();
// }
}
/**
* Created by rockyl on 2020-01-21.
*/
export function getTexture(uuid) {
return engine.Texture.from(getAssetByUUID(uuid).uuid);
}
export function getTextureByName(name) {
return getTexture(engine.getAssetByName(name).uuid);
}
export function playSound(name) {
engine.playSound(engine.getAssetByName(name).uuid, {keep: true});
}
export function createSvga(name, anchorName?) {
let inst = new svga.Svga();
inst.source = 'asset://' + engine.getAssetByName(name).uuid;
return inst;
}
export function getIndexFromRC(row,col,maxCol){
let index;
index = row * maxCol + col ;
return index
}
export function getRandomArray(array){
array.sort(function() {
return .5 - Math.random();
});
}
\ No newline at end of file
import {GameWrapper} from "./game/GameWrapper";
import {injectProps, prepareProps} from "./props";
export default function (props) {
prepareProps();
injectProps(props);
let instance = new GameWrapper();
return instance;
}
//////////////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2014-present, Egret Technology.
// All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of the Egret nor the
// names of its contributors may be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////////////////
declare module p2 {
export class AABB {
upperBound: number[];
lowerBound: number[];
constructor(options?: {
upperBound?: number[];
lowerBound?: number[];
});
containsPoint(point: number[]): boolean;
setFromPoints(points: number[][], position: number[], angle: number, skinSize: number): void;
copy(aabb: AABB): void;
extend(aabb: AABB): void;
overlaps(aabb: AABB): boolean;
overlapsRay(ray:Ray): number;
}
export class Broadphase {
static AABB: number;
static BOUNDING_CIRCLE: number;
static boundingRadiusCheck(bodyA: Body, bodyB: Body): boolean;
static aabbCheck(bodyA: Body, bodyB: Body): boolean;
static canCollide(bodyA: Body, bodyB: Body): boolean;
constructor(type: number);
result: Body[];
world: World;
boundingVolumeType: number;
setWorld(world: World): void;
getCollisionPairs(world: World): Body[];
boundingVolumeCheck(bodyA: Body, bodyB: Body): boolean;
}
export class NaiveBroadphase extends Broadphase {
aabbQuery(world: World, aabb: AABB, result: Body[]): Body[];
}
export class Narrowphase {
static findSeparatingAxis(c1:Convex, offset1:number[], angle1:number, c2:Convex, offset2:number[], angle2:number, sepAxis:number[]): boolean;
static getClosestEdge(c:Convex, angle:number, axis:number[], flip:boolean): number;
static projectConvexOntoAxis(convexShape:Convex, convexOffset:number[], convexAngle:number, worldAxis:number[], result:number[]): void;
contactEquationPool: ContactEquationPool;
contactEquations: ContactEquation[];
contactSkinSize: number;
enabledEquations: boolean;
enableFriction: boolean;
frictionCoefficient: number;
frictionEquationPool: FrictionEquationPool;
frictionEquations: FrictionEquation[];
frictionRelaxation: number;
frictionStiffness: number;
restitution: number;
slipForce: number;
stiffness: number;
surfaceVelocity: number;
//官方不赞成使用的属性
enableFrictionReduction: boolean;
bodiesOverlap(bodyA: Body, bodyB: Body): boolean;
capsuleCapsule(bi: Body, si: Capsule, xi: number[], ai: number, bj: Body, sj: Capsule, xj: number[], aj: number): void;
circleCapsule(bi: Body, si: Circle, xi: number[], ai: number, bj: Body, sj: Line, xj: number[], aj: number): void;
circleCircle(bodyA: Body, shapeA: Circle, offsetA: number[], angleA: number, bodyB: Body, shapeB: Circle, offsetB: number[], angleB: number, justTest: boolean, radiusA?:number, radiusB?:number): void;
circleConvex(circleBody:Body, circleShape:Circle, circleOffset:number[], circleAngle:number, convexBody:Body, convexShape:Convex, convexOffset:number[], convexAngle:number, justTest:boolean, circleRadius:number): void;
circleHeightfield(bi:Body, si:Circle, xi:number[], bj:Body, sj:Heightfield, xj:number[], aj:number): void;
circleLine(circleBody:Body, circleShape:Circle, circleOffset:number[], circleAngle:number, lineBody:Body, lineShape:Line, lineOffset:number[], lineAngle:number, justTest:boolean, lineRadius:number, circleRadius:number): void;
circleParticle(circleBody:Body, circleShape:Circle, circleOffset:number[], circleAngle:number, particleBody:Body, particleShape:Particle, particleOffset:number[], particleAngle:number, justTest:boolean): void;
circlePlane(bi:Body, si:Circle, xi:number[], bj:Body, sj:Plane, xj:number[], aj:number): void;
collidedLastStep(bodyA: Body, bodyB: Body): boolean;
convexCapsule(convexBody:Body, convexShape:Convex, convexPosition:number[], convexAngle:number, capsuleBody:Body, capsuleShape:Capsule, capsulePosition:number[], capsuleAngle:number): void;
convexConvex(bi:Body, si:Convex, xi:number[], ai:number, bj:Body, sj:Convex, xj:number[], aj:number): void;
convexLine(convexBody:Body, convexShape:Convex, convexOffset:number[], convexAngle:number, lineBody:Body, lineShape:Line, lineOffset:number[], lineAngle:number, justTest:boolean): void;
createContactEquation(bodyA: Body, bodyB: Body): ContactEquation;
createFrictionEquation(bodyA: Body,bodyB: Body): FrictionEquation;
createFrictionFromContact(contactEquation: ContactEquation): FrictionEquation;
lineBox(lineBody:Body, lineShape:Line, lineOffset:number[], lineAngle:number, boxBody:Body, boxShape:Box, boxOffset:number[], boxAngle:number, justTest:boolean): void;
lineCapsule(lineBody:Body, lineShape:Line, linePosition:number[], lineAngle:number, capsuleBody:Body, capsuleShape:Capsule, capsulePosition:number[], capsuleAngle:number): void;
lineLine(bodyA:Body, shapeA:Line, positionA:number[], angleA:number, bodyB:Body, shapeB:Line, positionB:number[], angleB:number): void;
particleConvex(particleBody:Body, particleShape:Particle, particleOffset:number[], particleAngle:number, convexBody:Body, convexShape:Convex, convexOffset:number[], convexAngle:number, justTest:boolean): void;
particlePlane(particleBody:Body, particleShape:Particle, particleOffset:number[], particleAngle:number, planeBody:Body, planeShape:Plane, planeOffset:number[], planeAngle:number, justTest:boolean): void;
planeCapsule(planeBody:Body, planeShape:Circle, planeOffset:number[], planeAngle:number, capsuleBody:Body, capsuleShape:Particle, capsuleOffset:number[], capsuleAngle:number, justTest:boolean): void;
planeConvex(planeBody:Body, planeShape:Plane, planeOffset:number[], planeAngle:number, convexBody:Body, convexShape:Convex, convexOffset:number[], convexAngle:number, justTest:boolean): void;
planeLine(planeBody:Body, planeShape:Plane, planeOffset:number[], planeAngle:number, lineBody:Body, lineShape:Line, lineOffset:number[], lineAngle:number): void;
reset(): void;
}
export class SAPBroadphase extends Broadphase {
axisIndex: number;
axisList: Body[];
aabbQuery(world: World, aabb: AABB, result: Body[]): Body[];
sortAxisList(a: Body[], axisIndex: number): Body[];
}
export class Constraint {
static DISTANCE: number;
static GEAR: number;
static LOCK: number;
static PRISMATIC: number;
static REVOLUTE: number;
constructor(bodyA: Body, bodyB: Body, type: number, options?: {
collideConnected?: boolean;
});
type: number;
equations: Equation[];
bodyA: Body;
bodyB: Body;
collideConnected: boolean;
update(): void;
setStiffness(stiffness: number): void;
setRelaxation(relaxation: number): void;
}
export class DistanceConstraint extends Constraint {
constructor(bodyA: Body, bodyB: Body, options?: {
distance?: number;
localAnchorA?: number[];
localAnchorB?: number[];
maxForce?: number;
});
localAnchorA: number[];
localAnchorB: number[];
distance: number;
maxForce: number;
upperLimitEnabled: boolean;
upperLimit: number;
lowerLimitEnabled: boolean;
lowerLimit: number;
position: number;
setMaxForce(maxForce: number): void;
getMaxForce(): number;
}
export class GearConstraint extends Constraint {
constructor(bodyA: Body, bodyB: Body, options?: {
angle?: number;
ratio?: number;
maxTorque?: number;
});
ratio: number;
angle: number;
setMaxTorque(torque: number): void;
getMaxTorque(): number;
}
export class LockConstraint extends Constraint {
constructor(bodyA: Body, bodyB: Body, options?: {
localOffsetB?: number[];
localAngleB?: number;
maxForce?: number;
collideConnected?: boolean;
});
localAngleB: number;
localOffsetB: number[];
setMaxForce(force: number): void;
getMaxForce(): number;
}
export class PrismaticConstraint extends Constraint {
constructor(bodyA: Body, bodyB: Body, options?: {
maxForce?: number;
localAnchorA?: number[];
localAnchorB?: number[];
localAxisA?: number[];
disableRotationalLock?: boolean;
upperLimit?: number;
lowerLimit?: number;
collideConnected?: boolean;
});
localAnchorA: number[];
localAnchorB: number[];
localAxisA: number[];
lowerLimit: number;
lowerLimitEnabled: boolean;
motorEnabled: boolean;
motorEquation: Equation;
motorSpeed: number;
position: number;
upperLimit: number;
upperLimitEnabled: boolean;
disableMotor(): void;
enableMotor(): void;
setLimits(lower: number, upper: number): void;
}
export class RevoluteConstraint extends Constraint {
constructor(bodyA: Body, bodyB: Body, options?: {
worldPivot?: number[];
localPivotA?: number[];
localPivotB?: number[];
maxForce?: number;
collideConnected?: boolean;
});
angle: number;
lowerLimit: number;
lowerLimitEnabled: boolean;
motorEnabled: boolean;
pivotA: number[];
pivotB: number[];
upperLimit: number;
upperLimitEnabled: boolean;
disableMotor(): void;
enableMotor(): void;
getMotorSpeed(): number;
//官方不赞成使用了
motorIsEnabled(): boolean;
setLimits(lower: number, upper: number): void;
setMotorSpeed(speed: number): void;
}
export class AngleLockEquation extends Equation {
constructor(bodyA: Body, bodyB: Body, options?: {
angle?: number;
ratio?: number;
});
computeGq(): number;
setRatio(ratio: number): number;
setMaxTorque(torque: number): number;
}
export class ContactEquation extends Equation {
constructor(bodyA: Body, bodyB: Body);
contactPointA: number[];
contactPointB: number[];
normalA: number[];
restitution: number;
firstImpact: boolean;
shapeA: Shape;
shapeB: Shape;
}
export class Equation {
static DEFAULT_STIFFNESS: number;
static DEFAULT_RELAXATION: number;
constructor(bodyA: Body, bodyB: Body, minForce?: number, maxForce?: number);
minForce: number;
maxForce: number;
bodyA: Body;
bodyB: Body;
stiffness: number;
relaxation: number;
G: number[];
needsUpdate: boolean;
multiplier: number;
relativeVelocity: number;
enabled: boolean;
gmult(): number;
computeB(): number;
computeGq(): number;
computeGW(): number;
computeGWlambda(): number;
computeGiMf(): number;
computeGiMGt(): number;
addToWlambda(deltalambda: number): void;
computeInvC(eps: number): number;
update(): void;
}
export class FrictionEquation extends Equation {
constructor(bodyA: Body, bodyB: Body, slipForce: number);
contactEquations: ContactEquation;
contactPointA: number[];
contactPointB: number[];
t: number[];
shapeA: Shape;
shapeB: Shape;
frictionCoefficient: number;
setSlipForce(slipForce: number): void;
getSlipForce(): number;
}
export class RotationalLockEquation extends Equation {
constructor(bodyA: Body, bodyB: Body, options?: {
angle?: number;
});
angle: number;
}
export class RotationalVelocityEquation extends Equation {
constructor(bodyA: Body, bodyB: Body);
}
export class EventEmitter {
on(type: string, listener: Function, context?: any): EventEmitter;
has(type: string, listener: Function): boolean;
off(type: string, listener: Function): EventEmitter;
emit(event: any): EventEmitter;
}
export class ContactMaterialOptions {
friction?: number;
restitution?: number;
stiffness?: number;
relaxation?: number;
frictionStiffness?: number;
frictionRelaxation?: number;
surfaceVelocity?: number;
}
export class ContactMaterial {
constructor(materialA: Material, materialB: Material, options?: ContactMaterialOptions);
id: number;
materialA: Material;
materialB: Material;
friction: number;
restitution: number;
stiffness: number;
relaxation: number;
frictionStuffness: number;
frictionRelaxation: number;
surfaceVelocity: number;
contactSkinSize: number;
}
export class Material {
constructor(id: number);
id: number;
}
export class vec2 {
static add(out: number[], a: number[], b: number[]): number[];
static centroid(out: number[], a: number[], b: number[], c: number[]): number[];
static clone(a: number[]): number[];
static copy(out: number[], a: number[]): number[];
static create(): number[];
static crossLength(a: number[], b: number[]): number;
static crossVZ(out: number[], vec: number[], zcomp: number): number;
static crossZV(out: number[], zcomp: number, vec: number[]): number;
static dist(a: number[], b: number[]): number;
static distance(a: number[], b: number[]): number;
static div(out: number[], a: number[], b: number[]): number[];
static divide(out: number[], a: number[], b: number[]): number[];
static dot(a: number[], b: number[]): number;
static fromValues(x: number, y: number): number[];
static getLineSegmentsIntersection(out: number[], p0: number[], p1: number[], p2: number[], p3: number[]): boolean;
static getLineSegmentsIntersectionFraction(p0: number[], p1: number[], p2: number[], p3: number[]): number;
static len(a: number[]): number;
static length(a: number[]): number;
static lerp(out: number[], a: number[], b: number[], t: number): void;
static mul(out: number[], a: number[], b: number[]): number[];
static multiply(out: number[], a: number[], b: number[]): number[];
static negate(out: number[], a: number[]): number[];
static normalize(out: number[], a: number[]): number[];
static reflect(out: number[], vector: number[], normal: number[]): void;
static rotate(out: number[], a: number[], angle: number): void;
static rotate90cw(out: number[], a: number[]): void;
static scale(out: number[], a: number[], b: number): number[];
static set(out: number[], x: number, y: number): number[];
static sqrDist(a: number[], b: number[]): number;
static squaredDistance(a: number[], b: number[]): number;
static sqrLen(a: number[]): number;
static squaredLength(a: number[]): number;
static str(vec: number[]): string;
static sub(out: number[], a: number[], b: number[]): number[];
static subtract(out: number[], a: number[], b: number[]): number[];
static toGlobalFrame(out: number[], localPoint: number[], framePosition: number[], frameAngle: number): void;
static toLocalFrame(out: number[], worldPoint: number[], framePosition: number[], frameAngle: number): void;
static vectorToLocalFrame(out: number[], worldVector: number[], frameAngle: number): void;
}
// export class BodyOptions {
//
// mass: number;
// position: number[];
// velocity: number[];
// angle: number;
// angularVelocity: number;
// force: number[];
// angularForce: number;
// fixedRotation: number;
//
// }
/**
* 刚体。有质量、位置、速度等属性以及一组被用于碰撞的形状
*
* @class Body
* @constructor
* @extends EventEmitter
* @param {Array} [options.force]
* @param {Array} [options.position]
* @param {Array} [options.velocity]
* @param {Boolean} [options.allowSleep]
* @param {Boolean} [options.collisionResponse]
* @param {Number} [options.angle=0]
* @param {Number} [options.angularForce=0]
* @param {Number} [options.angularVelocity=0]
* @param {Number} [options.ccdIterations=10]
* @param {Number} [options.ccdSpeedThreshold=-1]
* @param {Number} [options.fixedRotation=false]
* @param {Number} [options.gravityScale]
* @param {Number} [options.id]
* @param {Number} [options.mass=0] 一个大于0的数字。如果设置成0,其type属性将被设置为 Body.STATIC.
* @param {Number} [options.sleepSpeedLimit]
* @param {Number} [options.sleepTimeLimit]
* @param {Object} [options]
*
* @example
* // 创建一个刚体
* var body = new Body({
* mass: 1,
* position: [0, 0],
* angle: 0,
* velocity: [0, 0],
* angularVelocity: 0
* });
*
* // 将一个圆形形状添加到刚体
* body.addShape(new Circle({ radius: 1 }));
*
* // 将刚体加入 world
* world.addBody(body);
*/
export class Body extends EventEmitter {
sleepyEvent: {
type: string;
};
sleepEvent: {
type: string;
};
wakeUpEvent: {
type: string;
};
static DYNAMIC: number;
static STATIC: number;
static KINEMATIC: number;
static AWAKE: number;
static SLEEPY: number;
static SLEEPING: number;
constructor(options?);
/**
* 刚体id
* @property id
* @type {Number}
*/
id: number;
/**
* 刚体被添加到的 world。如果没有被添加到 world 该属性将被设置为 null
* @property world
* @type {World}
*/
world: World;
/**
* 刚体的碰撞形状
*
* @property shapes
* @type {Array}
*/
shapes: Shape[];
/**
* 质量
* @property mass
* @type {number}
*/
mass: number;
/**
* 惯性
* @property inertia
* @type {number}
*/
inertia: number;
/**
* 是否固定旋转
* @property fixedRotation
* @type {Boolean}
*/
fixedRotation: boolean;
/**
* 位置
* @property position
* @type {Array}
*/
position: number[];
/**
* 位置插值
* @property interpolatedPosition
* @type {Array}
*/
interpolatedPosition: number[];
/**
* 角度插值
* @property interpolatedAngle
* @type {Number}
*/
interpolatedAngle: number;
/**
* 速度
* @property velocity
* @type {Array}
*/
velocity: number[];
/**
* 角度
* @property angle
* @type {number}
*/
angle: number;
/**
* 力
* @property force
* @type {Array}
*/
force: number[];
/**
* 角力
* @property angularForce
* @type {number}
*/
angularForce: number;
/**
* 限行阻尼。取值区间[0,1]
* @property damping
* @type {Number}
* @default 0.1
*/
damping: number;
/**
* 角阻尼。取值区间[0,1]
* @property angularDamping
* @type {Number}
* @default 0.1
*/
angularDamping: number;
/**
* 运动类型。 应该是Body.STATIC,Body.DYNAMIC,Body.KINEMATIC之一
*
* * Static 刚体不会动,不响应力或者碰撞
* * Dynamic 刚体会动,响应力和碰撞
* * Kinematic 刚体仅根据自身属性运动,不响应力或者碰撞
*
* @property type
* @type {number}
*
* @example
* // 默认值是STATIC
* var body = new Body();
* console.log(body.type == Body.STATIC); // true
*
* @example
* // 将质量设置为非0的值,会变为DYNAMIC
* var dynamicBody = new Body({
* mass : 1
* });
* console.log(dynamicBody.type == Body.DYNAMIC); // true
*
* @example
* // KINEMATIC刚体只会运动,如果你改变它的速度
* var kinematicBody = new Body({
* type: Body.KINEMATIC
* });
*/
type: number;
/**
* 边界圆半径
* @property boundingRadius
* @type {Number}
*/
boundingRadius: number;
/**
* 边框
* @property aabb
* @type {AABB}
*/
aabb: AABB;
/**
* 设置AABB是否会更新。通过调用 updateAABB 方法更新它
* @property aabbNeedsUpdate
* @type {Boolean}
* @see updateAABB
*
* @example
* body.aabbNeedsUpdate = true;
* body.updateAABB();
* console.log(body.aabbNeedsUpdate); // false
*/
aabbNeedsUpdate: boolean;
/**
* 设置为true,刚体会自动进入睡眠。需要在 World 中允许刚体睡眠
* @property allowSleep
* @type {Boolean}
* @default true
*/
allowSleep: boolean;
/**
* Body.AWAKE,Body.SLEEPY,Body.SLEEPING之一
*
* 默认值是 Body.AWAKE。如果刚体速度低于 sleepSpeedLimit,该属性将变为 Body.SLEEPY。如果持续 Body.SLEEPY 状态 sleepTimeLimit 秒,该属性将变为 Body.SLEEPY。
*
* @property sleepState
* @type {Number}
* @default Body.AWAKE
*/
sleepState: number;
/**
* 如果速度小于该值,sleepState 将变为 Body.SLEEPY 状态
* @property sleepSpeedLimit
* @type {Number}
* @default 0.2
*/
sleepSpeedLimit: number;
/**
* 如果持续 Body.SLEEPY 状态 sleepTimeLimit 秒,sleepState 将变为 Body.SLEEPING
* @property sleepTimeLimit
* @type {Number}
* @default 1
*/
sleepTimeLimit: number;
/**
* 重力缩放因子。如果你想忽略刚体重心,设置为零。如果你想反转重力,将其设置为-1。
* @property {Number} gravityScale
* @default 1
*/
gravityScale: number;
/**
* The angular velocity of the body, in radians per second.
* @property angularVelocity
* @type {number}
*/
angularVelocity: number;
/**
* The inverse inertia of the body.
* @property invInertia
* @type {number}
*/
invInertia: number;
/**
* The inverse mass of the body.
* @property invMass
* @type {number}
*/
invMass: number;
/**
* The previous angle of the body.
* @property previousAngle
* @type {number}
*/
previousAngle: number;
/**
* The previous position of the body.
* @property previousPosition
* @type {Array}
*/
previousPosition: number[];
/**
* Constraint velocity that was added to the body during the last step.
* @property vlambda
* @type {Array}
*/
vlambda: number[];
/**
* Angular constraint velocity that was added to the body during last step.
* @property wlambda
* @type {Array}
*/
wlambda: number[];
/**
* The number of iterations that should be used when searching for the time of impact during CCD. A larger number will assure that there's a small penetration on CCD collision, but a small number will give more performance.
* @property {Number} ccdIterations
* @default 10
*/
ccdIterations: number;
/**
* If the body speed exceeds this threshold, CCD (continuous collision detection) will be enabled. Set it to a negative number to disable CCD completely for this body.
* @property {Number} ccdSpeedThreshold
* @default -1
*/
ccdSpeedThreshold: number;
/**
* Whether to produce contact forces when in contact with other bodies. Note that contacts will be generated, but they will be disabled. That means that this body will move through other bodies, but it will still trigger contact events, etc.
* @property collisionResponse
* @type {Boolean}
*/
collisionResponse: boolean;
/**
* Set to true if you want to fix the body movement along the X axis. The body will still be able to move along Y.
* @property fixedX
* @type {Boolean}
*/
fixedX: boolean;
/**
* Set to true if you want to fix the body movement along the Y axis. The body will still be able to move along X.
* @property fixedY
* @type {Boolean}
*/
fixedY: boolean;
/**
* How long the body has been sleeping.
* @property idleTime
* @type {Number}
*/
idleTime: number;
/**
* 与每个形状对应的显示对象
*/
displays: engine.DisplayObject[];
/**
* 设置刚体总密度
* @method setDensity
*/
setDensity(density: number): void;
/**
* 得到所有形状的总面积
* @method getArea
* @return {Number}
*/
getArea(): number;
/**
* 获得AABB
* @method getAABB
*/
getAABB(): AABB;
/**
* 更新AABB
* @method updateAABB
*/
updateAABB(): void;
/**
* 更新外边界
* @method updateBoundingRadius
*/
updateBoundingRadius(): void;
/**
* 添加一个形状
*
* @method addShape
* @param {Shape} shape 形状
* @param {Array} [offset] 偏移
* @param {Number} [angle] 角度
*
* @example
* var body = new Body(),
* shape = new Circle();
*
* // 位于中心
* body.addShape(shape);
*
* // 偏移量为x轴一个单位
* body.addShape(shape,[1,0]);
*
* // 偏移量为y轴一个单位,同时逆时针旋转90度
* body.addShape(shape,[0,1],Math.PI/2);
*/
addShape(shape: Shape, offset?: number[], angle?: number): void;
/**
* 移除形状
* @method removeShape
* @param {Shape} shape
* @return {Boolean}
*/
removeShape(shape: Shape): boolean;
/**
* 更新属性,结构或者质量改变时会被调用
*
* @method updateMassProperties
*
* @example
* body.mass += 1;
* body.updateMassProperties();
*/
updateMassProperties(): void;
/**
* 相对于 world 中的一个点施加力
* @method applyForce
* @param {Array} force 力
* @param {Array} relativePoint 以物体中心点为基准的点
*/
applyForce(force: number[], relativePoint: number[]): void;
/**
* Wake the body up. Normally you should not need this, as the body is automatically awoken at events such as collisions.
* Sets the sleepState to {{#crossLink "Body/AWAKE:property"}}Body.AWAKE{{/crossLink}} and emits the wakeUp event if the body wasn't awake before.
* @method wakeUp
*/
wakeUp(): void;
/**
* Force body sleep
* @method sleep
*/
sleep(): void;
/**
* Called every timestep to update internal sleep timer and change sleep state if needed.
* @method sleepTick
* @param {number} time The world time in seconds
* @param {boolean} dontSleep
* @param {number} dt
*/
sleepTick(time: number, dontSleep: boolean, dt: number): void;
/**
* Check if the body is overlapping another body. Note that this method only works if the body was added to a World and if at least one step was taken.
* @method overlaps
* @param {Body} body
* @return {boolean}
*/
overlaps(body: Body): boolean;
/**
* Moves the shape offsets so their center of mass becomes the body center of mass.
* @method adjustCenterOfMass
*/
adjustCenterOfMass(): void;
/**
* Apply damping.
* @method applyDamping
* @param {number} dt Current time step
*/
applyDamping(dt: number): void;
/**
* Reads a polygon shape path, and assembles convex shapes from that and puts them at proper offset points.
* @method fromPolygon
* @param {Array} path An array of 2d vectors, e.g. [[0,0],[0,1],...] that resembles a concave or convex polygon. The shape must be simple and without holes.
* @param {Object} [options]
* @param {Boolean} [options.optimalDecomp=false] Set to true if you need optimal decomposition. Warning: very slow for polygons with more than 10 vertices.
* @param {Boolean} [options.skipSimpleCheck=false] Set to true if you already know that the path is not intersecting itself.
* @param {Boolean|Number} [options.removeCollinearPoints=false] Set to a number (angle threshold value) to remove collinear points, or false to keep all points.
* @return {Boolean} True on success, else false.
*/
fromPolygon(path:number[][], options?: {
optimalDecomp?: boolean;
skipSimpleCheck?: boolean;
removeCollinearPoints?: boolean; // Boolean | Number
}): boolean;
/**
* Sets the force on the body to zero.
* @method setZeroForce
*/
setZeroForce(): void;
/**
* Transform a world point to local body frame.
* @method toLocalFrame
* @param {Array} out The vector to store the result in
* @param {Array} worldPoint The input world point
*/
toLocalFrame(out: number[], worldPoint: number[]): void;
/**
* Transform a local point to world frame.
* @method toWorldFrame
* @param {Array} out The vector to store the result in
* @param {Array} localPoint The input local point
*/
toWorldFrame(out: number[], localPoint: number[]): void;
/**
* Apply force to a body-local point.
* @method applyForceLocal
* @param {Array} localForce The force vector to add, oriented in local body space.
* @param {Array} localPoint A point relative to the body in world space. If not given, it is set to zero and all of the impulse will be excerted on the center of mass.
*/
applyForceLocal(localForce: number[], localPoint: number[]): void;
/**
* Apply impulse to a point relative to the body. This could for example be a point on the Body surface. An impulse is a force added to a body during a short period of time (impulse = force * time). Impulses will be added to Body.velocity and Body.angularVelocity.
* @method applyImpulse
* @param {Array} impulse The impulse vector to add, oriented in world space.
* @param {Array} relativePoint A point relative to the body in world space. If not given, it is set to zero and all of the impulse will be excerted on the center of mass.
*/
applyImpulse(impulse: number[], relativePoint: number[]): void;
/**
* Apply impulse to a point relative to the body. This could for example be a point on the Body surface. An impulse is a force added to a body during a short period of time (impulse = force * time). Impulses will be added to Body.velocity and Body.angularVelocity.
* @method applyImpulseLocal
* @param {Array} impulse The impulse vector to add, oriented in world space.
* @param {Array} relativePoint A point relative to the body in world space. If not given, it is set to zero and all of the impulse will be excerted on the center of mass.
*/
applyImpulseLocal(impulse: number[], relativePoint: number[]): void;
/**
* Get velocity of a point in the body.
* @method getVelocityAtPoint
* @param {Array} result A vector to store the result in
* @param {Array} relativePoint A world oriented vector, indicating the position of the point to get the velocity from
* @return {Array}
*/
getVelocityAtPoint(result: number[], relativePoint: number[]): number[];
/**
* Move the body forward in time given its current velocity.
* @method integrate
* @param {number} dt
*/
integrate(dt: number): void;
/**
* Transform a world point to local body frame.
* @method vectorToLocalFrame
* @param {Array} out The vector to store the result in
* @param {Array} worldVector The input world vector
*/
vectorToLocalFrame(out: number[], worldVector: number[]): void;
/**
* Transform a local point to world frame.
* @method vectorToWorldFrame
* @param {Array} out The vector to store the result in
* @param {Array} localVector The input local vector
*/
vectorToWorldFrame(out: number[], localVector: number[]): void;
}
/**
* Box shape class.
*
* @class Box
* @constructor
* @extends Convex
* @param {Object} [options] (Note that this options object will be passed on to the Shape constructor.)
* @param {Number} [options.width=1] Total width of the box
* @param {Number} [options.height=1] Total height of the box
*/
export class Box extends Convex {
constructor(options?: Object);
width: number;
height: number;
}
export class Pool {
objects: any[];
get(): Object;
release(object: Object): Pool;
resize(size: number): Pool;
}
export class OverlapKeeperRecordPool extends Pool {
}
export class IslandPool extends Pool {
}
export class IslandNodePool extends Pool {
}
export class ContactEquationPool extends Pool {
}
export class FrictionEquationPool extends Pool {
}
export class Ray {
static ALL: number;
static ANY: number;
static CLOSEST: number;
constructor(options?: {
from?: number[];
to?: number[];
checkCollisionResponse?: boolean;
skipBackfaces?: boolean;
collisionMask?: number;
collisionGroup?: number;
mode?: number;
callback?: number;
});
callback: Function;
checkCollisionResponse: boolean;
collisionGroup: number;
collisionMask: number;
direction: number[];
from: number[];
length: number;
mode: number;
skipBackfaces: boolean;
to: number[];
getAABB(aabb: AABB): void;
intersectBodies(bodies: Body[]): void;
update(): void;
}
export class RaycastResult {
body: Body;
faceIndex: number;
fraction: number;
isStopped: boolean;
normal: number[];
shape: Shape;
getHitDistance(ray: Ray): void;
getHitPoint(out:number[], ray: Ray): void;
hasHit():boolean;
reset(): void;
stop(): void;
}
export class TopDownVehicle {
constructor(chassisBody: Body, options?: Object);
chassisBody: Body;
wheels: WheelConstraint[];
addToWorld(world: World): void;
addWheel(wheelOptions?: Object): WheelConstraint;
removeFromWorld(world: World): void;
update(): void;
}
export class WheelConstraint extends Constraint {
constructor(vehicle: TopDownVehicle, options?: {
localForwardVector?: number[];
localPosition?: number[];
sideFriction?: number;
});
engineForce: number;
localForwardVector: number[];
localPosition: number[];
steerValue: number;
getSpeed(): number;
update(): void;
}
export class Spring {
constructor(bodyA: Body, bodyB: Body, options?: {
stiffness?: number;
damping?: number;
localAnchorA?: number[];
localAnchorB?: number[];
worldAnchorA?: number[];
worldAnchorB?: number[];
});
bodyA: Body;
bodyB: Body;
damping: number;
stiffness: number;
applyForce(): void;
}
export class LinearSpring extends Spring {
constructor(bodyA: Body, bodyB: Body, options?: {
restLength?: number;
stiffness?: number;
damping?: number;
worldAnchorA?: number[];
worldAnchorB?: number[];
localAnchorA?: number[];
localAnchorB?: number[];
});
localAnchorA: number[];
localAnchorB: number[];
restLength: number;
setWorldAnchorA(worldAnchorA: number[]): void;
setWorldAnchorB(worldAnchorB: number[]): void;
getWorldAnchorA(result: number[]): void;
getWorldAnchorB(result: number[]): void;
}
export class RotationalSpring extends Spring {
constructor(bodyA: Body, bodyB: Body, options?: {
restAngle?: number;
stiffness?: number;
damping?: number;
});
restAngle: number;
}
/**
* Capsule shape class.
*
* @class Capsule
* @constructor
* @extends Shape
* @param {Object} [options] (Note that this options object will be passed on to the Shape constructor.)
* @param {Number} [options.length=1] The distance between the end points
* @param {Number} [options.radius=1] Radius of the capsule
*/
export class Capsule extends Shape {
constructor(options?: Object);
length: number;
radius: number;
conputeMomentOfInertia(mass: number): number;
}
/**
* Circle shape class.
*
* @class Circle
* @constructor
* @extends Shape
* @param {Object} [options] (Note that this options object will be passed on to the Shape constructor.)
* @param {Number} [options.radius=1] The radius of this circle
* @example
* var circleShape = new Circle({ radius: 1 });
* body.addShape(circleShape);
*/
export class Circle extends Shape {
constructor(options?: Object);
/**
* 半径
* @property radius
* @type {number}
*/
radius: number;
}
/**
* Convex shape class.
*
* @class Convex
* @constructor
* @extends Shape
* @param {Object} [options] (Note that this options object will be passed on to the Shape constructor.)
* @param {Array} [options.vertices] An array of vertices that span this shape. Vertices are given in counter-clockwise (CCW) direction.
* @param {Array} [options.axes] An array of unit length vectors, representing the symmetry axes in the convex.
* @example
* var vertices = [[-1,-1], [1,-1], [1,1], [-1,1]];
* var convexShape = new Convex({ vertices: vertices });
* body.addShape(convexShape);
*/
export class Convex extends Shape {
static projectOntoAxis(offset: number[], localAxis: number[], result: number[]): void;
static triangleArea(a: number[], b: number[], c: number[]): number;
constructor(options?: Object);
vertices: number[][];
axes: number[];
centerOfMass: number[];
triangles: number[];
updateCenterOfMass(): void;
updateTriangles(): void;
}
export class Heightfield extends Shape {
constructor(options?: {
heights?: number[];
minValue?: number;
maxValue?: number;
elementWidth?: number;
});
heights: number[];
maxValue: number;
minValue: number;
elementWidth: number;
getLineSegment(start:number[], end:number[], i:number): void;
updateMaxMinValues(): void;
}
export class Shape {
static BOX: number;
static CAPSULE: number;
static CIRCLE: number;
static CONVEX: number;
static HEIGHTFIELD: number;
static LINE: number;
static PARTICLE: number;
static PLANE: number;
constructor(options?: {
position?: number[];
angle?: number;
collisionGroup?: number;
collisionMask?: number;
sensor?: boolean;
collisionResponse?: boolean;
type?: number;
});
angle: number;
area: number;
body: Body;
boundingRadius: number;
collisionGroup: number;
collisionMask: number;
collisionResponse: boolean;
id: number;
material: Material;
position: number[];
sensor: boolean;
type: number;
computeAABB(out: AABB, position: number[], angle: number): void;
computeMomentOfInertia(mass: number): number;
raycast(result: RaycastResult, ray: Ray, position: number[], angle: number): void;
updateArea(): void;
updateBoundingRadius(): number;
}
export class Line extends Shape {
constructor(options?: {
length?: number;
});
length: number;
}
export class Particle extends Shape {
}
export class Plane extends Shape {
}
export class Solver extends EventEmitter {
constructor();
equations: Equation[];
equationSortFunction: Function; //Function | boolean
addEquation(eq: Equation): void;
addEquations(eqs: Equation[]): void;
removeAllEquations(): void;
removeEquation(eq: Equation): void;
solve(dt: number, world: World): void;
solveIsland(dt: number, island: Island): void;
sortEquations(): void;
}
export class GSSolver extends Solver {
constructor(options?: {
iterations?: number;
tolerance?: number;
});
iterations: number;
tolerance: number;
useZeroRHS: boolean;
frictionIterations: number;
usedIterations: number;
solve(h: number, world: World): void;
}
export class OverlapKeeper {
constructor();
recordPool: OverlapKeeperRecordPool;
tick(): void;
setOverlapping(bodyA: Body, shapeA: Body, bodyB: Body, shapeB: Body): void;
bodiesAreOverlapping(bodyA: Body, bodyB: Body): boolean;
}
export class OverlapKeeperRecord {
constructor(bodyA: Body, shapeA: Shape, bodyB: Body, shapeB: Shape);
bodyA: Body;
bodyB: Body;
shapeA: Shape;
shapeB: Shape;
set(bodyA: Body, shapeA: Shape, bodyB: Body, shapeB: Shape): void;
}
export class TupleDictionary {
data: Object;
keys: number[];
copy(dict: TupleDictionary): void;
get(i: number, j: number): number;
getByKey(key: number): Object;
getKey(i: number, j: number): string;
reset(): void;
set(i: number, j: number, value: number): void;
}
export class Utils {
static appendArray<T>(a: Array<T>, b: Array<T>): Array<T>;
static splice<T>(array: Array<T>, index: number, howMany: number): void;
static extend(a: any, b: any): void;
static defaults(options: any, defaults: any): any;
}
export class Island {
equations: Equation[];
bodies: Body[];
reset(): void;
getBodies(): Body[];
wantsToSleep(): boolean;
sleep(): void;
}
export class IslandManager extends Solver {
static getUnvisitedNode(nodes: Node[]): IslandNode; // IslandNode | boolean
constructor(options?: Object);
islands: Island[];
nodes: IslandNode[];
islandPool: IslandPool;
nodePool: IslandNodePool;
visit(node: IslandNode, bds: Body[], eqs: Equation[]): void;
bfs(root: IslandNode, bds: Body[], eqs: Equation[]): void;
split(world: World): Island[];
}
export class IslandNode {
constructor(body: Body);
body: Body;
neighbors: IslandNode[];
equations: Equation[];
visited: boolean;
reset(): void;
}
/**
* world,包含所有刚体
*
* @class World
* @constructor
* @param {Object} [options]
* @param {Solver} [options.solver] 默认值 GSSolver.
* @param {Array} [options.gravity] 默认值 [0,-9.78]
* @param {Broadphase} [options.broadphase] 默认值 NaiveBroadphase
* @param {Boolean} [options.islandSplit=false]
* @param {Boolean} [options.doProfiling=false]
* @extends EventEmitter
*
* @example
* var world = new World({
* gravity: [0, -9.81],
* broadphase: new SAPBroadphase()
* });
*/
export class World extends EventEmitter {
/**
* step() 执行之后调用
* @event postStep
*/
postStepEvent: {
type: string;
};
/**
* Body 加入时调用
* @event addBody
* @param {Body} body
*/
addBodyEvent: {
type: string;
body: Body;
};
/**
* Body移除时调用
* @event removeBody
* @param {Body} body
*/
removeBodyEvent: {
type: string;
body: Body;
};
/**
* Spring 加入时调用
* @event addSpring
* @param {Spring} spring
*/
addSpringEvent: {
type: string;
spring: Spring;
};
/**
* 当两个刚体第一次碰撞时调用。调用时碰撞步骤已经完成
* @event impact
* @param {Body} bodyA
* @param {Body} bodyB
*/
impactEvent: {
type: string;
bodyA: Body;
bodyB: Body;
shapeA: Shape;
shapeB: Shape;
contactEquation: ContactEquation;
};
/**
* 当 Broadphase 手机对碰之后被调用
* @event postBroadphase
* @param {Array} 对碰数组
*/
postBroadphaseEvent: {
type: string;
pairs: Body[];
};
/**
* 当两个形状重叠时调用
* @event beginContact
* @param {Shape} shapeA
* @param {Shape} shapeB
* @param {Body} bodyA
* @param {Body} bodyB
* @param {Array} contactEquations
*/
beginContactEvent: {
type: string;
shapeA: Shape;
shapeB: Shape;
bodyA: Body;
bodyB: Body;
contactEquations: ContactEquation[];
};
/**
* 当两个形状停止重叠时调用
* @event endContact
* @param {Shape} shapeA
* @param {Shape} shapeB
* @param {Body} bodyA
* @param {Body} bodyB
*/
endContactEvent: {
type: string;
shapeA: Shape;
shapeB: Shape;
bodyA: Body;
bodyB: Body;
};
/**
* Fired just before equations are added to the solver to be solved. Can be used to control what equations goes into the solver.
* @event preSolve
* @param {Array} contactEquations An array of contacts to be solved.
* @param {Array} frictionEquations An array of friction equations to be solved.
*/
preSolveEvent: {
type: string;
contactEquations: ContactEquation[];
frictionEquations: FrictionEquation[];
};
/**
* 从不让刚体睡眠
* @static
* @property {number} NO_SLEEPING
*/
static NO_SLEEPING: number;
/**
* 刚体睡眠
* @static
* @property {number} BODY_SLEEPING
*/
static BODY_SLEEPING: number;
/**
* 取消激活在接触中的刚体,如果所有刚体都接近睡眠。必须设置 World.islandSplit
* @static
* @property {number} ISLAND_SLEEPING
*/
static ISLAND_SLEEPING: number;
constructor(options?: {
solver?: Solver;
gravity?: number[];
broadphase?: Broadphase;
islandSplit?: boolean;
});
/**
* For keeping track of what time step size we used last step
* @property lastTimeStep
* @type {number}
*/
lastTimeStep: number;
overlapKeeper: OverlapKeeper;
/**
* If the length of .gravity is zero, and .useWorldGravityAsFrictionGravity=true, then switch to using .frictionGravity for friction instead. This fallback is useful for gravityless games.
* @property {boolean} useFrictionGravityOnZeroGravity
* @default true
*/
useFrictionGravityOnZeroGravity: boolean;
/**
* 所有 Spring
* @property springs
* @type {Array}
*/
springs: Spring[];
/**
* 所有 Body
* @property {Array} bodies
*/
bodies: Body[];
/**
* 所使用的求解器,以满足约束条件和接触。 默认值是 GSSolver
* @property {Solver} solver
*/
solver: Solver;
/**
* @property narrowphase
* @type {Narrowphase}
*/
narrowphase: Narrowphase;
/**
* The island manager of this world.
* @property {IslandManager} islandManager
*/
islandManager: IslandManager;
/**
* 重力。在每个 step() 开始对所有刚体生效
*
* @property gravity
* @type {Array}
*/
gravity: number[];
/**
* 重力摩擦
* @property {Number} frictionGravity
*/
frictionGravity: number;
/**
* 设置为true,frictionGravity 会被自动设置为 gravity 长度.
* @property {Boolean} useWorldGravityAsFrictionGravity
*/
useWorldGravityAsFrictionGravity: boolean;
/**
* @property broadphase
* @type {Broadphase}
*/
broadphase: Broadphase;
/**
* 用户添加限制
*
* @property constraints
* @type {Array}
*/
constraints: Constraint[];
/**
* 默认材料,defaultContactMaterial 时使用
* @property {Material} defaultMaterial
*/
defaultMaterial: Material;
/**
* 使用的默认接触材料,如果没有接触材料被设置为碰撞的材料
* @property {ContactMaterial} defaultContactMaterial
*/
defaultContactMaterial: ContactMaterial;
/**
* 设置自动使用弹簧力
* @property applySpringForces
* @type {Boolean}
*/
applySpringForces: boolean;
/**
* 设置自动使用阻尼
* @property applyDamping
* @type {Boolean}
*/
applyDamping: boolean;
/**
* 设置自动使用重力
* @property applyGravity
* @type {Boolean}
*/
applyGravity: boolean;
/**
* 使用约束求解
* @property solveConstraints
* @type {Boolean}
*/
solveConstraints: boolean;
/**
* 接触材料
* @property contactMaterials
* @type {Array}
*/
contactMaterials: ContactMaterial[];
/**
* 世界时间
* @property time
* @type {Number}
*/
time: number;
/**
* 是否正在 step 阶段
* @property {Boolean} stepping
*/
stepping: boolean;
/**
* 是否启用岛内分裂
* @property {Boolean} islandSplit
*/
islandSplit: boolean;
/**
* 设置为true,world会派发 impact 事件,关闭可以提高性能
* @property emitImpactEvent
* @type {Boolean}
*/
emitImpactEvent: boolean;
/**
* 刚体睡眠策略。取值是 World.NO_SLEEPING,World.BODY_SLEEPING,World.ISLAND_SLEEPING 之一
* @property sleepMode
* @type {number}
* @default World.NO_SLEEPING
*/
sleepMode: number;
/**
* 添加约束
* @method addConstraint
* @param {Constraint} constraint
*/
addConstraint(constraint: Constraint): void;
/**
* 添加触点材料
* @method addContactMaterial
* @param {ContactMaterial} contactMaterial
*/
addContactMaterial(contactMaterial: ContactMaterial): void;
/**
* 移除触点材料
* @method removeContactMaterial
* @param {ContactMaterial} cm
*/
removeContactMaterial(cm: ContactMaterial): void;
/**
* 通过2个材料获得触点材料
* @method getContactMaterial
* @param {Material} materialA
* @param {Material} materialB
* @return {ContactMaterial} 获得的触点材料或者false
*/
getContactMaterial(materialA: Material, materialB: Material): ContactMaterial;
/**
* 移除约束
* @method removeConstraint
* @param {Constraint} constraint
*/
removeConstraint(constraint: Constraint): void;
/**
* 使物理系统向前经过一定时间
*
* @method step
* @param {Number} dt 时长
* @param {Number} [timeSinceLastCalled=0]
* @param {Number} [maxSubSteps=10]
*
* @example
* var world = new World();
* world.step(0.01);
*/
step(dt: number, timeSinceLastCalled?: number, maxSubSteps?: number): void;
/**
* 添加一个 Spring
*
* @method addSpring
* @param {Spring} spring
*/
addSpring(spring: Spring): void;
/**
* 移除一个 Spring
*
* @method removeSpring
* @param {Spring} spring
*/
removeSpring(spring: Spring): void;
/**
* 添加一个 Body
*
* @method addBody
* @param {Body} body
*
* @example
* var world = new World(),
* body = new Body();
* world.addBody(body);
*/
addBody(body: Body): void;
/**
* 移除一个 Body。如果在 step()阶段调用,将会在阶段之后移除
*
* @method removeBody
* @param {Body} body
*/
removeBody(body: Body): void;
/**
* 通过id获取一个 Body
* @method getBodyById
* @return {Body|Boolean} 得到的刚体或者false
*/
getBodyByID(id: number): Body;
/**
* 两个刚体之间禁用碰撞
* @method disableBodyCollision
* @param {Body} bodyA
* @param {Body} bodyB
*/
disableBodyCollision(bodyA: Body, bodyB: Body): void;
/**
* 两个刚体之间启用碰撞
* @method enableBodyCollision
* @param {Body} bodyA
* @param {Body} bodyB
*/
enableBodyCollision(bodyA: Body, bodyB: Body): void;
/**
* 重置 world
* @method clear
*/
clear(): void;
/**
* Test if a world point overlaps bodies
* @method hitTest
* @param {Array} worldPoint Point to use for intersection tests
* @param {Array} bodies A list of objects to check for intersection
* @param {number} precision Used for matching against particles and lines. Adds some margin to these infinitesimal objects.
* @return {Array} Array of bodies that overlap the point
*/
hitTest(worldPoint: number[], bodies: Body[], precision: number): Body[];
/**
* Ray cast against all bodies in the world.
* @method raycast
* @param {RaycastResult} result
* @param {Ray} ray
* @return {boolean} True if any body was hit.
*/
raycast(result: RaycastResult, ray: Ray): boolean;
/**
* Runs narrowphase for the shape pair i and j.
* @method runNarrowphase
* @param {Narrowphase} np
* @param {Body} bi
* @param {Shape} si
* @param {Array} xi
* @param {number} ai
* @param {Body} bj
* @param {Shape} sj
* @param {Array} xj
* @param {number} aj
* @param {number} mu
*/
runNarrowphase(np:Narrowphase, bi:Body, si:Shape, xi:number[], ai:number, bj:Body, sj:Shape, xj:number[], aj:number, mu:number): void;
/**
* Set the relaxation for all equations and contact materials.
* @method setGlobalRelaxation
* @param {number} relaxation
*/
setGlobalRelaxation(relaxation: number): void;
/**
* Set the stiffness for all equations and contact materials.
* @method setGlobalStiffness
* @param {Number} stiffness
*/
setGlobalStiffness(stiffness: number): void;
}
}
\ No newline at end of file
export let props: any = {};
export function prepareProps() {
let metaProps = getProps();
engine.injectProp(props, metaProps);
}
export function injectProps(p) {
engine.injectProp(props, p);
}
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -13,7 +13,7 @@ export class GameWrapper extends engine.Container { ...@@ -13,7 +13,7 @@ export class GameWrapper extends engine.Container {
super(); super();
engine.globalEvent.addEventListener('dxbcyj-game-start', this.start, this); engine.globalEvent.addEventListener('dxbcyj-game-start', this.start, this);
engine.globalEvent.addEventListener('dxbcyj-game-revive',this.revive);
let gameView = this._gameView = new GameView(); let gameView = this._gameView = new GameView();
this.addChild(gameView); this.addChild(gameView);
...@@ -23,7 +23,4 @@ export class GameWrapper extends engine.Container { ...@@ -23,7 +23,4 @@ export class GameWrapper extends engine.Container {
start(event: engine.Event) { start(event: engine.Event) {
this._gameView.start(event.data.guide); this._gameView.start(event.data.guide);
} }
revive(){
this._gameView.revive();
}
} }
/**
* Created by renjianfeng on 2020-03-13.
*/
const customId = 'getAwayFromCloud';
(async function () {
let customModule = await fetch(`../meta.json`);
customModule = await customModule.json();
console.log(customModule);
await loadAssets(customModule.assets);
launchWithCustomModule(customModule);
})();
function launchWithCustomModule(customModule) {
//engine.registerCustomCodeModule(customModule);
engine.registerCustomModule(customId, window[customId]);
const { props: propsOption, assets } = customModule;
let props = engine.computeProps(customModuleProps, propsOption);
const customModuleIns = {
id: customId,
props,
assets,
};
engine.registerCustomModules([customModuleIns]);
engine.launchWithConfig({
options: {
entrySceneView: 'entry',
},
assets: [],
views: [{
name: 'entry',
type: 'node',
properties: {
x: 0,
y: 0,
}
}],
customs: [],
}, null, function () {
setTimeout(() => {
engine.addCustomModule(customId, engine.gameStage.sceneContainer.getChildAt(0));
}, 100);
setTimeout(() => {
engine.globalEvent.dispatchEvent('pictures-start', {
});
// const d = engine.gameStage.sceneContainer.getChildAt(0);
// engine.gameStage.sceneContainer.getChildAt(0).x = (d.stage.width-props.W)/2;
// engine.gameStage.sceneContainer.getChildAt(0).y = (d.stage.height-props.H)/2;
}, 1000);
// setTimeout(() => {
// engine.globalEvent.dispatchEvent('pictures-start', {
// picUrl: "http://yun.duiba.com.cn/aurora/assets/e1593b97c27077b85b92f7eaaeae1ed64a1eb79a.png",
// // picUrl: "http://yun.duiba.com.cn/aurora/assets/d23e73d37ec01931e48cbd0a4095367044c5675c.png"
// blockUrl: "888"
// });
// }, 30*1000);
});
engine.globalEvent.addEventListener('cloud-time-update', (e) => {
// console.log(e.type, e.data);
});
engine.globalEvent.addEventListener('cloud-game-fail', (e) => {
console.log(e.type, e.data);
});
engine.globalEvent.addEventListener('cloud-game-success', (e) => {
console.log(e.type, e.data);
});
}
function getAssetByUUID(uuid) {
return engine.resolveCustomAsset(customId, uuid);
}
function getProps() {
return engine.getProps(customId);
}
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<title>美食从天而降</title>
<meta name="viewport"
content="width=device-width,initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no"/>
<meta name="apple-mobile-web-app-capable" content="yes"/>
<meta name="full-screen" content="true"/>
<meta name="screen-orientation" content="portrait"/>
<meta name="x5-fullscreen" content="true"/>
<meta name="360-fullscreen" content="true"/>
<style>
html,
body {
padding: 0;
margin: 0;
border: 0;
width: 100%;
height: 100%;
overflow: hidden;
position: absolute;
background-color: gray;
}
.game-container{
width: 100%;
height: 100%;
line-height:0;
font-size:0;
}
</style>
</head>
<body>
<div id="game-container" class="game-container"></div>
<!-- <script crossorigin="anonymous" src="//yun.duiba.com.cn/editor/zeroing/libs/engine.1de84ff79dba19e949088de63aa75af51a515e5c.js"></script>
<script crossorigin="anonymous" src="//yun.duiba.com.cn/editor/zeroing/libs/svga.fd3923ae6e664251ca7981801a65809cc5f36bc3.js"></script> -->
<script crossorigin="anonymous" src="//yun.duiba.com.cn/editor/zeroing/libs/engine.cba09e24bd26909e1a67685a889d4799f4c2597a.js"></script>
<script crossorigin="anonymous" src="//yun.duiba.com.cn/editor/zeroing/libs/svga.bbb584f45f3ee647d0611653cb854c5d5bb8fb47.js"></script>
<!-- <script src="//yun.duiba.com.cn/editor/zeroing/libs/engine.ebc906f6b50b8da0a669f77027981d5f3cb560ce.js"></script> -->
<!-- <script src="http://localhost:4002/debug/engine.js"></script>
<script src="http://localhost:4003/debug/engine-svga.js"></script> -->
<!--<script src="//yun.duiba.com.cn/editor/zeroing/libs/engine.9a9dbfda4cb2dd5508ecddfe3d95dfd88063f7b5.js"></script>-->
<script src="app.js"></script>
<script src="props.js"></script>
<script src="load-assets.js"></script>
<script src="main.js"></script>
<script>
</script>
</body>
/**
* Created by rockyl on 2020-01-21.
*/
const assets = [
{
"name": "玩家icon",
"url": "//yun.duiba.com.cn/aurora/assets/5b3e30496b2d9fdafb0cf3835fd6704ce10e45b4.png",
"uuid": "888",
"ext": ".png"
},
{
"name": "雨滴",
"url": "//yun.duiba.com.cn/aurora/assets/8564c8c9be3aead71b05a0bab8d7d07ac3f778a1.png",
"uuid": "264a6192-d7bf-45e8-8f15-6ba2c439a532",
"ext": ".png"
},
{
"name": "炸弹",
"url": "//yun.duiba.com.cn/aurora/assets/171e92283cd13c013ee1b76d28d252ff08815d47.png",
"uuid": "eb88b42d-e151-4c1b-94b9-7c16f7bfac29",
"ext": ".png"
},
{
"name": "石块",
"url": "//yun.duiba.com.cn/aurora/assets/99b0af0c59fe79a415a3f032149cfacc27e3ac2c.png",
"uuid": "ab1bdabc-21ba-46bf-9299-6c638f766c88",
"ext": ".png"
},
{
"name": "水花",
"url": "//yun.duiba.com.cn/aurora/assets/93d37b4a0e367e80e375308a6b4414d72d7666fc.svga",
"uuid": "b521bf94-20e1-44dd-8eca-d24996cbaeae",
"ext": ".svga"
},
{
"name": "炸弹",
"url": "//yun.duiba.com.cn/aurora/assets/4dd18f0689c663bbcf710a7afc4d929084d97d36.svga",
"uuid": "322edf39-805b-4e84-9d07-5573dfeebc0e",
"ext": ".svga"
},
{
"name": "玩家",
"url": "//yun.duiba.com.cn/aurora/assets/b66300c5d4f27134b0aac3dc90a3220e8ae572eb.svga",
"uuid": "71d8dcbc-3931-471a-b585-b3ae01b25aa6",
"ext": ".svga"
}
];
function loadAssets(customModuleAssets, onProgress, onComplete){
return engine.loadAssets(assets.concat(...customModuleAssets), onProgress, onComplete);
}
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('tslib')) :
typeof define === 'function' && define.amd ? define(['tslib'], factory) :
(global = global || self, global.getAwayFromCloud = factory(global.tslib));
}(this, (function (tslib) { 'use strict';
function getTexture(uuid) {
return engine.Texture.from(getAssetByUUID(uuid).uuid);
}
function createSvga(name, anchorName) {
var inst = new svga.Svga();
inst.source = 'asset://' + engine.getAssetByName(name).uuid;
return inst;
}
//# sourceMappingURL=utils.js.map
var Human = (function (_super) {
tslib.__extends(Human, _super);
function Human() {
var _this = _super.call(this) || this;
_this.humanArray = [
'487c1ca7-dea5-4732-b4b6-acb5406ee3a4',
'71e07cee-fd6d-40bb-ac0b-5bb28c87276e',
'2cd9f1bb-d0d8-42ea-941b-dcd0428e474d'
];
_this.human = new engine.Sprite(getTexture(_this.humanArray[0]));
_this.addChild(_this.human);
_this.width = _this.human.width;
_this.height = _this.human.height;
return _this;
}
Human.prototype.facialChange = function (num) {
var face = new engine.Sprite(getTexture(this.humanArray[num]));
this.human.addChild(face);
return face;
};
Human.prototype.removeFace = function (face) {
this.human.removeChild(face);
};
Human.prototype.scaleEffect = function () {
var _this = this;
var aaa = 0;
var pt = Date.now();
this.addEventListener(engine.Event.ENTER_FRAME, function () {
var dt = Date.now() - pt;
aaa += dt;
_this.anchorX = _this.width + _this.width / 2;
_this.anchorY = _this.height;
if (aaa > 90 && aaa <= 100) {
_this.scaleY = 0.99;
_this.scaleX = 1.01;
}
if (aaa > 190 && aaa < 200) {
_this.scaleX = 1;
_this.scaleY = 1;
aaa = 0;
}
pt = Date.now();
});
};
return Human;
}(engine.Container));
//# sourceMappingURL=Human.js.map
var Moist = (function (_super) {
tslib.__extends(Moist, _super);
function Moist() {
var _this = _super.call(this) || this;
_this.moistBg = new engine.Sprite(getTexture('8a8e79b6-2c6f-441b-81ae-c441465abfb0'));
_this.moist = new engine.Sprite(getTexture('024d67e9-ed7f-4481-94ca-a15bd5226cad'));
_this.moistCover = new engine.Sprite(getTexture('024d67e9-ed7f-4481-94ca-a15bd5226cad'));
_this.txt = new engine.TextInput();
_this.hintpic = new engine.Sprite(getTexture('ed0e8931-2557-4527-bcfc-9071f90d5737'));
_this.percent = 0;
_this.addChild(_this.moistBg);
_this.moistBg.addChild(_this.moist);
_this.moist.mask = _this.moistCover;
_this.txt.text = _this.percent * 100 + '%';
_this.txt.size = 30;
_this.txt.fillColor = '#7A83C5';
_this.addChild(_this.txt);
_this.txt.x = 0;
_this.txt.y = -50;
_this.hintpic.x = -10;
_this.hintpic.y = 440;
_this.addChild(_this.hintpic);
return _this;
}
Moist.prototype.cover = function (percent) {
this.moistCover.anchorY = 416;
this.moistBg.addChild(this.moistCover);
this.moistCover.scaleY = percent;
var t = engine.Tween.get(this.moistCover);
};
Moist.prototype.stopScale = function () {
this.moistCover.scaleY = 1;
this.txt.text = '100%';
};
Moist.prototype.updateText = function (percent) {
var a = percent * 100;
if (a <= 90) {
this.txt.text = a.toPrecision(2) + '%';
}
else {
this.txt.text = a.toPrecision(3) + '%';
}
};
Moist.prototype.updatePercent = function (percent) {
this.percent = percent;
};
return Moist;
}(engine.Container));
//# sourceMappingURL=Moist.js.map
var TimeCounter = (function (_super) {
tslib.__extends(TimeCounter, _super);
function TimeCounter() {
var _this = _super.call(this) || this;
_this.timeCounter = new engine.Sprite(getTexture('b7d2a60a-9e60-4eca-be80-a991abea47c9'));
_this.time = 20;
_this.addChild(_this.timeCounter);
_this.timeCounter.x = 256;
_this.timeCounter.y = 50;
_this.timeText = new engine.TextInput();
_this.timeText.text = _this.time + 's';
_this.timeText.size = 48;
_this.timeText.fillColor = '#7A83C5';
_this.timeCounter.addChild(_this.timeText);
_this.timeText.x = 100;
_this.timeText.y = 15;
return _this;
}
TimeCounter.prototype.updateTime = function (time) {
this.time = time;
this.timeText.text = this.time + 's';
};
return TimeCounter;
}(engine.Container));
//# sourceMappingURL=TimeCounter.js.map
var CloudRain = (function (_super) {
tslib.__extends(CloudRain, _super);
function CloudRain() {
var _this = _super.call(this) || this;
_this.clound1 = new engine.Sprite(getTexture('1e1a6993-9da0-4813-b1bd-00f2dbae2af2'));
_this.clound2 = new engine.Sprite(getTexture('6ed0e2e7-3ba3-4967-8fe0-39667792e343'));
_this.sun = new engine.Sprite(getTexture("0f05aaae-338a-439a-82b0-20efcee5cca4"));
_this.sun.x = 90;
_this.sun.y = 120;
_this.addChild(_this.sun);
_this.addChild(_this.clound1);
_this.addChild(_this.clound2);
_this.clound1.x = 100;
_this.clound1.y = 220;
_this.clound2.x = 150;
_this.clound2.y = 220;
return _this;
}
CloudRain.prototype.succeed = function () {
var _this = this;
var a = 0;
var ld = Date.now();
this.addEventListener(engine.Event.ENTER_FRAME, function () {
var dt = Date.now() - ld;
a += dt;
if (a > 100) {
_this.clound1.x -= (800 * dt) / 1000;
_this.clound2.x += (820 * dt) / 1000;
if (_this.clound1.x <= -380) {
_this.clound1.x = -380;
}
if (_this.clound2.x >= 750) {
_this.clound2.x = 750;
}
_this.sun.y -= (150 * dt) / 1000;
if (_this.sun.y <= 60) {
_this.sun.y = 60;
}
}
ld = Date.now();
});
};
return CloudRain;
}(engine.Container));
//# sourceMappingURL=CloudRain.js.map
var GameTest = (function (_super) {
tslib.__extends(GameTest, _super);
function GameTest() {
var _this = _super.call(this) || this;
_this.timeArray = [];
_this.container = new engine.Container();
_this.dripArray = [];
_this.clicknum = 0;
_this.R = 250;
_this.D = 340;
_this.con = new engine.Sprite();
_this.t1 = new engine.Sprite(getTexture('a163b74f-32bc-43d2-8015-7cf1eac71501'));
_this.t2 = new engine.Sprite(getTexture('22de82d1-97ec-4195-a32c-f4fc1656e2de'));
_this.t3 = new engine.Sprite(getTexture('cc952365-a990-4912-98af-50905559b9d5'));
_this.once(engine.Event.ADDED_TO_STAGE, _this.setup, _this);
return _this;
}
GameTest.prototype.setup = function () {
var playBg = new engine.Sprite(getTexture("5ab43bdc-a6ce-46fb-99c2-a806f57f7484"));
this.addChild(playBg);
this.humanbeing = new Human();
this.humanbeing.x = 290;
this.humanbeing.y = 750;
this.addChild(this.humanbeing);
console.log("xxxxxx", this.stage.width, this.stage.height, this.width, this.height);
this.rightHand = new engine.Sprite(getTexture("c7129f77-92a6-479e-9994-7d4b39040a15"));
this.rightHand.x = -70;
this.rightHand.y = -65;
this.rightHand.anchorX = 196;
this.rightHand.anchorY = 253;
this.humanbeing.addChild(this.rightHand);
this.playBtn = new engine.Sprite(getTexture("9e347bef-6e91-4c92-ba5f-f9a52e656207"));
this.playBtn.x = 138;
this.playBtn.y = 1150;
this.playBtn.anchorX = this.playBtn.x + this.playBtn.width / 2;
this.playBtn.anchorY = this.playBtn.y + this.playBtn.height / 2;
this.addChild(this.playBtn);
this.moists = new Moist();
this.moists.x = 20;
this.moists.y = 450;
this.addChild(this.moists);
this.cloud = new CloudRain();
this.addChild(this.cloud);
this.timeArray.push(this.t3, this.t2, this.t1);
};
GameTest.prototype.start = function () {
var _this = this;
var middleX = this.humanbeing.x + this.humanbeing.width / 2;
var validX1 = this.humanbeing.x;
var validX2 = this.humanbeing.x + this.humanbeing.width;
var point1 = new engine.Graphics();
point1.beginFill(0xff0000);
point1.drawRect(0, 0, 10, 10);
point1.x = 0;
point1.y = 100;
point1.endFill();
this.rightHand.addChild(point1);
var point2 = new engine.Graphics();
point2.beginFill(0xff0000);
point2.drawRect(0, 0, 10, 10);
point2.x = 170;
point2.y = 0;
point2.endFill();
this.rightHand.addChild(point2);
var point3 = new engine.Graphics();
point3.beginFill(0xff0000);
point3.drawRect(0, 0, 10, 10);
point3.x = 330;
point3.y = 100;
point3.endFill();
this.rightHand.addChild(point3);
window['p1'] = point1;
window['p2'] = point2;
window['p3'] = point3;
this.timeCounter = new TimeCounter();
this.addChild(this.timeCounter);
var ld = Date.now();
var a = 0;
var b = 0;
var timer = 0;
var succeedFlag = false;
var failFlag = false;
for (var i = 0; i < this.timeArray.length; i++) {
var t = this.timeArray[i];
t.anchorTexture.set(0.5, 0.5);
t.x = 750 / 2;
t.y = 1624 / 2;
t.alpha = 0;
this.container.addChild(t);
this.addChild(this.container);
}
for (var i = 0; i < this.timeArray.length; i++) {
var img = this.timeArray[i];
var delta = i * 1000;
var t = engine.Tween.get(img);
t.wait(delta).set({ alpha: 0.2, scaleX: 2, scaleY: 2 })
.to({ alpha: 1, scaleX: 1, scaleY: 1 }, 300)
.to({ alpha: 0 }, 200)
.wait(500);
if (i === this.timeArray.length - 1) {
t.call(function () {
engine.Tween.get(_this.container).to({ alpha: 0 }, 200).call(function () {
_this.removeChild(_this.container);
});
_this.winds = createSvga("wind");
_this.addChild(_this.winds);
_this.winds.visible = true;
_this.winds.play(true, true);
_this.winds.once(engine.Event.END_FRAME, function () {
_this.removeChild(_this.winds);
}, _this);
});
}
}
this.rainEffect = createSvga("雨滴动效");
this.addEventListener(engine.Event.ENTER_FRAME, function addFrame() {
var _this = this;
var dt = Date.now() - ld;
b += dt;
timer += dt;
if (timer >= 3000) {
a += dt;
if (a > 10) {
a = 0;
if (this.moists.percent < 1 && this.timeCounter.time > 0) {
var drip = new engine.Sprite(getTexture("07f74bf6-416f-445e-98d5-021efe4c9fdc"));
drip.x = Math.random() * (this.humanbeing.x + 160) + (this.humanbeing.x - 160);
drip.y = Math.random() * 100 + 300;
this.dripArray.push(drip);
this.addChild(drip);
}
}
var _loop_1 = function (drip) {
drip.y += (300 * dt) / 1000;
if (drip.y > this_1.stage.height) {
var index_1 = this_1.dripArray.indexOf(drip);
this_1.removeChild(drip);
this_1.dripArray = this_1.dripArray.filter(function (ele, i) { return i != index_1; });
}
};
var this_1 = this;
for (var _i = 0, _a = this.dripArray; _i < _a.length; _i++) {
var drip = _a[_i];
_loop_1(drip);
}
if (b >= 1000) {
b = 0;
if (this.moists.percent < 1) {
this.timeCounter.time -= 1;
if (this.timeCounter.time <= 0) {
this.timeCounter.time = 0;
}
this.timeCounter.updateTime(this.timeCounter.time);
}
if (this.timeCounter.time <= 0 && !succeedFlag) {
this.timeCounter.time = 0;
succeedFlag = true;
console.log("游戏成功!");
this.success();
}
}
var wind = -40;
this.rightHand.rotation += wind / 60;
if (this.rightHand.rotation <= -90) {
this.rightHand.rotation = -90;
}
else if (this.rightHand.rotation >= 90) {
this.rightHand.rotation = 90;
}
if (this.rightHand.rotation <= -60) {
var face_1 = this.humanbeing.facialChange(1);
face_1.x = 7;
face_1.y = 22;
setTimeout(function () {
_this.humanbeing.removeFace(face_1);
}, 100);
}
this.angle = Math.asin(this.D / 2 / this.R) * 57.18;
this.rightHand.name = "aaa";
var sa = this.worldMatrix.a;
var sd = this.worldMatrix.d;
var p1x = point1.worldMatrix.tx / sa;
var p2x = point2.worldMatrix.tx / sa;
var p3x = point3.worldMatrix.tx / sa;
var p1y = point1.worldMatrix.ty / sd;
var p2y = point2.worldMatrix.ty / sd;
var p3y = point3.worldMatrix.ty / sd;
var k12 = (p1y - p2y) / (p1x - p2x);
var k23 = (p2y - p3y) / (p2x - p3x);
var px1 = p1x;
var px2 = p2x;
var px3 = p3x;
var maxX = px1 >= px2 ? (px1 >= px3 ? px1 : px3) : px2 >= px3 ? px2 : px3;
var minX = px1 >= px2 ? (px2 >= px3 ? px3 : px2) : px1 >= px3 ? px3 : px1;
var x2 = (middleX + this.R) < maxX ? (middleX + this.R) : maxX;
var _loop_2 = function (drip) {
var dx = drip.worldMatrix.tx / sa;
var dy = drip.worldMatrix.ty / sd;
var b12 = p1y - p1x * k12 - 50;
var b23 = p2y - p2x * k23 - 50;
var y12 = k12 * dx + b12;
var y23 = k23 * dx + b23;
if (dx >= minX && dx < maxX) {
if (dx < px2) {
if (dy >= y12) {
var index_2 = this_2.dripArray.indexOf(drip);
this_2.removeChild(drip);
this_2.dripArray = this_2.dripArray.filter(function (ele, i) { return i != index_2; });
}
}
if (dx >= px2) {
if (dy >= y23) {
var index_3 = this_2.dripArray.indexOf(drip);
this_2.removeChild(drip);
this_2.dripArray = this_2.dripArray.filter(function (ele, i) { return i != index_3; });
}
}
}
if (drip.x > this_2.humanbeing.x &&
drip.x < this_2.humanbeing.x + this_2.humanbeing.width) {
if (drip.y >= this_2.humanbeing.y) {
this_2.moists.percent += 0.1;
this_2.moists.cover(this_2.moists.percent);
this_2.moists.updateText(this_2.moists.percent);
this_2.addChild(this_2.rainEffect);
this_2.rainEffect.visible = true;
this_2.rainEffect.play(true, true);
this_2.rainEffect.x = drip.x - drip.width * 2;
this_2.rainEffect.y = drip.y;
this_2.rainEffect.once(engine.Event.END_FRAME, function () {
_this.rainEffect.visible = false;
});
if (this_2.moists.percent >= 1 && !failFlag) {
this_2.moists.stopScale();
failFlag = true;
console.log("游戏结束!");
this_2.stop();
}
this_2.removeChild(drip);
var face_2 = this_2.humanbeing.facialChange(2);
face_2.x = 7;
face_2.y = 22;
setTimeout(function () {
_this.humanbeing.removeFace(face_2);
}, 500);
console.log("人");
var index_4 = this_2.dripArray.indexOf(drip);
this_2.dripArray = this_2.dripArray.filter(function (ele, i) { return i != index_4; });
this_2.humanbeing.scaleEffect();
}
}
};
var this_2 = this;
for (var _b = 0, _c = this.dripArray; _b < _c.length; _b++) {
var drip = _c[_b];
_loop_2(drip);
}
}
ld = Date.now();
});
this.playBtn.addEventListener(engine.MouseEvent.CLICK, this.onClick, this);
this.rightHand.rotation = 0;
};
GameTest.prototype.onClick = function () {
this.clicknum += 1;
this.rightHand.rotation += 10 * this.clicknum;
this.clicknum = 0;
};
GameTest.prototype.stop = function () {
engine.globalEvent.dispatchEvent("cloud-game-fail", { reason: 1 });
};
GameTest.prototype.success = function () {
this.cloud.succeed();
engine.globalEvent.dispatchEvent("cloud-game-success", {
moist: this.moists.percent,
});
};
return GameTest;
}(engine.Container));
var props = {};
function prepareProps() {
var metaProps = getProps();
engine.injectProp(props, metaProps);
}
function injectProps(p) {
engine.injectProp(props, p);
}
//# sourceMappingURL=props.js.map
var GameWrapper = (function (_super) {
tslib.__extends(GameWrapper, _super);
function GameWrapper() {
var _this = _super.call(this) || this;
engine.globalEvent.addEventListener('pictures-start', _this.start, _this);
engine.globalEvent.addEventListener('pictures-stop', _this.stop, _this);
var gameTest = _this._gameTest = new GameTest();
_this.addChild(gameTest);
return _this;
}
GameWrapper.prototype.start = function (event) {
injectProps(event.data);
this._gameTest.start();
};
GameWrapper.prototype.stop = function (event) {
this._gameTest.stop();
};
return GameWrapper;
}(engine.Container));
//# sourceMappingURL=GameWrapper.js.map
function index (props) {
prepareProps();
injectProps(props);
var instance = new GameWrapper();
return instance;
}
//# sourceMappingURL=index.js.map
return index;
})));
//# sourceMappingURL=main.js.map
\ No newline at end of file
{"version":3,"file":"index.js","sources":["src/custom/getAwayFromCloud/src/game/utils.ts","src/custom/getAwayFromCloud/src/game/Human.ts","src/custom/getAwayFromCloud/src/game/Moist.ts","src/custom/getAwayFromCloud/src/game/TimeCounter.ts","src/custom/getAwayFromCloud/src/game/CloudRain.ts","src/custom/getAwayFromCloud/src/game/GameTest.ts","src/custom/getAwayFromCloud/src/props.ts","src/custom/getAwayFromCloud/src/game/GameWrapper.ts","src/custom/getAwayFromCloud/src/index.ts"],"sourcesContent":["/**\n * Created by rockyl on 2020-01-21.\n */\n\nexport function getTexture(uuid) {\n\treturn engine.Texture.from(getAssetByUUID(uuid).uuid);\n}\n\nexport function getTextureByName(name) {\n\treturn getTexture(engine.getAssetByName(name).uuid);\n}\n\nexport function playSound(name) {\n\tengine.playSound(engine.getAssetByName(name).uuid, {keep: true});\n}\nexport function createSvga(name, anchorName?) {\n\tlet inst = new svga.Svga();\n\tinst.source = 'asset://' + engine.getAssetByName(name).uuid;\n\treturn inst;\n}\n\n\n\nexport function getIndexFromRC(row,col,maxCol){\n\tlet index;\n\tindex = row * maxCol + col ;\n\treturn index\n}\n\n\n\n\nexport function getRandomArray(array){\n\tarray.sort(function() {\n\t\treturn .5 - Math.random();\n\t});\n}","import {getTexture} from './utils'\n\nexport default class Human extends engine.Container{\n \n //常态,吃力,沮丧\n humanArray = [\n '487c1ca7-dea5-4732-b4b6-acb5406ee3a4',\n '71e07cee-fd6d-40bb-ac0b-5bb28c87276e',\n '2cd9f1bb-d0d8-42ea-941b-dcd0428e474d'\n ]\n //三张面部表情\n human:engine.Sprite = new engine.Sprite(getTexture(this.humanArray[0]))\n\n constructor(){\n super();\n this.addChild(this.human)\n this.width = this.human.width;\n this.height = this.human.height;\n }\n\n facialChange(num){\n let face = new engine.Sprite(getTexture(this.humanArray[num]));\n this.human.addChild(face);\n return face;\n }\n\n removeFace(face){\n this.human.removeChild(face);\n }\n\n scaleEffect(){\n let aaa = 0;\n let pt = Date.now();\n this.addEventListener(engine.Event.ENTER_FRAME,()=>{\n let dt = Date.now() -pt;\n aaa += dt;\n this.anchorX = this.width + this.width / 2\n this.anchorY = this.height;\n if(aaa > 90 && aaa<=100 ){\n this.scaleY = 0.99;\n this.scaleX = 1.01;\n }\n\n if(aaa >190 && aaa < 200){\n this.scaleX = 1;\n this.scaleY = 1;\n aaa = 0;\n }\n\n pt = Date.now();\n })\n }\n}","import {getTexture} from './utils'\n\nexport default class Moist extends engine.Container{\n\n percent:number\n moistBg:engine.Sprite = new engine.Sprite(getTexture('8a8e79b6-2c6f-441b-81ae-c441465abfb0'))\n moist:engine.Sprite = new engine.Sprite(getTexture('024d67e9-ed7f-4481-94ca-a15bd5226cad'))\n moistCover:any = new engine.Sprite(getTexture('024d67e9-ed7f-4481-94ca-a15bd5226cad'))\n txt = new engine.TextInput();\n hintpic:engine.Sprite = new engine.Sprite(getTexture('ed0e8931-2557-4527-bcfc-9071f90d5737'))\n\n addPercent:number\n constructor(){\n super();\n this.percent = 0;\n this.addChild(this.moistBg)\n this.moistBg.addChild(this.moist)\n this.moist.mask = this.moistCover;\n\n\n this.txt.text = this.percent*100+'%';\n this.txt.size = 30;\n this.txt.fillColor = '#7A83C5';\n this.addChild(this.txt)\n this.txt.x = 0;\n this.txt.y = -50;\n\n this.hintpic.x = -10;\n this.hintpic.y = 440;\n this.addChild(this.hintpic)\n }\n\n cover(percent){\n this.moistCover.anchorY = 416;\n this.moistBg.addChild(this.moistCover)\n this.moistCover.scaleY = percent;\n let ld = Date.now();\n // let time\n // this.addEventListener(engine.Event.ENTER_FRAME,()=>{\n // let dt = Date.now() - ld;\n // time += dt;\n // if(time >= 100){\n // // this.moistCover.scaleY =\n // }\n // })\n let t = engine.Tween.get(this.moistCover);\n // t.set({alpha:1,scaleY:this.percent})\n // .to({alpha:1,scaleY:percent - 0.08},100)\n // .to({alpha:1,scaleY:percent - 0.06},100)\n // .to({alpha:1,scaleY:percent - 0.04},100)\n // .to({alpha:1,scaleY:percent - 0.02},100)\n // .to({alpha:1,scaleY:percent},100)\n\n }\n\n stopScale(){\n this.moistCover.scaleY = 1;\n this.txt.text = '100%';\n }\n\n updateText(percent){\n let a = percent * 100;\n if(a <=90){\n this.txt.text = a.toPrecision(2)+'%';\n }else{\n this.txt.text = a.toPrecision(3)+'%';\n }\n }\n\n updatePercent(percent){\n this.percent = percent;\n }\n}","import {getTexture} from './utils'\n\nexport default class TimeCounter extends engine.Container{\n timeCounter:engine.Sprite = new engine.Sprite(getTexture('b7d2a60a-9e60-4eca-be80-a991abea47c9'));\n timeText:any;\n time:number\n\n \n constructor(){\n super()\n this.time = 20\n this.addChild(this.timeCounter)\n\n this.timeCounter.x = 256;\n this.timeCounter.y = 50;\n // 计时文本\n this.timeText = new engine.TextInput();\n this.timeText.text = this.time +'s';\n this.timeText.size = 48;\n this.timeText.fillColor = '#7A83C5';\n this.timeCounter.addChild(this.timeText);\n this.timeText.x = 100;\n this.timeText.y = 15;\n\n }\n\n updateTime(time){\n this.time = time;\n this.timeText.text = this.time + 's'\n }\n\n\n}","import {getTexture} from './utils'\n\nexport default class CloudRain extends engine.Container{\n\n clound1:engine.Sprite = new engine.Sprite(getTexture('1e1a6993-9da0-4813-b1bd-00f2dbae2af2'))\n clound2:engine.Sprite = new engine.Sprite(getTexture('6ed0e2e7-3ba3-4967-8fe0-39667792e343'))\n sun = new engine.Sprite(getTexture(\"0f05aaae-338a-439a-82b0-20efcee5cca4\"));\n \n constructor(){\n super()\n this.sun.x = 90;\n this.sun.y = 120;\n this.addChild(this.sun)\n\n this.addChild(this.clound1);\n this.addChild(this.clound2);\n\n this.clound1.x = 100;\n this.clound1.y = 220;\n this.clound2.x = 150;\n this.clound2.y = 220;\n\n }\n\n succeed(){\n // 380 580\n let a = 0\n let ld = Date.now();\n this.addEventListener(engine.Event.ENTER_FRAME,()=>{\n let dt = Date.now() - ld;\n a += dt;\n if(a>100){\n this.clound1.x -= (800 * dt) / 1000;\n this.clound2.x += (820*dt)/1000;\n if(this.clound1.x <= -380){\n this.clound1.x = -380;\n }\n if(this.clound2.x >= 750){\n this.clound2.x = 750;\n }\n\n this.sun.y -= (150 * dt) / 1000;\n if(this.sun.y <= 60){\n this.sun.y = 60;\n }\n }\n ld = Date.now();\n })\n }\n\n\n \n\n\n\n}","import { getTexture, createSvga } from \"./utils\";\n\nimport Human from \"./Human\";\nimport Moist from \"./Moist\";\nimport TimeCounter from \"./TimeCounter\";\nimport CloudRain from \"./CloudRain\";\nimport gameStage = engine.gameStage;\n\nexport default class GameTest extends engine.Container {\n constructor() {\n super();\n this.once(engine.Event.ADDED_TO_STAGE, this.setup, this);\n }\n\n rightHand: engine.Sprite;\n // ambrella: engine.Sprite;\n playBtn: engine.Sprite;\n human: engine.Sprite;\n\n humanbeing: Human;\n moists: Moist;\n contain: any;\n timeCounter: TimeCounter;\n cloudRain: CloudRain;\n cloud: CloudRain;\n winds\n rainEffect\n timeArray: any[] = []\n container: engine.Container = new engine.Container()\n\n setup() {\n let playBg = new engine.Sprite(\n getTexture(\"5ab43bdc-a6ce-46fb-99c2-a806f57f7484\")\n );\n this.addChild(playBg);\n\n // this.human = new engine.Sprite(\n // getTexture(\"487c1ca7-dea5-4732-b4b6-acb5406ee3a4\")\n // );\n // this.human.x = 290;\n // this.human.y = 900;\n // 人\n this.humanbeing = new Human();\n this.humanbeing.x = 290;\n // this.humanbeing.y = 900;\n this.humanbeing.y = 750;\n this.addChild(this.humanbeing);\n\n // this.contain = new engine.Sprite()\n console.log(\n \"xxxxxx\",\n this.stage.width,\n this.stage.height,\n this.width,\n this.height\n );\n\n // 手和伞为一个整体\n this.rightHand = new engine.Sprite(\n getTexture(\"c7129f77-92a6-479e-9994-7d4b39040a15\")\n );\n this.rightHand.x = -70;\n this.rightHand.y = -65;\n this.rightHand.anchorX = 196;\n this.rightHand.anchorY = 253;\n\n this.humanbeing.addChild(this.rightHand);\n\n // this.addChild(this.human);\n // this.human.addChild(this.rightHand);\n\n this.playBtn = new engine.Sprite(\n getTexture(\"9e347bef-6e91-4c92-ba5f-f9a52e656207\")\n );\n this.playBtn.x = 138;\n this.playBtn.y = 1150;\n this.playBtn.anchorX = this.playBtn.x + this.playBtn.width / 2;\n this.playBtn.anchorY = this.playBtn.y + this.playBtn.height / 2;\n this.addChild(this.playBtn);\n // 湿润度\n this.moists = new Moist();\n this.moists.x = 20;\n this.moists.y = 450;\n this.addChild(this.moists);\n\n // 云\n this.cloud = new CloudRain();\n this.addChild(this.cloud);\n\n this.timeArray.push(this.t3, this.t2, this.t1);\n }\n\n dripArray: any[] = [];\n clicknum: number = 0;\n R: number = 250;\n D: number = 340;\n angle: number;\n\n con: engine.Sprite = new engine.Sprite();\n\n // 游戏开始前倒计时三张图\n t1 = new engine.Sprite(getTexture('a163b74f-32bc-43d2-8015-7cf1eac71501'));\n t2 = new engine.Sprite(getTexture('22de82d1-97ec-4195-a32c-f4fc1656e2de'));\n t3 = new engine.Sprite(getTexture('cc952365-a990-4912-98af-50905559b9d5'));\n\n\n start() {\n const middleX = this.humanbeing.x + this.humanbeing.width / 2;\n const validX1 = this.humanbeing.x;\n const validX2 = this.humanbeing.x + this.humanbeing.width;\n\n let point1 = new engine.Graphics();\n point1.beginFill(0xff0000);\n point1.drawRect(0, 0, 10, 10);\n point1.x = 0;\n point1.y = 100;\n point1.endFill();\n // this.addChild(point1)\n this.rightHand.addChild(point1);\n\n let point2 = new engine.Graphics();\n point2.beginFill(0xff0000);\n point2.drawRect(0, 0, 10, 10);\n point2.x = 170;\n point2.y = 0;\n point2.endFill();\n // this.addChild(point2)\n this.rightHand.addChild(point2);\n\n let point3 = new engine.Graphics();\n point3.beginFill(0xff0000);\n point3.drawRect(0, 0, 10, 10);\n point3.x = 330;\n point3.y = 100;\n point3.endFill();\n // this.addChild(point3)\n this.rightHand.addChild(point3);\n\n window['p1'] = point1;\n // @ts-ignore\n window['p2'] = point2;\n window['p3'] = point3;\n\n //计时器\n this.timeCounter = new TimeCounter();\n this.addChild(this.timeCounter);\n\n let ld = Date.now();\n\n let a = 0;\n let b = 0;\n\n let timer = 0;\n\n let succeedFlag = false;\n let failFlag = false;\n\n\n // 倒计时\n for (let i = 0; i < this.timeArray.length; i++) {\n let t = this.timeArray[i]\n t.anchorTexture.set(0.5, 0.5);\n t.x = 750 / 2;\n t.y = 1624 / 2;\n t.alpha = 0;\n this.container.addChild(t);\n this.addChild(this.container)\n }\n for (let i = 0; i < this.timeArray.length; i++) {\n let img = this.timeArray[i];\n let delta = i * 1000;\n let t = engine.Tween.get(img);\n t.wait(delta).set({alpha: 0.2, scaleX: 2, scaleY: 2})\n .to({alpha: 1, scaleX: 1, scaleY: 1}, 300)\n .to({alpha: 0}, 200)\n .wait(500);\n if (i === this.timeArray.length - 1) {\n t.call(() => {\n engine.Tween.get(this.container).to({alpha: 0}, 200).call(() => {\n this.removeChild(this.container)\n })\n\n // 风吹动效\n this.winds = createSvga(\"wind\");\n this.addChild(this.winds);\n this.winds.visible = true;\n this.winds.play(true, true)\n this.winds.once(engine.Event.END_FRAME, () => {\n this.removeChild(this.winds);\n }, this)\n })\n\n }\n }\n\n // 雨滴动效\n this.rainEffect = createSvga(\"雨滴动效\");\n\n this.addEventListener(engine.Event.ENTER_FRAME, function addFrame() {\n let dt = Date.now() - ld;\n\n b += dt;\n timer += dt;\n\n // 延迟三秒执行\n if (timer >= 3000) {\n a += dt;\n if (a > 10) {\n a = 0;\n if (this.moists.percent < 1 && this.timeCounter.time > 0) {\n let drip = new engine.Sprite(getTexture(\"07f74bf6-416f-445e-98d5-021efe4c9fdc\"));\n drip.x = Math.random() * (this.humanbeing.x + 160) + (this.humanbeing.x - 160);\n drip.y = Math.random() * 100 + 300;\n this.dripArray.push(drip);\n this.addChild(drip);\n }\n\n }\n\n // 雨滴下落\n for (let drip of this.dripArray) {\n drip.y += (300 * dt) / 1000;\n if (drip.y > this.stage.height) {\n let index = this.dripArray.indexOf(drip);\n this.removeChild(drip);\n this.dripArray = this.dripArray.filter(\n (ele, i) => i != index\n );\n }\n }\n\n\n //计时器\n if (b >= 1000) {\n b = 0;\n if (this.moists.percent < 1) {\n this.timeCounter.time -= 1;\n if (this.timeCounter.time <= 0) {\n this.timeCounter.time = 0;\n }\n this.timeCounter.updateTime(this.timeCounter.time);\n }\n\n if (this.timeCounter.time <= 0 && !succeedFlag) {\n this.timeCounter.time = 0;\n succeedFlag = true;\n console.log(\"游戏成功!\");\n // 云动画\n // 雨水结束\n // 太阳出来\n this.success();\n // this.removeEventListener(engine.Event.END_FRAME,()=>{})\n // if(succeedFlag){\n // }\n }\n }\n\n // 伞的旋转\n let wind = -40;\n this.rightHand.rotation += wind / 60;\n\n if (this.rightHand.rotation <= -90) {\n this.rightHand.rotation = -90;\n } else if (this.rightHand.rotation >= 90) {\n this.rightHand.rotation = 90;\n }\n\n // 吃力表情\n if (this.rightHand.rotation <= -60) {\n let face = this.humanbeing.facialChange(1);\n face.x = 7;\n face.y = 22;\n setTimeout(() => {\n this.humanbeing.removeFace(face);\n }, 100);\n }\n\n // ld = Date.now();\n\n // return;\n // 扇形的角度\n this.angle = Math.asin(this.D / 2 / this.R) * 57.18;\n\n // 伞的偏移角度距离水平位置\n let validMaxX;\n let validMinX;\n // 伞的圆函数\n let ambrellaFuncY;\n\n this.rightHand.name = \"aaa\";\n\n // a.worldMatrix.tx\n\n // point1,2线性方程斜率\n\n const sa = this.worldMatrix.a;\n const sd = this.worldMatrix.d;\n\n const p1x = point1.worldMatrix.tx / sa;\n const p2x = point2.worldMatrix.tx / sa;\n const p3x = point3.worldMatrix.tx / sa;\n const p1y = point1.worldMatrix.ty / sd;\n const p2y = point2.worldMatrix.ty / sd;\n const p3y = point3.worldMatrix.ty / sd;\n\n let k12 = (p1y - p2y) / (p1x - p2x);\n let k23 = (p2y - p3y) / (p2x - p3x);\n\n let px1 = p1x;\n let px2 = p2x;\n let px3 = p3x;\n\n let maxX = px1 >= px2 ? (px1 >= px3 ? px1 : px3) : px2 >= px3 ? px2 : px3;\n let minX = px1 >= px2 ? (px2 >= px3 ? px3 : px2) : px1 >= px3 ? px3 : px1;\n\n let x2 = (middleX + this.R) < maxX ? (middleX + this.R) : maxX;\n\n for (let drip of this.dripArray) {\n\n const dx = drip.worldMatrix.tx / sa;\n const dy = drip.worldMatrix.ty / sd;\n\n // point1,2线性方程\n let b12 = p1y - p1x * k12 - 50;\n let b23 = p2y - p2x * k23 - 50;\n let y12 = k12 * dx + b12;\n let y23 = k23 * dx + b23;\n if (dx >= minX && dx < maxX) {\n // 伞碰撞12\n if (dx < px2) {\n // if (Math.abs(y12 -drip.worldMatrix.ty) <= 20) {\n if (dy >= y12) {\n let index = this.dripArray.indexOf(drip);\n this.removeChild(drip);\n this.dripArray = this.dripArray.filter(\n (ele, i) => i != index\n );\n }\n // }\n }\n // 23\n if (dx >= px2) {\n // if (Math.abs(y23 -drip.worldMatrix.ty) <= 20) {\n if (dy >= y23) {\n let index = this.dripArray.indexOf(drip);\n this.removeChild(drip);\n this.dripArray = this.dripArray.filter(\n (ele, i) => i != index\n );\n }\n // }\n }\n }\n\n // 碰人\n if (drip.x > this.humanbeing.x &&\n drip.x < this.humanbeing.x + this.humanbeing.width) {\n if (drip.y >= this.humanbeing.y) {\n // 湿润度增加\n this.moists.percent += 0.1;\n this.moists.cover(this.moists.percent);\n this.moists.updateText(this.moists.percent);\n // this.moists.updatePercent(this.moists.percent);\n\n\n // 雨滴动效\n this.addChild(this.rainEffect);\n this.rainEffect.visible = true;\n this.rainEffect.play(true, true);\n this.rainEffect.x = drip.x - drip.width * 2;\n this.rainEffect.y = drip.y;\n this.rainEffect.once(engine.Event.END_FRAME, () => {\n this.rainEffect.visible = false;\n })\n\n if (this.moists.percent >= 1 && !failFlag) {\n // 游戏结束\n this.moists.stopScale();\n failFlag = true;\n console.log(\"游戏结束!\");\n // 清除事件\n this.stop();\n // this.timeCounter.updateTime(this.timeCounter.time);\n }\n\n this.removeChild(drip);\n // 表情改变\n let face = this.humanbeing.facialChange(2);\n face.x = 7;\n face.y = 22;\n setTimeout(() => {\n this.humanbeing.removeFace(face);\n }, 500);\n console.log(\"人\");\n\n let index = this.dripArray.indexOf(drip);\n this.dripArray = this.dripArray.filter(\n (ele, i) => i != index\n );\n\n // 动效\n this.humanbeing.scaleEffect();\n }\n }\n }\n }\n\n\n ld = Date.now();\n });\n\n this.playBtn.addEventListener(\n engine.MouseEvent.CLICK,\n this.onClick,\n this\n );\n this.rightHand.rotation = 0;\n }\n\n onClick() {\n this.clicknum += 1;\n this.rightHand.rotation += 10 * this.clicknum;\n this.clicknum = 0;\n // engine.Tween.get(this.playBtn)\n // .set({scaleX:1,scaleY:1})\n // .to({scaleX:1.1,scaleY:1.1},100)\n // .to({scaleX:1,scaleY:1},100)\n\n\n }\n\n stop() {\n // this.removeAllEventListener();\n // this.playBtn.removeAllEventListener();\n engine.globalEvent.dispatchEvent(\"cloud-game-fail\", {reason: 1});\n\n }\n\n success() {\n this.cloud.succeed();\n engine.globalEvent.dispatchEvent(\"cloud-game-success\", {\n moist: this.moists.percent,\n });\n }\n}\n// }\n\n","\n\nexport let props: any = {};\n\nexport function prepareProps() {\n\tlet metaProps = getProps();\n\n\tengine.injectProp(props, metaProps);\n}\n\nexport function injectProps(p) {\n\tengine.injectProp(props, p);\n}\n","\nimport GameView from \"./GameView\";\nimport GameTest from \"./GameTest\";\n\nimport { injectProps } from \"../props\";\n\n\nexport class GameWrapper extends engine.Container {\n\t// private _status;\n\tprivate _gameView: GameView;\n\tprivate _gameTest: GameTest;\n\n\n\n\n\n\tconstructor() {\n\t\tsuper();\n\n\t\tengine.globalEvent.addEventListener('pictures-start', this.start, this);\n\t\tengine.globalEvent.addEventListener('pictures-stop', this.stop, this);\n\n\t\t//创建实例\n\t\t// let gameView = this._gameView = new GameView();\n\t\tlet gameTest = this._gameTest = new GameTest();\n\t\tthis.addChild(gameTest);\n\n\t}\n\n\tstart(event: engine.Event) {\n\t\tinjectProps(event.data);\n\n\t\t// this._status = 1;\n\n\t\t// this._gameView.start();\n\t\tthis._gameTest.start();\n\t}\n\tstop(event: engine.Event) {\n\t\t\n\t\t// this._gameView.stop();\n\t\tthis._gameTest.stop();\n\t}\n}\n","\n\nimport {GameWrapper} from \"./game/GameWrapper\";\nimport {injectProps, prepareProps} from \"./props\";\n\nexport default function (props) {\n\tprepareProps();\n\tinjectProps(props);\n\n\tlet instance = new GameWrapper();\n\t\n\treturn instance;\n}\n"],"names":["__extends"],"mappings":";;;;;;UAIgB,UAAU,CAAC,IAAI;KAC9B,OAAO,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;CACvD,CAAC;UASe,UAAU,CAAC,IAAI,EAAE,UAAW;KAC3C,IAAI,IAAI,GAAG,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;KAC3B,IAAI,CAAC,MAAM,GAAG,UAAU,GAAG,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC;KAC5D,OAAO,IAAI,CAAC;CACb,CAAC;;;CCjBD;KAAmCA,+BAAgB;KAW/C;SAAA,YACI,iBAAO,SAIV;SAbD,gBAAU,GAAG;aACT,sCAAsC;aACtC,sCAAsC;aACtC,sCAAsC;UACzC,CAAA;SAED,WAAK,GAAiB,IAAI,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,KAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;SAInE,KAAI,CAAC,QAAQ,CAAC,KAAI,CAAC,KAAK,CAAC,CAAA;SACzB,KAAI,CAAC,KAAK,GAAG,KAAI,CAAC,KAAK,CAAC,KAAK,CAAC;SAC9B,KAAI,CAAC,MAAM,GAAG,KAAI,CAAC,KAAK,CAAC,MAAM,CAAC;;MACnC;KAED,4BAAY,GAAZ,UAAa,GAAG;SACZ,IAAI,IAAI,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;SAC/D,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;SAC1B,OAAO,IAAI,CAAC;MACf;KAED,0BAAU,GAAV,UAAW,IAAI;SACX,IAAI,CAAC,KAAK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SET_X": {
"alias": "OFFSET_X",
"type": "number",
"default": 0
},
"OFFSET_Y": {
"alias": "OFFSET_Y",
"type": "number",
"default": 0
},
"GAME_TIME": {
"alias": "游戏时间",
"type": "number",
"default": 30
},
"moistPercent": {
"alias": "湿润度",
"type": "number",
"default": 0
}
},
"assets": [
{
"name": "被遮罩",
"url": "//yun.duiba.com.cn/aurora/assets/c9d66b3e2381fdc7503cdcef9b7173f067a0b96d.png",
"uuid": "8a8e79b6-2c6f-441b-81ae-c441465abfb0",
"ext": ".png"
},
{
"name": "遮罩",
"url": "//yun.duiba.com.cn/aurora/assets/70ade7c1efa699c8662379f406319188fb6aebc5.png",
"uuid": "024d67e9-ed7f-4481-94ca-a15bd5226cad",
"ext": ".png"
},
{
"name":"衣服湿润度",
"url":"//yun.duiba.com.cn/aurora/assets/f59b03b7441b4da17d8e7567b44c6fe92ce9eb50.png",
"uuid":"ed0e8931-2557-4527-bcfc-9071f90d5737",
"ext":".png"
},
{
"name":"wind",
"url":"//yun.duiba.com.cn/aurora/assets/15fc1dabf22baedd8bf5e5b418e57cfc81686072.svga",
"uuid":"7f1ef018-79ab-42bf-ac85-0208e36e2928",
"ext":".svga"
},
{
"name":"雨滴动效",
"url":"//yun.duiba.com.cn/aurora/assets/85feef80df5c2c7728da817e488987d09ba0aab3.svga",
"uuid":"973ed8a7-bfeb-42dd-84fb-e062d150073e",
"ext":".svga"
},
{
"name":"背景",
"url":"//yun.duiba.com.cn/aurora/assets/d0e22ae58b6e8519b969ed207197a31820790349.png",
"uuid":"5ab43bdc-a6ce-46fb-99c2-a806f57f7484",
"ext":".png"
},
{
"name":"倒计时",
"url":"//yun.duiba.com.cn/aurora/assets/97e5c35fa0503b5d28168fe7d22fb179f1279e21.png",
"uuid":"b7d2a60a-9e60-4eca-be80-a991abea47c9",
"ext":".png"
},
{
"name":"t1",
"url":"//yun.duiba.com.cn/aurora/assets/6cc52715ce3bee15d10acbe90eac5828c21fdc7f.png",
"uuid":"a163b74f-32bc-43d2-8015-7cf1eac71501",
"ext":".png"
},
{
"name":"t2",
"url":"//yun.duiba.com.cn/aurora/assets/0d00d8639caf5d344028b01a1022762724164c92.png",
"uuid":"22de82d1-97ec-4195-a32c-f4fc1656e2de",
"ext":".png"
},
{
"name":"t3",
"url":"//yun.duiba.com.cn/aurora/assets/4b7c2f0d4c8248425ed335838ab5a5ce44256b90.png",
"uuid":"cc952365-a990-4912-98af-50905559b9d5",
"ext":".png"
},
{
"name":"云1",
"url":"//yun.duiba.com.cn/aurora/assets/429981638472e8f02ce2a780f3b05be72d13b943.png",
"uuid":"1e1a6993-9da0-4813-b1bd-00f2dbae2af2",
"ext":".png"
},
{
"name":"云2",
"url":"//yun.duiba.com.cn/aurora/assets/c900fe3536b2119b1a917540e1aac5380363d9d1.png",
"uuid":"6ed0e2e7-3ba3-4967-8fe0-39667792e343",
"ext":".png"
},
{
"name":"太阳",
"url":"//yun.duiba.com.cn/aurora/assets/f4ad009080bac141589b7f8eb88d6e66da732cd9.png",
"uuid":"0f05aaae-338a-439a-82b0-20efcee5cca4",
"ext":".png"
},
{
"name":"常态1",
"url":"//yun.duiba.com.cn/aurora/assets/3a1e9ec8247078fc92af538ea8ee29c73b532b93.png",
"uuid":"487c1ca7-dea5-4732-b4b6-acb5406ee3a4",
"ext":".png"
},
{
"name":"吃力1",
"url":"//yun.duiba.com.cn/aurora/assets/40f906478c4fe90f9b68392df0031d382502f8d9.png",
"uuid":"b876771a-a5d1-47f4-bd45-5978519c521a",
"ext":".png"
},
{
"name":"沮丧1",
"url":"//yun.duiba.com.cn/aurora/assets/f76eb798d2ccff84f53780c37d802830c5f6071c.png",
"uuid":"ff43517a-27bb-4f73-948c-d7a4fa7b4c69",
"ext":".png"
},
{
"name":"常态2",
"url":"//yun.duiba.com.cn/aurora/assets/875fd6ba38735682fe27d010338277238672f310.png",
"uuid":"4f8d0a7e-9db3-408e-81f2-fdd323ba6094",
"ext":".png"
},
{
"name":"吃力2",
"url":"//yun.duiba.com.cn/aurora/assets/753b58a25ee4b617afe0a14767036b63681f0809.png",
"uuid":"71e07cee-fd6d-40bb-ac0b-5bb28c87276e",
"ext":".png"
},
{
"name":"沮丧2",
"url":"//yun.duiba.com.cn/aurora/assets/17682be2c0e9f299315bf4e17598ea2e3c8e11ce.png",
"uuid":"2cd9f1bb-d0d8-42ea-941b-dcd0428e474d",
"ext":".png"
},
{
"name":"撑伞按钮",
"url":"//yun.duiba.com.cn/aurora/assets/2d15942ed213e1d0ae953925565d80f93cec4701.png",
"uuid":"9e347bef-6e91-4c92-ba5f-f9a52e656207",
"ext":".png"
},
{
"name":"伞",
"url":"//yun.duiba.com.cn/aurora/assets/a4c14c17dc144611164c70f905f1d35a2aa1812f.png",
"uuid":"c7129f77-92a6-479e-9994-7d4b39040a15",
"ext":".png"
},
{
"name":"雨滴",
"url":"//yun.duiba.com.cn/aurora/assets/a1bf1b1622759aabec29e857e325039c147bac54.png",
"uuid":"07f74bf6-416f-445e-98d5-021efe4c9fdc",
"ext":".png"
},
{
"name":"",
"url":"//yun.duiba.com.cn/aurora/assets/1cded0d917c44d22ddce058f239e1cfac1b506c2.png",
"uuid":"57d4067e-c32f-4b12-a8fc-185753726fc6",
"ext":".png"
},
{
"name":"击中",
"url":"//yun.duiba.com.cn/aurora/assets/251402a1991ef00a124ddd91f519a30147285e00.png",
"uuid":"38ec6627-efa8-4f7a-9bdc-3c73cea717f1",
"ext":".png"
},
{
"name":"关闭",
"url":"//yun.duiba.com.cn/aurora/assets/6900f3a3b592c1b9cd3925fb9b66b6ec673a8c43.png",
"uuid":"e4a82aee-4472-4b06-bd75-02fb64f1c8c8",
"ext":".png"
}
],
"events": {
"in": {
"pictures-start": {
"alias": "开始",
"data": {
"picUrl":"图片路径",
"blockUrl":"blockUrl",
"GAME_TIME":"每局的游戏时间",
"MAX_ROW":"行",
"MAX_COL":"列",
"W":"宽",
"H":"高",
"GAP":"图片间隙",
"OFFSET_X":"OFFSET_X",
"OFFSET_Y":"OFFSET_Y"
}
},
"pictures-stop": {
"alias": "停止"
}
},
"out": {
"cloud-time-update": {
"alias": "倒计时更新",
"data": {
"time":"剩余时间"
}
},
"cloud-game-fail": {
"alias": "游戏结束",
"data": {
"reason": "结束原因(1:时间到了)"
}
},
"cloud-game-success": {
"alias": "游戏成功",
"data": {
"time": "游戏消耗时间"
}
}
}
}
}
\ No newline at end of file
import {getTexture} from './utils'
export default class CloudRain extends engine.Container{
clound1:engine.Sprite = new engine.Sprite(getTexture('1e1a6993-9da0-4813-b1bd-00f2dbae2af2'))
clound2:engine.Sprite = new engine.Sprite(getTexture('6ed0e2e7-3ba3-4967-8fe0-39667792e343'))
sun = new engine.Sprite(getTexture("0f05aaae-338a-439a-82b0-20efcee5cca4"));
constructor(){
super()
this.sun.x = 90;
this.sun.y = 120;
this.addChild(this.sun)
this.addChild(this.clound1);
this.addChild(this.clound2);
this.clound1.x = 100;
this.clound1.y = 220;
this.clound2.x = 150;
this.clound2.y = 220;
}
succeed(){
// 380 580
let a = 0
let ld = Date.now();
this.addEventListener(engine.Event.ENTER_FRAME,()=>{
let dt = Date.now() - ld;
a += dt;
if(a>100){
this.clound1.x -= (800 * dt) / 1000;
this.clound2.x += (820*dt)/1000;
if(this.clound1.x <= -380){
this.clound1.x = -380;
}
if(this.clound2.x >= 750){
this.clound2.x = 750;
}
this.sun.y -= (150 * dt) / 1000;
if(this.sun.y <= 60){
this.sun.y = 60;
}
}
ld = Date.now();
})
}
}
\ No newline at end of file
import { getTexture } from "./utils";
export default class GameTest1 extends engine.Container {
constructor() {
super();
this.once(engine.Event.ADDED_TO_STAGE, this.setup, this);
}
rightHand: engine.Sprite;
ambrella: engine.Sprite;
playBtn: engine.Sprite;
human: engine.Sprite;
setup() {
let playBg = new engine.Sprite(getTexture('c9ff7c30-2734-417d-a811-d88b6b7140b8'))
this.addChild(playBg)
this.human = new engine.Sprite(
getTexture("487c1ca7-dea5-4732-b4b6-acb5406ee3a4")
);
this.human.x = 290;
this.human.y = 900;
this.rightHand = new engine.Sprite(
getTexture("c7129f77-92a6-479e-9994-7d4b39040a15")
);
this.rightHand.x = -70;
this.rightHand.y = -65;
this.rightHand.anchorX = 196;
this.rightHand.anchorY = 253;
this.addChild(this.human);
this.human.addChild(this.rightHand);
this.playBtn = new engine.Sprite(
getTexture("9e347bef-6e91-4c92-ba5f-f9a52e656207")
);
this.playBtn.x = 138;
this.playBtn.y = 200;
this.addChild(this.playBtn);
}
dripArray: any[] = [];
clicknum: number = 0;
R: number = 250;
D: number = 340;
angle: number;
con: engine.Sprite = new engine.Sprite();
start() {
const middleX = this.human.x + this.human.width / 2;
const validX1 = this.human.x;
const validX2 = this.human.x + this.human.width;
// setInterval(()=>{
// let drip = new engine.Sprite(getTexture('07f74bf6-416f-445e-98d5-021efe4c9fdc'))
// drip.x = Math.random() * ((this.human.x + 180)) + (this.human.x - 180) ;
// drip.y = Math.random() * (drip.height);
// this.dripArray.push(drip)
// this.addChild(drip);
// },100)
let drip = new engine.Sprite(
getTexture("07f74bf6-416f-445e-98d5-021efe4c9fdc")
);
drip.x = 200;
drip.y = 0;
this.dripArray.push(drip);
this.addChild(drip);
for (let i = 0; i < 1000; i++) {
let y =
-Math.sqrt(
this.R * this.R - (i - middleX - 50) * (i - middleX - 50)
) +
(this.human.y + 180);
let img = new engine.Sprite(
getTexture("e4a82aee-4472-4b06-bd75-02fb64f1c8c8")
);
img.width = 2;
img.height = 2;
img.x = i;
img.y = y;
this.con.addChild(img);
}
this.addChild(this.con);
// 位移
// setInterval(()=>{
// for(let drip of this.dripArray){
// drip.y += 10;
// if(drip.y > this.stage.height){
// this.removeChild(drip);
// let index = this.dripArray.indexOf(drip)
// this.dripArray = this.dripArray.filter((ele,i)=>i != index)
// }
// }
// },100)
let point1 = new engine.Container();
// point1.beginFill(0xff0000);
// point1.drawRect(0,0,10,10);
point1.y = 100;
// point1.endFill();
this.rightHand.addChild(point1);
let point2 = new engine.Container();
// point2.beginFill(0xff0000);
// point2.drawRect(0,0,10,10);
point2.x = 170;
// point2.endFill();
this.rightHand.addChild(point2);
let point3 = new engine.Container();
// point3.beginFill(0xff0000);
// point3.drawRect(0,0,10,10);
point3.x = 330;
point3.y = 100;
// point3.endFill();
this.rightHand.addChild(point3);
let ld = Date.now();
let a = 0;
this.addEventListener(engine.Event.ENTER_FRAME, () => {
let dt = Date.now() - ld;
a += dt;
if (a > 200) {
a = 0;
let drip = new engine.Sprite(
getTexture("07f74bf6-416f-445e-98d5-021efe4c9fdc")
);
drip.x =
Math.random() * (this.human.x + 180) + (this.human.x - 180);
drip.y = Math.random() * drip.height;
this.dripArray.push(drip);
this.addChild(drip);
}
// 位移
for (let drip of this.dripArray) {
drip.y += (300 * dt) / 1000;
if (drip.y > this.stage.height) {
this.removeChild(drip);
let index = this.dripArray.indexOf(drip);
this.dripArray = this.dripArray.filter(
(ele, i) => i != index
);
}
}
let wind = -40;
this.rightHand.rotation += wind / 60;
if (this.rightHand.rotation <= -90) {
this.rightHand.rotation = -90;
} else if (this.rightHand.rotation >= 90) {
this.rightHand.rotation = 90;
}
ld = Date.now();
// return;
// 扇形的角度
this.angle = Math.asin(this.D / 2 / this.R) * 57.18;
// 伞的偏移角度距离水平位置
let validMaxX;
let validMinX;
// 伞的圆函数
let ambrellaFuncY;
this.rightHand.name = 'aaa';
// a.worldMatrix.tx
// point1,2线性方程斜率
let k12 = (point1.worldMatrix.ty - point2.worldMatrix.ty) / ((point1.worldMatrix.tx - point2.worldMatrix.tx))
let k23 = (point2.worldMatrix.ty - point3.worldMatrix.ty) / ((point2.worldMatrix.tx - point3.worldMatrix.tx))
if (this.rightHand.rotation >= 0) {
// 右偏移且伞左端在右边
// if (this.rightHand.rotation - this.angle >= 0) {
// let x =
// this.R *
// Math.sin((this.rightHand.rotation - this.angle) / 180);
// // 伞是否完全在人的右侧 大于人物的一半宽度
// validMaxX = middleX + x;
// // 距离圆最远的垂直切线距离
// let rx = this.R;
// for (let drip of this.dripArray) {
// // 伞的范围内
// if (
// drip.x + drip.width >= validMaxX &&
// drip.x + drip.width <= middleX + this.R
// ) {
// let ambrellaFuncY =
// -Math.sqrt(
// this.R * this.R -
// (drip.x - middleX - 50) *
// (drip.x - middleX - 50)
// ) +
// (this.human.y + 160);
// if (drip.y + drip.height >= ambrellaFuncY) {
// this.removeChild(drip);
// let index = this.dripArray.indexOf(drip);
// this.dripArray = this.dripArray.filter(
// (ele, i) => i != index
// );
// }
// }
// if (x - this.human.width / 2 >= 0) {
// validMaxX = validX2;
// }
// if (
// (drip.x >= validX1 && drip.x <= validMaxX) ||
// (drip.x + drip.width >= validX1 &&
// drip.x + drip.width <= validMaxX)
// ) {
// // 是否发生碰撞
// if (drip.y + drip.height >= this.human.y) {
// this.removeChild(drip);
// let index = this.dripArray.indexOf(drip);
// this.dripArray = this.dripArray.filter(
// (ele, i) => i != index
// );
// // let upset = new engine.Sprite(getTexture('ff43517a-27bb-4f73-948c-d7a4fa7b4c69'))
// // upset.x = 294;
// // upset.y = 900;
// // this.addChild(upset);
// // setTimeout(()=>{
// // this.removeChild(upset)
// // },1000)
// }
// }
// }
let px1 = point1.worldMatrix.tx;
let px2 = point2.worldMatrix.tx;
let px3 = point3.worldMatrix.tx;
let maxX = px1 > px2 ? (px1>px3?px1:(px3)) : (px2>px3?px2:px3);
let minX = px1 > px2 ? (px2>px3?px3:px2) : (px1>px3?px3:(px1));
// let x2 = (middleX + this.R) < maxX ? (middleX+this.R):maxX;
for(let drip of this.dripArray){
// point1,2线性方程
let b12 = point1.worldMatrix.ty - point1.worldMatrix.tx * k12;
let b23 = point2.worldMatrix.ty - point2.worldMatrix.tx * k23;
let y12 = k12 * drip.x + b12;
let y23 = k23 * drip.x + b23;
if(minX >= validX1){
if(drip.x > minX && drip.x < maxX){
// 伞碰撞12
if(drip.x < px2){
if(drip.y >= y12){
this.removeChild(drip);
let index = this.dripArray.indexOf(drip);
this.dripArray = this.dripArray.filter(
(ele, i) => i != index
);
}
}
// 23
if(drip.x >= px2){
if(drip.y >= y23){
this.removeChild(drip);
let index = this.dripArray.indexOf(drip);
this.dripArray = this.dripArray.filter(
(ele, i) => i != index
);
}
}
}
// 碰人
if(drip.x < minX && drip.x >= validX1){
if(drip.y >= this.human.y){
this.removeChild(drip);
let index = this.dripArray.indexOf(drip);
this.dripArray = this.dripArray.filter(
(ele, i) => i != index
);
}
}
}
}
// } else {
// let x =
// this.R *
// Math.sin((this.angle - this.rightHand.rotation) / 180);
// // 右偏移且伞左端在左边
// validMinX = middleX - x;
// // 伞的右端
// let rx =
// this.R *
// Math.sin((this.angle + this.rightHand.rotation) / 180);
// // 伞是否完全包裹人物
// for (let drip of this.dripArray) {
// // 伞的范围内
// if (
// drip.x + drip.width >= validMinX &&
// drip.x + drip.width < middleX + rx
// ) {
// // ambrellaFuncY = Math.sqrt(this.R*this.R - (drip.x-this.rightHand.anchorX-200) * (drip.x-this.rightHand.anchorX-200)) + this.rightHand.anchorY;
// // let r = Math.sqrt((drip.x - middleX-50)*(drip.x - middleX-50) + ((drip.y+drip.height) - (this.human.y + 200)) * ((drip.y+drip.height) - (this.human.y + 200)))
// ambrellaFuncY =
// -Math.sqrt(
// this.R * this.R -
// (drip.x - middleX - 50) *
// (drip.x - middleX - 50)
// ) +
// (this.human.y + 160);
// // let y = Math.sqrt(this.R*this.R - (drip.x-middleX-50)*(drip.x-middleX-50)) + (this.human.y + 200);
// // console.log(ambrellaFuncY,2,y,r)
// if (drip.y + drip.height >= ambrellaFuncY) {
// // if(r <= this.R){
// this.removeChild(drip);
// let index = this.dripArray.indexOf(drip);
// this.dripArray = this.dripArray.filter(
// (ele, i) => i != index
// );
// }
// }
// if (
// (drip.x > validX1 && drip.x < validMinX) ||
// (drip.x + drip.width > validX1 &&
// drip.x + drip.width < validMinX)
// ) {
// // 是否发生碰撞
// if (drip.y + drip.height >= this.human.y) {
// this.removeChild(drip);
// let index = this.dripArray.indexOf(drip);
// this.dripArray = this.dripArray.filter(
// (ele, i) => i != index
// );
// // let upset = new engine.Sprite(getTexture('ff43517a-27bb-4f73-948c-d7a4fa7b4c69'))
// // upset.x = 294;
// // upset.y = 900;
// // this.addChild(upset);
// // setTimeout(()=>{
// // this.removeChild(upset)
// // },1000)
// }
// }
// }
// }
} else {
let px1 = point1.worldMatrix.tx;
let px2 = point2.worldMatrix.tx;
let px3 = point3.worldMatrix.tx;
let maxX = px1 > px2 ? (px1>px3?px1:(px3)) : (px2>px3?px2:px3);
let minX = px1 > px2 ? (px2>px3?px3:px2) : (px1>px3?px3:(px1));
for(let drip of this.dripArray){
// point1,2线性方程
let b12 = point1.worldMatrix.ty - point1.worldMatrix.tx * k12;
let b23 = point2.worldMatrix.ty - point2.worldMatrix.tx * k23;
let y12 = k12 * drip.x + b12;
let y23 = k23 * drip.x + b23;
if(maxX <= validX2){
if(drip.x > minX && drip.x < maxX){
// 伞碰撞23
if(drip.x > px2){
if(drip.y >= y23){
this.removeChild(drip);
let index = this.dripArray.indexOf(drip);
this.dripArray = this.dripArray.filter(
(ele, i) => i != index
);
}
}
// 12
if(drip.x <= px2){
if(drip.y >= y12){
this.removeChild(drip);
let index = this.dripArray.indexOf(drip);
this.dripArray = this.dripArray.filter(
(ele, i) => i != index
);
}
}
}
// 碰人
if(drip.x < px1 && drip.x >= validX1){
if(drip.y >= this.human.y){
this.removeChild(drip);
let index = this.dripArray.indexOf(drip);
this.dripArray = this.dripArray.filter(
(ele, i) => i != index
);
}
}
}
}
// if (-this.rightHand.rotation - this.angle >= 0) {
// let x =
// this.R *
// Math.sin((-this.angle - this.rightHand.rotation) / 180);
// // 左偏且在左边
// validMinX = middleX - x;
// for (let drip of this.dripArray) {
// // 伞的范围内(可能包括人的部分)
// if (
// drip.x + drip.width < validMinX &&
// drip.x + drip.width > middleX - this.R
// ) {
// // ambrellaFuncY = Math.sqrt(this.R*this.R - (drip.x-this.rightHand.anchorX) * (drip.x-this.rightHand.anchorX)) + this.rightHand.anchorY;
// // ambrellaFuncY = Math.sqrt(this.R*this.R - (drip.x-this.rightHand.anchorX-200) * (drip.x-this.rightHand.anchorX-200)) + this.rightHand.anchorY + 500;
// // let r = Math.sqrt((drip.x - middleX-50)*(drip.x - middleX-50) + ((drip.y+drip.height) - (this.human.y + 200)) * ((drip.y+drip.height) - (this.human.y + 200)))
// ambrellaFuncY =
// -Math.sqrt(
// this.R * this.R -
// (drip.x - middleX - 50) *
// (drip.x - middleX - 50)
// ) +
// (this.human.y + 160);
// // let y = Math.sqrt(this.R*this.R - (drip.x-middleX-50)*(drip.x-middleX-50)) + (this.human.y + 200)
// // console.log(ambrellaFuncY,3,y,r)
// // if(r <= this.R){
// if (drip.y + drip.height >= ambrellaFuncY) {
// this.removeChild(drip);
// let index = this.dripArray.indexOf(drip);
// this.dripArray = this.dripArray.filter(
// (ele, i) => i != index
// );
// }
// }
// if (x > this.human.width / 2) {
// validMinX = validX1;
// }
// if (
// (drip.x > validMinX && drip.x < validX2) ||
// (drip.x + drip.width > validMinX &&
// drip.x + drip.width < validX2)
// ) {
// // 淋湿人物范围
// // 人物是否发生碰撞
// if (drip.y + drip.height >= this.human.y) {
// this.removeChild(drip);
// let index = this.dripArray.indexOf(drip);
// this.dripArray = this.dripArray.filter(
// (ele, i) => i != index
// );
// // let upset = new engine.Sprite(getTexture('ff43517a-27bb-4f73-948c-d7a4fa7b4c69'))
// // upset.x = 294;
// // upset.y = 900;
// // this.addChild(upset);
// // setTimeout(()=>{
// // this.removeChild(upset)
// // },1000)
// }
// }
// }
// } else {
// // 左偏移且在右边
// let x =
// this.R *
// Math.sin((this.angle + this.rightHand.rotation) / 180);
// let lx =
// this.R *
// Math.sin((this.angle - this.rightHand.rotation) / 180);
// validMinX = middleX + x;
// for (let drip of this.dripArray) {
// // 雨滴和伞碰撞
// if (
// drip.x + drip.width <= validMinX &&
// drip.x + drip.width > middleX - lx
// ) {
// // ambrellaFuncY = Math.sqrt(this.R*this.R - (drip.x-this.rightHand.anchorX) * (drip.x-this.rightHand.anchorX)) + this.rightHand.anchorY;
// // ambrellaFuncY = Math.sqrt(this.R*this.R - (drip.x-middleX) * (drip.x-middleX)) + (this.human.y );
// // let r = Math.sqrt((drip.x - middleX-50)*(drip.x - middleX-50) + ((drip.y+drip.height) - (this.human.y + 200)) * ((drip.y+drip.height) - (this.human.y + 200)))
// // ambrellaFuncY = Math.sqrt(this.R*this.R - (drip.x-middleX) * (drip.x- middleX)) + (this.human.y);
// let ambrellaFuncY =
// -Math.sqrt(
// this.R * this.R -
// (drip.x - middleX - 50) *
// (drip.x - middleX - 50)
// ) +
// (this.human.y + 160);
// // console.log(ambrellaFuncY,4,y,r)
// // if(r <= this.R){
// if (drip.y + drip.height >= ambrellaFuncY) {
// this.removeChild(drip);
// let index = this.dripArray.indexOf(drip);
// this.dripArray = this.dripArray.filter(
// (ele, i) => i != index
// );
// }
// } else if (
// (drip.x > validMinX && drip.x < validX2) ||
// (drip.x + drip.width > validMinX &&
// drip.x + drip.width < validX2)
// ) {
// // 人物是否发生碰撞
// if (drip.y + drip.height >= this.human.y) {
// this.removeChild(drip);
// let index = this.dripArray.indexOf(drip);
// this.dripArray = this.dripArray.filter(
// (ele, i) => i != index
// );
// // let upset = new engine.Sprite(getTexture('ff43517a-27bb-4f73-948c-d7a4fa7b4c69'))
// // upset.x = 294;
// // upset.y = 900;
// // this.addChild(upset);
// // setTimeout(()=>{
// // this.removeChild(upset)
// // },1000)
// }
// }
// }
// }
}
ld = Date.now();
});
this.playBtn.addEventListener(
engine.MouseEvent.CLICK,
this.onClick,
this
);
this.rightHand.rotation = 0;
}
onClick() {
this.clicknum += 1;
this.rightHand.rotation += 10 * this.clicknum;
this.clicknum = 0;
}
stop() {}
}
\ No newline at end of file
import { getTexture, createSvga } from "./utils";
import Human from "./Human";
import Moist from "./Moist";
import TimeCounter from "./TimeCounter";
import CloudRain from "./CloudRain";
import gameStage = engine.gameStage;
export default class GameTest extends engine.Container {
constructor() {
super();
this.once(engine.Event.ADDED_TO_STAGE, this.setup, this);
}
rightHand: engine.Sprite;
// ambrella: engine.Sprite;
playBtn: engine.Sprite;
human: engine.Sprite;
humanbeing: Human;
moists: Moist;
contain: any;
timeCounter: TimeCounter;
cloudRain: CloudRain;
cloud: CloudRain;
winds
rainEffect
timeArray: any[] = []
container: engine.Container = new engine.Container()
setup() {
let playBg = new engine.Sprite(
getTexture("5ab43bdc-a6ce-46fb-99c2-a806f57f7484")
);
this.addChild(playBg);
// this.human = new engine.Sprite(
// getTexture("487c1ca7-dea5-4732-b4b6-acb5406ee3a4")
// );
// this.human.x = 290;
// this.human.y = 900;
// 人
this.humanbeing = new Human();
this.humanbeing.x = 290;
// this.humanbeing.y = 900;
this.humanbeing.y = 750;
this.addChild(this.humanbeing);
// this.contain = new engine.Sprite()
console.log(
"xxxxxx",
this.stage.width,
this.stage.height,
this.width,
this.height
);
// 手和伞为一个整体
this.rightHand = new engine.Sprite(
getTexture("c7129f77-92a6-479e-9994-7d4b39040a15")
);
this.rightHand.x = -70;
this.rightHand.y = -65;
this.rightHand.anchorX = 196;
this.rightHand.anchorY = 253;
this.humanbeing.addChild(this.rightHand);
// this.addChild(this.human);
// this.human.addChild(this.rightHand);
this.playBtn = new engine.Sprite(
getTexture("9e347bef-6e91-4c92-ba5f-f9a52e656207")
);
this.playBtn.x = 138;
this.playBtn.y = 1150;
this.playBtn.anchorX = this.playBtn.x + this.playBtn.width / 2;
this.playBtn.anchorY = this.playBtn.y + this.playBtn.height / 2;
this.addChild(this.playBtn);
// 湿润度
this.moists = new Moist();
this.moists.x = 20;
this.moists.y = 450;
this.addChild(this.moists);
// 云
this.cloud = new CloudRain();
this.addChild(this.cloud);
this.timeArray.push(this.t3, this.t2, this.t1);
}
dripArray: any[] = [];
clicknum: number = 0;
R: number = 250;
D: number = 340;
angle: number;
con: engine.Sprite = new engine.Sprite();
// 游戏开始前倒计时三张图
t1 = new engine.Sprite(getTexture('a163b74f-32bc-43d2-8015-7cf1eac71501'));
t2 = new engine.Sprite(getTexture('22de82d1-97ec-4195-a32c-f4fc1656e2de'));
t3 = new engine.Sprite(getTexture('cc952365-a990-4912-98af-50905559b9d5'));
start() {
const middleX = this.humanbeing.x + this.humanbeing.width / 2;
const validX1 = this.humanbeing.x;
const validX2 = this.humanbeing.x + this.humanbeing.width;
let point1 = new engine.Graphics();
point1.beginFill(0xff0000);
point1.drawRect(0, 0, 10, 10);
point1.x = 0;
point1.y = 100;
point1.endFill();
// this.addChild(point1)
this.rightHand.addChild(point1);
let point2 = new engine.Graphics();
point2.beginFill(0xff0000);
point2.drawRect(0, 0, 10, 10);
point2.x = 170;
point2.y = 0;
point2.endFill();
// this.addChild(point2)
this.rightHand.addChild(point2);
let point3 = new engine.Graphics();
point3.beginFill(0xff0000);
point3.drawRect(0, 0, 10, 10);
point3.x = 330;
point3.y = 100;
point3.endFill();
// this.addChild(point3)
this.rightHand.addChild(point3);
window['p1'] = point1;
// @ts-ignore
window['p2'] = point2;
window['p3'] = point3;
//计时器
this.timeCounter = new TimeCounter();
this.addChild(this.timeCounter);
let ld = Date.now();
let a = 0;
let b = 0;
let timer = 0;
let succeedFlag = false;
let failFlag = false;
// 倒计时
for (let i = 0; i < this.timeArray.length; i++) {
let t = this.timeArray[i]
t.anchorTexture.set(0.5, 0.5);
t.x = 750 / 2;
t.y = 1624 / 2;
t.alpha = 0;
this.container.addChild(t);
this.addChild(this.container)
}
for (let i = 0; i < this.timeArray.length; i++) {
let img = this.timeArray[i];
let delta = i * 1000;
let t = engine.Tween.get(img);
t.wait(delta).set({alpha: 0.2, scaleX: 2, scaleY: 2})
.to({alpha: 1, scaleX: 1, scaleY: 1}, 300)
.to({alpha: 0}, 200)
.wait(500);
if (i === this.timeArray.length - 1) {
t.call(() => {
engine.Tween.get(this.container).to({alpha: 0}, 200).call(() => {
this.removeChild(this.container)
})
// 风吹动效
this.winds = createSvga("wind");
this.addChild(this.winds);
this.winds.visible = true;
this.winds.play(true, true)
this.winds.once(engine.Event.END_FRAME, () => {
this.removeChild(this.winds);
}, this)
})
}
}
// 雨滴动效
this.rainEffect = createSvga("雨滴动效");
this.addEventListener(engine.Event.ENTER_FRAME, function addFrame() {
let dt = Date.now() - ld;
b += dt;
timer += dt;
// 延迟三秒执行
if (timer >= 3000) {
a += dt;
if (a > 10) {
a = 0;
if (this.moists.percent < 1 && this.timeCounter.time > 0) {
let drip = new engine.Sprite(getTexture("07f74bf6-416f-445e-98d5-021efe4c9fdc"));
drip.x = Math.random() * (this.humanbeing.x + 160) + (this.humanbeing.x - 160);
drip.y = Math.random() * 100 + 300;
this.dripArray.push(drip);
this.addChild(drip);
}
}
// 雨滴下落
for (let drip of this.dripArray) {
drip.y += (300 * dt) / 1000;
if (drip.y > this.stage.height) {
let index = this.dripArray.indexOf(drip);
this.removeChild(drip);
this.dripArray = this.dripArray.filter(
(ele, i) => i != index
);
}
}
//计时器
if (b >= 1000) {
b = 0;
if (this.moists.percent < 1) {
this.timeCounter.time -= 1;
if (this.timeCounter.time <= 0) {
this.timeCounter.time = 0;
}
this.timeCounter.updateTime(this.timeCounter.time);
}
if (this.timeCounter.time <= 0 && !succeedFlag) {
this.timeCounter.time = 0;
succeedFlag = true;
console.log("游戏成功!");
// 云动画
// 雨水结束
// 太阳出来
this.success();
// this.removeEventListener(engine.Event.END_FRAME,()=>{})
// if(succeedFlag){
// }
}
}
// 伞的旋转
let wind = -40;
this.rightHand.rotation += wind / 60;
if (this.rightHand.rotation <= -90) {
this.rightHand.rotation = -90;
} else if (this.rightHand.rotation >= 90) {
this.rightHand.rotation = 90;
}
// 吃力表情
if (this.rightHand.rotation <= -60) {
let face = this.humanbeing.facialChange(1);
face.x = 7;
face.y = 22;
setTimeout(() => {
this.humanbeing.removeFace(face);
}, 100);
}
// ld = Date.now();
// return;
// 扇形的角度
this.angle = Math.asin(this.D / 2 / this.R) * 57.18;
// 伞的偏移角度距离水平位置
let validMaxX;
let validMinX;
// 伞的圆函数
let ambrellaFuncY;
this.rightHand.name = "aaa";
// a.worldMatrix.tx
// point1,2线性方程斜率
const sa = this.worldMatrix.a;
const sd = this.worldMatrix.d;
const p1x = point1.worldMatrix.tx / sa;
const p2x = point2.worldMatrix.tx / sa;
const p3x = point3.worldMatrix.tx / sa;
const p1y = point1.worldMatrix.ty / sd;
const p2y = point2.worldMatrix.ty / sd;
const p3y = point3.worldMatrix.ty / sd;
let k12 = (p1y - p2y) / (p1x - p2x);
let k23 = (p2y - p3y) / (p2x - p3x);
let px1 = p1x;
let px2 = p2x;
let px3 = p3x;
let maxX = px1 >= px2 ? (px1 >= px3 ? px1 : px3) : px2 >= px3 ? px2 : px3;
let minX = px1 >= px2 ? (px2 >= px3 ? px3 : px2) : px1 >= px3 ? px3 : px1;
let x2 = (middleX + this.R) < maxX ? (middleX + this.R) : maxX;
for (let drip of this.dripArray) {
const dx = drip.worldMatrix.tx / sa;
const dy = drip.worldMatrix.ty / sd;
// point1,2线性方程
let b12 = p1y - p1x * k12 - 50;
let b23 = p2y - p2x * k23 - 50;
let y12 = k12 * dx + b12;
let y23 = k23 * dx + b23;
if (dx >= minX && dx < maxX) {
// 伞碰撞12
if (dx < px2) {
// if (Math.abs(y12 -drip.worldMatrix.ty) <= 20) {
if (dy >= y12) {
let index = this.dripArray.indexOf(drip);
this.removeChild(drip);
this.dripArray = this.dripArray.filter(
(ele, i) => i != index
);
}
// }
}
// 23
if (dx >= px2) {
// if (Math.abs(y23 -drip.worldMatrix.ty) <= 20) {
if (dy >= y23) {
let index = this.dripArray.indexOf(drip);
this.removeChild(drip);
this.dripArray = this.dripArray.filter(
(ele, i) => i != index
);
}
// }
}
}
// 碰人
if (drip.x > this.humanbeing.x &&
drip.x < this.humanbeing.x + this.humanbeing.width) {
if (drip.y >= this.humanbeing.y) {
// 湿润度增加
this.moists.percent += 0.1;
this.moists.cover(this.moists.percent);
this.moists.updateText(this.moists.percent);
// this.moists.updatePercent(this.moists.percent);
// 雨滴动效
this.addChild(this.rainEffect);
this.rainEffect.visible = true;
this.rainEffect.play(true, true);
this.rainEffect.x = drip.x - drip.width * 2;
this.rainEffect.y = drip.y;
this.rainEffect.once(engine.Event.END_FRAME, () => {
this.rainEffect.visible = false;
})
if (this.moists.percent >= 1 && !failFlag) {
// 游戏结束
this.moists.stopScale();
failFlag = true;
console.log("游戏结束!");
// 清除事件
this.stop();
// this.timeCounter.updateTime(this.timeCounter.time);
}
this.removeChild(drip);
// 表情改变
let face = this.humanbeing.facialChange(2);
face.x = 7;
face.y = 22;
setTimeout(() => {
this.humanbeing.removeFace(face);
}, 500);
console.log("人");
let index = this.dripArray.indexOf(drip);
this.dripArray = this.dripArray.filter(
(ele, i) => i != index
);
// 动效
this.humanbeing.scaleEffect();
}
}
}
}
ld = Date.now();
});
this.playBtn.addEventListener(
engine.MouseEvent.CLICK,
this.onClick,
this
);
this.rightHand.rotation = 0;
}
onClick() {
this.clicknum += 1;
this.rightHand.rotation += 10 * this.clicknum;
this.clicknum = 0;
// engine.Tween.get(this.playBtn)
// .set({scaleX:1,scaleY:1})
// .to({scaleX:1.1,scaleY:1.1},100)
// .to({scaleX:1,scaleY:1},100)
}
stop() {
// this.removeAllEventListener();
// this.playBtn.removeAllEventListener();
engine.globalEvent.dispatchEvent("cloud-game-fail", {reason: 1});
}
success() {
this.cloud.succeed();
engine.globalEvent.dispatchEvent("cloud-game-success", {
moist: this.moists.percent,
});
}
}
// }
import { getTexture } from "./utils";
console.log = ()=>{}
export default class GameView extends engine.Container {
constructor() {
super();
this.once(engine.Event.ADDED_TO_STAGE, this.setup, this);
}
rightHand: engine.Sprite;
ambrella: engine.Sprite;
playBtn: engine.Sprite;
human: engine.Sprite;
cir: engine.Shape;
setup() {
// let playBg = new engine.Sprite(getTexture('c9ff7c30-2734-417d-a811-d88b6b7140b8'))
// this.addChild(playBg)
this.human = new engine.Sprite(
getTexture("487c1ca7-dea5-4732-b4b6-acb5406ee3a4")
);
this.human.x = 290;
this.human.y = 900;
this.rightHand = new engine.Sprite(
getTexture("c7129f77-92a6-479e-9994-7d4b39040a15")
);
this.rightHand.x = -70;
this.rightHand.y = -65;
this.rightHand.anchorX = 196;
this.rightHand.anchorY = 253;
this.addChild(this.human);
this.human.addChild(this.rightHand);
this.playBtn = new engine.Sprite(
getTexture("9e347bef-6e91-4c92-ba5f-f9a52e656207")
);
this.playBtn.x = 138;
this.playBtn.y = 200;
this.addChild(this.playBtn);
// 沮丧
// 设置圆
// this.cir = new engine.Shape();
// this.cir.beginFill(0x666666,1);
// this.cir.drawRect(0,0,200,200)
// this.addChild(this.cir)
}
dripArray: any[] = [];
clicknum: number = 0;
R: number = 250;
D: number = 340;
angle: number;
con: engine.Sprite = new engine.Sprite();
// middleX:number = this.human.x + this.human.width/2;
// validX1:number = this.human.x;
// validX2:number = this.human.x + this.human.width;
start() {
const middleX = this.human.x + this.human.width / 2;
const validX1 = this.human.x;
const validX2 = this.human.x + this.human.width;
// setInterval(()=>{
// let drip = new engine.Sprite(getTexture('07f74bf6-416f-445e-98d5-021efe4c9fdc'))
// drip.x = Math.random() * ((this.human.x + 180)) + (this.human.x - 180) ;
// drip.y = Math.random() * (drip.height);
// this.dripArray.push(drip)
// this.addChild(drip);
// },100)
let drip = new engine.Sprite(
getTexture("07f74bf6-416f-445e-98d5-021efe4c9fdc")
);
drip.x = 200;
drip.y = 0;
this.dripArray.push(drip);
this.addChild(drip);
window['a'] = new engine.Graphics();
window['a'].beginFill(0xff0000);
window['a'].drawRect(280,1290,10,10);
window['a'].endFill();
this.addChild(window['a']);
window['b'] = new engine.Graphics();
window['b'].beginFill(0xff0000);
window['b'].drawRect(165,1110,10,10);
window['b'].endFill();
this.addChild(window['b']);
window['c'] = new engine.Graphics();
window['c'].beginFill(0xff0000);
window['c'].drawRect(280,940,10,10);
window['c'].endFill();
this.addChild(window['c']);
for (let i = 0; i < 1000; i++) {
let y =
-Math.sqrt(
this.R * this.R - (i - middleX - 50) * (i - middleX - 50)
) +
(this.human.y + 180);
let img = new engine.Sprite(
getTexture("e4a82aee-4472-4b06-bd75-02fb64f1c8c8")
);
img.width = 2;
img.height = 2;
img.x = i;
img.y = y;
this.con.addChild(img);
}
this.addChild(this.con);
// setInterval(()=>{
// for(let drip of this.dripArray){
// drip.y += 10;
// if(drip.y > this.stage.height){
// this.removeChild(drip);
// let index = this.dripArray.indexOf(drip)
// this.dripArray = this.dripArray.filter((ele,i)=>i != index)
// }
// }
// },100)
let ld = Date.now();
let a = 0;
this.addEventListener(engine.Event.ENTER_FRAME, () => {
let dt = Date.now() - ld;
// a += dt;
// if (a > 100) {
// a = 0;
// let drip = new engine.Sprite(
// getTexture("07f74bf6-416f-445e-98d5-021efe4c9fdc")
// );
// drip.x =
// Math.random() * (this.human.x + 180) + (this.human.x - 180);
// drip.y = Math.random() * drip.height;
// this.dripArray.push(drip);
// this.addChild(drip);
// }
for (let drip of this.dripArray) {
drip.y += (50 * dt) / 1000;
if (drip.y > this.stage.height) {
this.removeChild(drip);
let index = this.dripArray.indexOf(drip);
this.dripArray = this.dripArray.filter(
(ele, i) => i != index
);
}
}
let wind = -40;
let clicknum = this.clicknum || 0;
// let deg = (wind + 10 * clicknum );
this.rightHand.rotation += wind / 60;
// console.log(this.rightHand.rotation);
if (this.rightHand.rotation <= -90) {
this.rightHand.rotation = -90;
} else if (this.rightHand.rotation >= 90) {
this.rightHand.rotation = 90;
}
// 先算点三点最小和最大X
// a.worldMatrix.tx;
this.dripArray.forEach((v:engine.Sprite)=>{
// 看看雨滴的x是不是在
// y
});
ld = Date.now();
// return;
// 扇形的角度
this.angle = Math.asin(this.D / 2 / this.R) * 57.18;
// 伞的偏移角度距离水平位置
let validMaxX;
let validMinX;
// 伞的圆函数
let ambrellaFuncY;
/* if(Math.abs(this.rightHand.rotation) >= 90 - this.angle){
let x1 = this.R * Math.sin(Math.abs(this.rightHand.rotation) - this.angle);
let x2 = this.R
for(let drip of this.dripArray){
if(drip.x >= middleX + x1 && drip.x < middleX + x2){
let ambrellaFuncY =
-Math.sqrt(
this.R * this.R -
(drip.x - middleX - 50) *
(drip.x - middleX - 50)
) +
(this.human.y + 160);
if(drip.y >= ambrellaFuncY){
this.removeChild(drip);
let index = this.dripArray.indexOf(drip);
this.dripArray = this.dripArray.filter(
(ele, i) => i != index
);
}
}
if (
drip.x > this.human.x &&
drip.x < this.human.x + this.human.width
) {
if(drip.y > this.human.y){
this.removeChild(drip);
let index = this.dripArray.indexOf(drip);
this.dripArray = this.dripArray.filter(
(ele, i) => i != index
);
}
}
}
} */
// if (this.rightHand.rotation >= 0) {
// // 伞距离中点偏移的距离
// let x2 =
// this.R *
// Math.sin((this.angle + this.rightHand.rotation) / 180);
// // 右偏移且伞左端在右边
// if (this.rightHand.rotation - this.angle >= 0) {
// let x =
// this.R *
// Math.sin((this.rightHand.rotation - this.angle) / 180);
// // 伞是否完全在人的右侧 大于人物的一半宽度
// validMaxX = middleX + x;
// // 距离圆最远的垂直切线距离
// let rx = this.R;
// for (let drip of this.dripArray) {
// // 伞的范围内
// if (
// drip.x + drip.width >= validMaxX &&
// drip.x + drip.width <= middleX + this.R
// ) {
// // ambrellaFuncY = Math.sqrt(this.R*this.R - (drip.x-this.rightHand.anchorX) * (drip.x-this.rightHand.anchorX)) + this.rightHand.anchorY;
// // let r = Math.sqrt((drip.x - middleX -50)*(drip.x - middleX - 50) + ((drip.y+drip.height) - (this.human.y + 200)) * ((drip.y+drip.height) - (this.human.y + 200)))
// // ambrellaFuncY = Math.sqrt(this.R*this.R - (drip.x-middleX) * (drip.x- middleX)) + (this.human.y)
// let ambrellaFuncY =
// -Math.sqrt(
// this.R * this.R -
// (drip.x - middleX - 50) *
// (drip.x - middleX - 50)
// ) +
// (this.human.y + 160);
// // console.log(ambrellaFuncY,1,y,r)
// // if(r <= this.R){
// if (drip.y + drip.height >= ambrellaFuncY) {
// this.removeChild(drip);
// let index = this.dripArray.indexOf(drip);
// this.dripArray = this.dripArray.filter(
// (ele, i) => i != index
// );
// }
// }
// if (x - this.human.width / 2 >= 0) {
// validMaxX = validX2;
// }
// if (
// (drip.x >= validX1 && drip.x <= validMaxX) ||
// (drip.x + drip.width >= validX1 &&
// drip.x + drip.width <= validMaxX)
// ) {
// // 是否发生碰撞
// if (drip.y + drip.height >= this.human.y) {
// this.removeChild(drip);
// let index = this.dripArray.indexOf(drip);
// this.dripArray = this.dripArray.filter(
// (ele, i) => i != index
// );
// // let upset = new engine.Sprite(getTexture('ff43517a-27bb-4f73-948c-d7a4fa7b4c69'))
// // upset.x = 294;
// // upset.y = 900;
// // this.addChild(upset);
// // setTimeout(()=>{
// // this.removeChild(upset)
// // },1000)
// }
// }
// }
// } else {
// let x =
// this.R *
// Math.sin((this.angle - this.rightHand.rotation) / 180);
// // 右偏移且伞左端在左边
// validMinX = middleX - x;
// // 伞的右端
// let rx =
// this.R *
// Math.sin((this.angle + this.rightHand.rotation) / 180);
// // 伞是否完全包裹人物
// for (let drip of this.dripArray) {
// // 伞的范围内
// if (
// drip.x + drip.width >= validMinX &&
// drip.x + drip.width < middleX + rx
// ) {
// // ambrellaFuncY = Math.sqrt(this.R*this.R - (drip.x-this.rightHand.anchorX-200) * (drip.x-this.rightHand.anchorX-200)) + this.rightHand.anchorY;
// // let r = Math.sqrt((drip.x - middleX-50)*(drip.x - middleX-50) + ((drip.y+drip.height) - (this.human.y + 200)) * ((drip.y+drip.height) - (this.human.y + 200)))
// ambrellaFuncY =
// -Math.sqrt(
// this.R * this.R -
// (drip.x - middleX - 50) *
// (drip.x - middleX - 50)
// ) +
// (this.human.y + 160);
// // let y = Math.sqrt(this.R*this.R - (drip.x-middleX-50)*(drip.x-middleX-50)) + (this.human.y + 200);
// // console.log(ambrellaFuncY,2,y,r)
// if (drip.y + drip.height >= ambrellaFuncY) {
// // if(r <= this.R){
// this.removeChild(drip);
// let index = this.dripArray.indexOf(drip);
// this.dripArray = this.dripArray.filter(
// (ele, i) => i != index
// );
// }
// }
// if (
// (drip.x > validX1 && drip.x < validMinX) ||
// (drip.x + drip.width > validX1 &&
// drip.x + drip.width < validMinX)
// ) {
// // 是否发生碰撞
// if (drip.y + drip.height >= this.human.y) {
// this.removeChild(drip);
// let index = this.dripArray.indexOf(drip);
// this.dripArray = this.dripArray.filter(
// (ele, i) => i != index
// );
// // let upset = new engine.Sprite(getTexture('ff43517a-27bb-4f73-948c-d7a4fa7b4c69'))
// // upset.x = 294;
// // upset.y = 900;
// // this.addChild(upset);
// // setTimeout(()=>{
// // this.removeChild(upset)
// // },1000)
// }
// }
// }
// }
// } else {
// if (-this.rightHand.rotation - this.angle >= 0) {
// let x =
// this.R *
// Math.sin((-this.angle - this.rightHand.rotation) / 180);
// // 左偏且在左边
// validMinX = middleX - x;
// for (let drip of this.dripArray) {
// // 伞的范围内(可能包括人的部分)
// if (
// drip.x + drip.width < validMinX &&
// drip.x + drip.width > middleX - this.R
// ) {
// // ambrellaFuncY = Math.sqrt(this.R*this.R - (drip.x-this.rightHand.anchorX) * (drip.x-this.rightHand.anchorX)) + this.rightHand.anchorY;
// // ambrellaFuncY = Math.sqrt(this.R*this.R - (drip.x-this.rightHand.anchorX-200) * (drip.x-this.rightHand.anchorX-200)) + this.rightHand.anchorY + 500;
// // let r = Math.sqrt((drip.x - middleX-50)*(drip.x - middleX-50) + ((drip.y+drip.height) - (this.human.y + 200)) * ((drip.y+drip.height) - (this.human.y + 200)))
// ambrellaFuncY =
// -Math.sqrt(
// this.R * this.R -
// (drip.x - middleX - 50) *
// (drip.x - middleX - 50)
// ) +
// (this.human.y + 160);
// // let y = Math.sqrt(this.R*this.R - (drip.x-middleX-50)*(drip.x-middleX-50)) + (this.human.y + 200)
// // console.log(ambrellaFuncY,3,y,r)
// // if(r <= this.R){
// if (drip.y + drip.height >= ambrellaFuncY) {
// this.removeChild(drip);
// let index = this.dripArray.indexOf(drip);
// this.dripArray = this.dripArray.filter(
// (ele, i) => i != index
// );
// }
// }
// if (x > this.human.width / 2) {
// validMinX = validX1;
// }
// if (
// (drip.x > validMinX && drip.x < validX2) ||
// (drip.x + drip.width > validMinX &&
// drip.x + drip.width < validX2)
// ) {
// // 淋湿人物范围
// // 人物是否发生碰撞
// if (drip.y + drip.height >= this.human.y) {
// this.removeChild(drip);
// let index = this.dripArray.indexOf(drip);
// this.dripArray = this.dripArray.filter(
// (ele, i) => i != index
// );
// // let upset = new engine.Sprite(getTexture('ff43517a-27bb-4f73-948c-d7a4fa7b4c69'))
// // upset.x = 294;
// // upset.y = 900;
// // this.addChild(upset);
// // setTimeout(()=>{
// // this.removeChild(upset)
// // },1000)
// }
// }
// }
// } else {
// // 左偏移且在右边
// let x =
// this.R *
// Math.sin((this.angle + this.rightHand.rotation) / 180);
// let lx =
// this.R *
// Math.sin((this.angle - this.rightHand.rotation) / 180);
// validMinX = middleX + x;
// for (let drip of this.dripArray) {
// // 雨滴和伞碰撞
// if (
// drip.x + drip.width <= validMinX &&
// drip.x + drip.width > middleX - lx
// ) {
// // ambrellaFuncY = Math.sqrt(this.R*this.R - (drip.x-this.rightHand.anchorX) * (drip.x-this.rightHand.anchorX)) + this.rightHand.anchorY;
// // ambrellaFuncY = Math.sqrt(this.R*this.R - (drip.x-middleX) * (drip.x-middleX)) + (this.human.y );
// // let r = Math.sqrt((drip.x - middleX-50)*(drip.x - middleX-50) + ((drip.y+drip.height) - (this.human.y + 200)) * ((drip.y+drip.height) - (this.human.y + 200)))
// // ambrellaFuncY = Math.sqrt(this.R*this.R - (drip.x-middleX) * (drip.x- middleX)) + (this.human.y);
// let ambrellaFuncY =
// -Math.sqrt(
// this.R * this.R -
// (drip.x - middleX - 50) *
// (drip.x - middleX - 50)
// ) +
// (this.human.y + 160);
// // console.log(ambrellaFuncY,4,y,r)
// // if(r <= this.R){
// if (drip.y + drip.height >= ambrellaFuncY) {
// this.removeChild(drip);
// let index = this.dripArray.indexOf(drip);
// this.dripArray = this.dripArray.filter(
// (ele, i) => i != index
// );
// }
// } else if (
// (drip.x > validMinX && drip.x < validX2) ||
// (drip.x + drip.width > validMinX &&
// drip.x + drip.width < validX2)
// ) {
// // 人物是否发生碰撞
// if (drip.y + drip.height >= this.human.y) {
// this.removeChild(drip);
// let index = this.dripArray.indexOf(drip);
// this.dripArray = this.dripArray.filter(
// (ele, i) => i != index
// );
// // let upset = new engine.Sprite(getTexture('ff43517a-27bb-4f73-948c-d7a4fa7b4c69'))
// // upset.x = 294;
// // upset.y = 900;
// // this.addChild(upset);
// // setTimeout(()=>{
// // this.removeChild(upset)
// // },1000)
// }
// }
// }
// }
// }
ld = Date.now();
});
this.playBtn.addEventListener(
engine.MouseEvent.CLICK,
this.onClick,
this
);
// engine.Tween.get(this.rightHand)
// .to({
// alpha:1,
// rotation:90
// },1000)
this.rightHand.rotation = 0;
// 点击按钮
//明天:伞两边的距离都要计算,判断还不完全。
// 伞在人物上方时,注意x的偏移量与人物两端的大小比较
}
onClick() {
this.clicknum += 1;
this.rightHand.rotation += 10 * this.clicknum;
this.clicknum = 0;
// setInterval(()=>{
// this.rightHand.rotation += 10*this.clicknum/60;
// },1000/60)
}
stop() {}
}
import GameView from "./GameView";
import GameTest from "./GameTest";
import { injectProps } from "../props";
export class GameWrapper extends engine.Container {
// private _status;
private _gameView: GameView;
private _gameTest: GameTest;
constructor() {
super();
engine.globalEvent.addEventListener('pictures-start', this.start, this);
engine.globalEvent.addEventListener('pictures-stop', this.stop, this);
//创建实例
// let gameView = this._gameView = new GameView();
let gameTest = this._gameTest = new GameTest();
this.addChild(gameTest);
}
start(event: engine.Event) {
injectProps(event.data);
// this._status = 1;
// this._gameView.start();
this._gameTest.start();
}
stop(event: engine.Event) {
// this._gameView.stop();
this._gameTest.stop();
}
}
import {getTexture} from './utils'
export default class Human extends engine.Container{
//常态,吃力,沮丧
humanArray = [
'487c1ca7-dea5-4732-b4b6-acb5406ee3a4',
'71e07cee-fd6d-40bb-ac0b-5bb28c87276e',
'2cd9f1bb-d0d8-42ea-941b-dcd0428e474d'
]
//三张面部表情
human:engine.Sprite = new engine.Sprite(getTexture(this.humanArray[0]))
constructor(){
super();
this.addChild(this.human)
this.width = this.human.width;
this.height = this.human.height;
}
facialChange(num){
let face = new engine.Sprite(getTexture(this.humanArray[num]));
this.human.addChild(face);
return face;
}
removeFace(face){
this.human.removeChild(face);
}
scaleEffect(){
let aaa = 0;
let pt = Date.now();
this.addEventListener(engine.Event.ENTER_FRAME,()=>{
let dt = Date.now() -pt;
aaa += dt;
this.anchorX = this.width + this.width / 2
this.anchorY = this.height;
if(aaa > 90 && aaa<=100 ){
this.scaleY = 0.99;
this.scaleX = 1.01;
}
if(aaa >190 && aaa < 200){
this.scaleX = 1;
this.scaleY = 1;
aaa = 0;
}
pt = Date.now();
})
}
}
\ No newline at end of file
import {getTexture} from './utils'
export default class Moist extends engine.Container{
percent:number
moistBg:engine.Sprite = new engine.Sprite(getTexture('8a8e79b6-2c6f-441b-81ae-c441465abfb0'))
moist:engine.Sprite = new engine.Sprite(getTexture('024d67e9-ed7f-4481-94ca-a15bd5226cad'))
moistCover:any = new engine.Sprite(getTexture('024d67e9-ed7f-4481-94ca-a15bd5226cad'))
txt = new engine.TextInput();
hintpic:engine.Sprite = new engine.Sprite(getTexture('ed0e8931-2557-4527-bcfc-9071f90d5737'))
addPercent:number
constructor(){
super();
this.percent = 0;
this.addChild(this.moistBg)
this.moistBg.addChild(this.moist)
this.moist.mask = this.moistCover;
this.txt.text = this.percent*100+'%';
this.txt.size = 30;
this.txt.fillColor = '#7A83C5';
this.addChild(this.txt)
this.txt.x = 0;
this.txt.y = -50;
this.hintpic.x = -10;
this.hintpic.y = 440;
this.addChild(this.hintpic)
}
cover(percent){
this.moistCover.anchorY = 416;
this.moistBg.addChild(this.moistCover)
this.moistCover.scaleY = percent;
let ld = Date.now();
// let time
// this.addEventListener(engine.Event.ENTER_FRAME,()=>{
// let dt = Date.now() - ld;
// time += dt;
// if(time >= 100){
// // this.moistCover.scaleY =
// }
// })
let t = engine.Tween.get(this.moistCover);
// t.set({alpha:1,scaleY:this.percent})
// .to({alpha:1,scaleY:percent - 0.08},100)
// .to({alpha:1,scaleY:percent - 0.06},100)
// .to({alpha:1,scaleY:percent - 0.04},100)
// .to({alpha:1,scaleY:percent - 0.02},100)
// .to({alpha:1,scaleY:percent},100)
}
stopScale(){
this.moistCover.scaleY = 1;
this.txt.text = '100%';
}
updateText(percent){
let a = percent * 100;
if(a <=90){
this.txt.text = a.toPrecision(2)+'%';
}else{
this.txt.text = a.toPrecision(3)+'%';
}
}
updatePercent(percent){
this.percent = percent;
}
}
\ No newline at end of file
import {getTexture} from './utils'
export default class TimeCounter extends engine.Container{
timeCounter:engine.Sprite = new engine.Sprite(getTexture('b7d2a60a-9e60-4eca-be80-a991abea47c9'));
timeText:any;
time:number
constructor(){
super()
this.time = 20
this.addChild(this.timeCounter)
this.timeCounter.x = 256;
this.timeCounter.y = 50;
// 计时文本
this.timeText = new engine.TextInput();
this.timeText.text = this.time +'s';
this.timeText.size = 48;
this.timeText.fillColor = '#7A83C5';
this.timeCounter.addChild(this.timeText);
this.timeText.x = 100;
this.timeText.y = 15;
}
updateTime(time){
this.time = time;
this.timeText.text = this.time + 's'
}
}
\ No newline at end of file
/**
* Created by rockyl on 2020-01-21.
*/
export function getTexture(uuid) {
return engine.Texture.from(getAssetByUUID(uuid).uuid);
}
export function getTextureByName(name) {
return getTexture(engine.getAssetByName(name).uuid);
}
export function playSound(name) {
engine.playSound(engine.getAssetByName(name).uuid, {keep: true});
}
export function createSvga(name, anchorName?) {
let inst = new svga.Svga();
inst.source = 'asset://' + engine.getAssetByName(name).uuid;
return inst;
}
export function getIndexFromRC(row,col,maxCol){
let index;
index = row * maxCol + col ;
return index
}
export function getRandomArray(array){
array.sort(function() {
return .5 - Math.random();
});
}
\ No newline at end of file
import {GameWrapper} from "./game/GameWrapper";
import {injectProps, prepareProps} from "./props";
export default function (props) {
prepareProps();
injectProps(props);
let instance = new GameWrapper();
return instance;
}
export let props: any = {};
export function prepareProps() {
let metaProps = getProps();
engine.injectProp(props, metaProps);
}
export function injectProps(p) {
engine.injectProp(props, p);
}
/**
* Created by rockyl on 2019-12-16.
*/
const customId = 'jiugong-turntable-change';
(async function () {
let customModule = await fetch(`../meta.json`);
customModule = await customModule.json();
console.log(customModule);
await loadAssets(customModule.assets);
launchWithCustomModule(customModule);
})();
function launchWithCustomModule(customModule) {
//engine.registerCustomCodeModule(customModule);
engine.registerCustomModule(customId, window[customId]);
const {props: propsOption, assets} = customModule;
let props = engine.computeProps(customModuleProps, propsOption);
const customModuleIns = {
id: customId,
props,
assets,
};
engine.registerCustomModules([customModuleIns]);
engine.launchWithConfig({
options: {
entrySceneView: 'entry',
},
assets: [],
views: [{
name: 'entry',
type: 'node',
properties: {
x: 0,
y: 0,
}
}],
}, null, function () {
setTimeout(() => {
engine.addCustomModule(customId, engine.gameStage.sceneContainer.getChildAt(0));
}, 100);
let pram = [
{
id:1,
name:'奖品1奖品1',
img:'//yun.dui88.com/images/201907/ui83og75fr.png'
},
{
id:2,
name:'奖品2奖品2奖品2',
img:'//yun.dui88.com/images/201907/ui83og75fr.png'
},
{
id:3,
name:'奖品333333',
img:'//yun.dui88.com/images/201907/ui83og75fr.png'
},
{
id:4,
name:'奖品4545545454',
img:'//yun.dui88.com/images/201907/ui83og75fr.png'
},
{
id:5,
name:'奖奖品5奖品5奖品5品5',
img:'//yun.dui88.com/images/201907/ui83og75fr.png'
},
{
id:6,
name:'奖品6',
img:'//yun.dui88.com/images/201907/ui83og75fr.png'
},
{
id:7,
name:'奖品7',
img:'//yun.dui88.com/images/201907/ui83og75fr.png'
},
{
id:8,
name:'奖品奖品5奖品5奖品58',
img:'//yun.dui88.com/images/201907/ui83og75fr.png'
}
]
setTimeout(() => {
engine.globalEvent.dispatchEvent('jiugong-turntable-change-init')
}, 1000);
setTimeout(() => {
engine.globalEvent.dispatchEvent('jiugong-turntable-change-prizeData',{resources:pram})
}, 1500);
setTimeout(() => {
engine.globalEvent.dispatchEvent('jiugong-turntable-change-start')
}, 4000);
let pram1 = [
{
id:1,
name:'奖品1',
img:'//yun.dui88.com/images/201907/ui83og75fr.png'
},
{
id:2,
name:'奖品2',
img:'//yun.dui88.com/images/201907/ui83og75fr.png'
},
{
id:3,
name:'奖品3',
img:'//yun.dui88.com/images/201907/ui83og75fr.png'
},
{
id:4,
name:'奖品4',
img:'//yun.dui88.com/images/201907/ui83og75fr.png'
},
{
id:5,
name:'奖品5',
img:'//yun.dui88.com/images/201907/ui83og75fr.png'
},
{
id:6,
name:'奖品6',
img:'//yun.dui88.com/images/201907/ui83og75fr.png'
},
{
id:7,
name:'奖品7',
img:'//yun.dui88.com/images/201907/ui83og75fr.png'
},
{
id:8,
name:'奖品8',
img:'//yun.dui88.com/images/201907/ui83og75fr.png'
}
]
setTimeout(() => {
engine.globalEvent.dispatchEvent('jiugong-turntable-change-winPrize',{prizeID:4})
}, 6000);
// setTimeout(() => {
// engine.globalEvent.dispatchEvent('jiugong-turntable-change-prizeData',{resources:pram1})
// }, 10000);
});
}
function getAssetByUUID(uuid) {
return engine.resolveCustomAsset(customId, uuid);
}
function getProps() {
return engine.getProps(customId);
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>九宫格答题-更换奖池</title>
<meta name="viewport"
content="width=device-width,initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no"/>
<meta name="apple-mobile-web-app-capable" content="yes"/>
<meta name="full-screen" content="true"/>
<meta name="screen-orientation" content="portrait"/>
<meta name="x5-fullscreen" content="true"/>
<meta name="360-fullscreen" content="true"/>
<style>
html,
body {
padding: 0;
margin: 0;
border: 0;
width: 100%;
height: 100%;
overflow: hidden;
position: absolute;
background-color: #000000;
}
</style>
</head>
<body>
<div id="game-container" style="line-height:0;font-size:0"></div>
<script src="//yun.duiba.com.cn/editor/zeroing/libs/engine.ebc906f6b50b8da0a669f77027981d5f3cb560ce.js"></script>
<!--<script src="http://localhost:4002/debug/engine.js"></script>
<script src="http://localhost:4003/debug/engine-svga.js"></script>-->
<!--//yun.duiba.com.cn/aurora/assets/6a63b68a1fd87eaf60a515968f91a0b1014fe640.ttf-->
<script src="//yun.duiba.com.cn/editor/zeroing/libs/svga.fd3923ae6e664251ca7981801a65809cc5f36bc3.js"> </script>
<!--<script src="//yun.duiba.com.cn/editor/zeroing/libs/engine.9a9dbfda4cb2dd5508ecddfe3d95dfd88063f7b5.js"></script>-->
<script src="app.js"></script>
<script src="props.js"></script>
<script src="load-assets.js"></script>
<script src="main.js"></script>
<script>
</script>
</body>
\ No newline at end of file
/**
* Created by rockyl on 2020-01-21.
*/
const assets = [
];
function loadAssets(customModuleAssets, onProgress, onComplete){
return engine.loadAssets(assets.concat(...customModuleAssets), onProgress, onComplete);
}
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('tslib')) :
typeof define === 'function' && define.amd ? define(['tslib'], factory) :
(global = global || self, global['jiugong-turntable-change'] = factory(global.tslib));
}(this, (function (tslib) { 'use strict';
function getTexture(uuid) {
return engine.Texture.from(getAssetByUUID(uuid).uuid);
}
function getTextureByName(name) {
return getTexture(engine.getAssetByName(name).uuid);
}
//# sourceMappingURL=utils.js.map
var props = {};
function prepareProps() {
var metaProps = getProps();
engine.injectProp(props, metaProps);
}
function injectProps(p) {
engine.injectProp(props, p);
}
//# sourceMappingURL=props.js.map
var Turntable = (function (_super) {
tslib.__extends(Turntable, _super);
function Turntable() {
var _this = _super.call(this) || this;
_this._vertical_Y = props.vertical || 20;
_this._horizontal_X = props.horizontal || 20;
_this._prizeIndex = 0;
_this._boxArray = [];
_this._boxIndex = 0;
_this.tweenTime = props.tweenTime || 200;
_this.slowTweenTime = props.slowTweenTime || 200;
_this.circleNumber = 0;
_this.turntableOrder = [1, 2, 3, 5, 8, 7, 6, 4];
_this.recordID = -1;
_this.boxPrizeIndex = -1;
_this.slowDown = false;
_this.isStop = false;
return _this;
}
Turntable.prototype.initData = function (res) {
this.initTurntable(res);
this.setNodeOrder();
};
Turntable.prototype.initTurntable = function (res) {
var turnTableNode = null;
if (this._turnTableNode) {
this.removeChild(this._turnTableNode);
this._turnTableNode = null;
this._boxArray = [];
this._prizeIndex = 0;
this._boxIndex = 0;
}
turnTableNode = this._turnTableNode = new engine.Container();
this.addChild(turnTableNode);
for (var index_Y = 0; index_Y < 3; index_Y++) {
for (var index_X = 0; index_X < 3; index_X++) {
if (index_X == 1 && index_Y == 1)
continue;
var tmpNode = new engine.Container();
var unchecked = this.getImage('unchecked', 1);
var checked = this.getImage('checked', 0);
tmpNode.width = Math.max(unchecked.width, checked.width);
this._singleNodeWidth = this._singleNodeWidth ? this._singleNodeWidth : tmpNode.width;
tmpNode.height = Math.max(unchecked.height, checked.height);
tmpNode.x = index_X * (tmpNode.width + this._horizontal_X);
tmpNode.y = index_Y * (tmpNode.height + this._vertical_Y);
tmpNode.addChild(unchecked);
tmpNode.addChild(checked);
var prize = new engine.Sprite(engine.Texture.fromImage(res[this._prizeIndex].img));
var prizeID = res[this._prizeIndex].id;
prize.width = props.icon_width;
prize.height = props.icon_height;
prize.x = (tmpNode.width - prize.width) / 2 + props.icon_X;
prize.y = (tmpNode.height - prize.height) / 2 + props.icon_Y;
tmpNode.prizeID = prizeID;
tmpNode.addChild(prize);
var titleLabel = new engine.Label();
titleLabel.fillColor = props.prizeName_color;
titleLabel.size = props.prizeName_size;
titleLabel.width = unchecked.width;
titleLabel.textAlign = engine.TEXT_ALIGN.CENTER;
titleLabel.x = 0;
titleLabel.y = props.prizeName_Ypos;
titleLabel.text = this.fixTitle(res[this._prizeIndex].name);
tmpNode.addChild(titleLabel);
this._prizeIndex++;
this._boxArray.push(tmpNode);
turnTableNode.addChild(tmpNode);
}
}
turnTableNode.x = (750 - (this._singleNodeWidth * 3 + this._horizontal_X * 2)) / 2;
};
Turntable.prototype.setNodeOrder = function () {
var tmpNodeArray = [];
for (var index = 0; index < this.turntableOrder.length; index++) {
var order = this.turntableOrder[index];
tmpNodeArray.push(this._boxArray[order - 1]);
}
this._boxArray = tmpNodeArray;
};
Turntable.prototype.fixTitle = function (name) {
if (!name) {
return "";
}
if (name.split("").length < props.prizeName_maxLength) {
return name;
}
var n = "";
for (var i = 0; i < props.prizeName_retainLength; i++) {
n += name.split("")[i];
}
n += "...";
return n;
};
Turntable.prototype.getImage = function (resName, alpha) {
var tmpImage = new engine.Sprite(getTextureByName(resName));
tmpImage.x = 0;
tmpImage.y = 0;
tmpImage.alpha = alpha;
tmpImage.name = resName;
return tmpImage;
};
Turntable.prototype.startDraw = function () {
var _this = this;
var tmpCheckNode = this._boxArray[this._boxIndex].getChildByName('checked');
if (this.isStop) {
engine.Tween.removeTweens(tmpCheckNode);
return;
}
if (this.slowDown) {
if (this._boxIndex != this.getNodeIndexOFprize()) {
this.tweenTime += this.slowTweenTime;
}
else {
this.isStop = true;
this.twinkle(tmpCheckNode);
}
}
engine.Tween.get(tmpCheckNode)
.to({ alpha: 1 }, this.tweenTime / 2)
.to({ alpha: 0 }, this.tweenTime / 2)
.call(function () {
if (_this.circleNumber >= props.circleNumber && _this.getSlowStart() == _this._boxIndex) {
_this.slowDown = true;
}
_this._boxIndex++;
if (_this._boxIndex >= _this._boxArray.length) {
_this._boxIndex = 0;
_this.circleNumber++;
}
_this.startDraw();
});
};
Turntable.prototype.getSlowStart = function () {
if (this.recordID < 0)
return -1;
var tmpIndex = this.getNodeIndexOFprize();
if (tmpIndex < 4) {
return tmpIndex + 4;
}
else {
return tmpIndex - 4;
}
};
Turntable.prototype.getNodeIndexOFprize = function () {
if (this.recordID < 0)
return -1;
for (var index = 0; index < this._boxArray.length; index++) {
var element = this._boxArray[index];
if (element.prizeID === this.recordID) {
return index;
}
}
return -1;
};
Turntable.prototype.twinkle = function (tmpNode) {
engine.Tween.removeTweens(tmpNode);
var twinkleTime = 1;
engine.Tween.get(tmpNode, { loop: true })
.to({ alpha: 0 }, 30)
.to({ alpha: 1 }, 30)
.call(function () {
if (twinkleTime > 5) {
engine.Tween.removeTweens(tmpNode);
engine.globalEvent.dispatchEvent('jiugong-turntable-change-over');
return;
}
else {
twinkleTime++;
}
});
};
Turntable.prototype.setRecordID = function (prizeID) {
this.recordID = prizeID;
};
Turntable.prototype.reset = function () {
this._boxArray.forEach(function (element) {
engine.Tween.removeTweens(element.getChildByName('checked'));
});
this._boxIndex = 0;
this.tweenTime = props.tweenTime || 200;
this.slowTweenTime = props.slowTweenTime || 200;
this.circleNumber = 0;
this.recordID = -1;
this.boxPrizeIndex = -1;
this.slowDown = false;
this.isStop = false;
for (var index = 0; index < this._boxArray.length; index++) {
var element = this._boxArray[index];
element.getChildByName('checked').alpha = 0;
}
};
return Turntable;
}(engine.Container));
//# sourceMappingURL=turntable.js.map
var GameView = (function (_super) {
tslib.__extends(GameView, _super);
function GameView() {
return _super.call(this) || this;
}
GameView.prototype.setup = function () {
if (this._hasSetup) {
return;
}
this._hasSetup = true;
var turntable = this._turntable = new Turntable();
this.addChild(turntable);
};
GameView.prototype.setPrizeData = function (res) {
this._turntable.initData(res);
};
GameView.prototype.startDraw = function () {
this._turntable.startDraw();
};
GameView.prototype.setRecordID = function (prizeID) {
this._turntable.setRecordID(prizeID);
};
GameView.prototype.reset = function () {
this._turntable.reset();
};
GameView.prototype.setSetup = function () {
this._hasSetup = false;
};
return GameView;
}(engine.Container));
//# sourceMappingURL=GameView.js.map
var GameWrapper = (function (_super) {
tslib.__extends(GameWrapper, _super);
function GameWrapper() {
var _this = _super.call(this) || this;
engine.globalEvent.addEventListener('jiugong-turntable-change-init', _this.init, _this);
engine.globalEvent.addEventListener('jiugong-turntable-change-prizeData', _this.initPrizeData, _this);
engine.globalEvent.addEventListener('jiugong-turntable-change-start', _this.start, _this);
engine.globalEvent.addEventListener('jiugong-turntable-change-winPrize', _this.winPrize, _this);
engine.globalEvent.addEventListener('jiugong-turntable-change-reset', _this.reset, _this);
engine.globalEvent.addEventListener('jiugong-turntable-change-abnormal', _this.reset, _this);
return _this;
}
GameWrapper.prototype.init = function (event) {
var gameView = this._gameView = new GameView();
this.addChild(gameView);
this._gameView.setup();
};
GameWrapper.prototype.initPrizeData = function (event) {
this._gameView.setSetup();
this._gameView.setPrizeData(event.data.resources);
};
GameWrapper.prototype.start = function (event) {
this._gameView.startDraw();
};
GameWrapper.prototype.winPrize = function (event) {
this._gameView.setRecordID(event.data.prizeID);
};
GameWrapper.prototype.reset = function () {
this._gameView.reset();
};
return GameWrapper;
}(engine.Container));
//# sourceMappingURL=GameWrapper.js.map
function index (props) {
prepareProps();
injectProps(props);
var instance = new GameWrapper();
return instance;
}
//# sourceMappingURL=index.js.map
return index;
})));
//# sourceMappingURL=main.js.map
\ No newline at end of file
{"version":3,"file":"index.js","sources":["src/custom/jiugong-turntable-change/src/game/utils.ts","src/custom/jiugong-turntable-change/src/props.ts","src/custom/jiugong-turntable-change/src/game/turntable.ts","src/custom/jiugong-turntable-change/src/game/GameView.ts","src/custom/jiugong-turntable-change/src/game/GameWrapper.ts","src/custom/jiugong-turntable-change/src/index.ts"],"sourcesContent":["\r\n/**\r\n * Created by rockyl on 2020-01-21.\r\n */\r\n\r\nexport function getTexture(uuid) {\r\n\treturn engine.Texture.from(getAssetByUUID(uuid).uuid);\r\n}\r\n\r\nexport function getTextureByName(name) {\r\n\treturn getTexture(engine.getAssetByName(name).uuid);\r\n}\r\n\r\nexport function playSound(name) {\r\n\tengine.playSound(engine.getAssetByName(name).uuid, {keep: true});\r\n}\r\nexport function getStage(){\r\n\treturn engine.gameStage.stage;\r\n}","/**\r\n * Created by rockyl on 2020-01-21.\r\n */\r\n\r\nexport let props: any = {};\r\n\r\nexport function prepareProps() {\r\n\tlet metaProps = getProps();\r\n\r\n\tengine.injectProp(props, metaProps);\r\n}\r\n\r\nexport function injectProps(p) {\r\n\tengine.injectProp(props, p);\r\n}\r\n","\r\nimport {getTextureByName} from \"./utils\";\r\nimport {getStage} from \"./utils\";\r\n\r\nimport { props } from '../props';\r\n\r\nexport class Turntable extends engine.Container{\r\n private _turnTableNode:engine.Container;\r\n private _vertical_Y = props.vertical || 20;//纵向间距\r\n private _horizontal_X = props.horizontal || 20;//横向间距\r\n private _prizeIndex = 0;\r\n\r\n private _boxArray = [];\r\n private _boxIndex = 0;//当前下标\r\n\r\n private tweenTime = props.tweenTime || 200;//单个动画时间(毫秒)\r\n private slowTweenTime = props.slowTweenTime || 200;\r\n private circleNumber = 0;//圈数\r\n\r\n private turntableOrder = [1,2,3,5,8,7,6,4]; \r\n private recordID = -1;//中奖奖品ID\r\n private boxPrizeIndex = -1;//中奖奖品节点下标 \r\n private slowDown = false;//是否开始缓速\r\n private isStop = false;\r\n\r\n private _singleNodeWidth;//单个节点宽度\r\n constructor(){\r\n super()\r\n \r\n }\r\n public initData(res){\r\n this.initTurntable(res);\r\n this.setNodeOrder();\r\n }\r\n initTurntable(res){\r\n let turnTableNode = null;\r\n if(this._turnTableNode){\r\n this.removeChild(this._turnTableNode);\r\n this._turnTableNode = null;\r\n this._boxArray = [];\r\n this._prizeIndex = 0;\r\n this._boxIndex = 0;\r\n }\r\n turnTableNode = this._turnTableNode = new engine.Container();\r\n //turnTableNode.y = 50;\r\n this.addChild(turnTableNode);\r\n for (let index_Y = 0; index_Y < 3; index_Y++) {\r\n for (let index_X = 0; index_X < 3; index_X++) { \r\n if(index_X == 1 && index_Y == 1)continue;\r\n let tmpNode:any = new engine.Container()\r\n\r\n let unchecked = this.getImage('unchecked',1);\r\n let checked = this.getImage('checked',0);\r\n\r\n tmpNode.width = Math.max(unchecked.width,checked.width);\r\n this._singleNodeWidth = this._singleNodeWidth ? this._singleNodeWidth : tmpNode.width;\r\n tmpNode.height = Math.max(unchecked.height,checked.height);\r\n tmpNode.x = index_X*(tmpNode.width + this._horizontal_X);\r\n tmpNode.y = index_Y*(tmpNode.height + this._vertical_Y);\r\n tmpNode.addChild(unchecked);\r\n tmpNode.addChild(checked);\r\n \r\n let prize =new engine.Sprite(engine.Texture.fromImage(res[this._prizeIndex].img)) ;\r\n let prizeID = res[this._prizeIndex].id;\r\n prize.width = props.icon_width;\r\n prize.height = props.icon_height;\r\n prize.x = (tmpNode.width - prize.width)/2 + props.icon_X;\r\n prize.y = (tmpNode.height - prize.height)/2 + props.icon_Y;\r\n tmpNode.prizeID = prizeID;\r\n tmpNode.addChild(prize);\r\n \r\n let titleLabel = new engine.Label();\r\n titleLabel.fillColor = props.prizeName_color;\r\n titleLabel.size = props.prizeName_size;\r\n titleLabel.width = unchecked.width;\r\n titleLabel.textAlign = engine.TEXT_ALIGN.CENTER;\r\n titleLabel.x = 0;\r\n titleLabel.y = props.prizeName_Ypos;\r\n \r\n titleLabel.text = this.fixTitle(res[this._prizeIndex].name);\r\n tmpNode.addChild(titleLabel)\r\n \r\n this._prizeIndex ++ ;\r\n this._boxArray.push(tmpNode); \r\n turnTableNode.addChild(tmpNode); \r\n }\r\n }\r\n turnTableNode.x = (750 - (this._singleNodeWidth*3 + this._horizontal_X*2))/2;\r\n }\r\n\r\n setNodeOrder(){\r\n let tmpNodeArray = [];\r\n for (let index = 0; index < this.turntableOrder.length; index++) {\r\n let order = this.turntableOrder[index];\r\n tmpNodeArray.push(this._boxArray[order-1]);\r\n }\r\n this._boxArray = tmpNodeArray;\r\n }\r\n\r\n fixTitle(name){\r\n if(!name){\r\n return \"\"\r\n }\r\n if(name.split(\"\").length<props.prizeName_maxLength){\r\n return name\r\n }\r\n let n = \"\"\r\n for(let i=0;i<props.prizeName_retainLength;i++){\r\n n += name.split(\"\")[i]\r\n }\r\n n+=\"...\"\r\n return n\r\n }\r\n\r\n getImage(resName,alpha){\r\n let tmpImage = new engine.Sprite(getTextureByName(resName));\r\n tmpImage.x = 0\r\n tmpImage.y = 0\r\n tmpImage.alpha = alpha;\r\n tmpImage.name = resName;\r\n return tmpImage;\r\n }\r\n startDraw(){\r\n let tmpCheckNode = this._boxArray[this._boxIndex].getChildByName('checked');\r\n if(this.isStop){engine.Tween.removeTweens(tmpCheckNode);return}\r\n if(this.slowDown)\r\n {\r\n if(this._boxIndex != this.getNodeIndexOFprize()){\r\n this.tweenTime += this.slowTweenTime;\r\n }else{\r\n this.isStop = true;\r\n this.twinkle(tmpCheckNode);\r\n }\r\n }\r\n engine.Tween.get(tmpCheckNode)\r\n .to({alpha:1},this.tweenTime/2)\r\n .to({alpha:0},this.tweenTime/2)\r\n .call(()=>{\r\n if(this.circleNumber >= props.circleNumber && this.getSlowStart() == this._boxIndex){\r\n this.slowDown = true;\r\n }\r\n this._boxIndex ++;\r\n if(this._boxIndex >= this._boxArray.length){\r\n this._boxIndex = 0;\r\n this.circleNumber++;\r\n }\r\n \r\n this.startDraw();\r\n \r\n \r\n })\r\n }\r\n //获取开始减速的下标\r\n private getSlowStart(){\r\n if(this.recordID < 0)return -1;\r\n let tmpIndex = this.getNodeIndexOFprize();\r\n if(tmpIndex < 4){\r\n return tmpIndex + 4;\r\n }else{\r\n return tmpIndex - 4\r\n }\r\n }\r\n //获取奖品节点下标\r\n getNodeIndexOFprize(){\r\n if(this.recordID < 0)return -1;\r\n for (let index = 0; index < this._boxArray.length; index++) {\r\n let element = this._boxArray[index];\r\n if(element.prizeID === this.recordID){\r\n return index;\r\n } \r\n }\r\n return -1;\r\n }\r\n //中奖节点闪烁\r\n twinkle(tmpNode){\r\n engine.Tween.removeTweens(tmpNode)\r\n let twinkleTime = 1;\r\n engine.Tween.get(tmpNode, {loop:true})\r\n .to({alpha:0}, 30)\r\n .to({alpha:1}, 30)\r\n .call(()=>{\r\n if(twinkleTime > 5){\r\n engine.Tween.removeTweens(tmpNode);\r\n engine.globalEvent.dispatchEvent('jiugong-turntable-change-over')\r\n return;\r\n }else{\r\n twinkleTime++;\r\n }\r\n })\r\n }\r\n setRecordID(prizeID){\r\n this.recordID = prizeID;\r\n }\r\n reset(){\r\n this._boxArray.forEach(element => {\r\n engine.Tween.removeTweens(element.getChildByName('checked'));\r\n });\r\n this._boxIndex = 0;//当前下标\r\n this.tweenTime = props.tweenTime || 200;//单个动画时间(毫秒)\r\n this.slowTweenTime = props.slowTweenTime || 200;\r\n this.circleNumber = 0;//圈数\r\n this.recordID = -1;//中奖奖品ID\r\n this.boxPrizeIndex = -1;//中奖奖品节点下标 \r\n this.slowDown = false;//是否开始缓速\r\n this.isStop = false;\r\n for (let index = 0; index < this._boxArray.length; index++) {\r\n let element = this._boxArray[index];\r\n element.getChildByName('checked').alpha = 0;\r\n }\r\n \r\n }\r\n\r\n}","\r\n/**\r\n * Created by rockyl on 2018/8/16.\r\n */\r\n\r\nimport {props} from \"../props\";\r\nimport { Turntable } from \"./turntable\";\r\n\r\n\r\n\r\n\r\n\r\nexport default class GameView extends engine.Container {\r\n\r\n\t\r\n\tprivate _hasSetup;\r\n\tprivate _turntable:Turntable;\r\n\tconstructor() {\r\n\t\tsuper();\t\r\n\t}\r\n\t setup(){\r\n\t\tif (this._hasSetup) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tthis._hasSetup = true;\r\n\t\t\r\n\t\tlet turntable = this._turntable = new Turntable();\r\n\t\tthis.addChild(turntable);\r\n\t}\r\n\tsetPrizeData(res){\r\n\t\tthis._turntable.initData(res);\r\n\t}\r\n\tstartDraw(){\r\n\t\tthis._turntable.startDraw();\r\n\t}\r\n\tsetRecordID(prizeID){\r\n\t\tthis._turntable.setRecordID(prizeID)\r\n\t}\r\n\treset(){\r\n\t\tthis._turntable.reset();\r\n\t}\r\n\tsetSetup(){\r\n\t\tthis._hasSetup = false;\r\n\t}\r\n}\r\n","\r\n\r\nimport { props } from '../props';\r\n\r\n\r\n/**\r\n * Created by rockyl on 2020-01-09.\r\n */\r\n\r\nimport GameView from \"./GameView\";\r\n\r\nexport class GameWrapper extends engine.Container {\r\n\tprivate _gameView: GameView;\r\n\r\n\tconstructor() {\r\n\t\tsuper();\r\n\r\n\t\tengine.globalEvent.addEventListener('jiugong-turntable-change-init', this.init, this);\r\n\t\tengine.globalEvent.addEventListener('jiugong-turntable-change-prizeData', this.initPrizeData, this);\r\n\r\n\t\tengine.globalEvent.addEventListener('jiugong-turntable-change-start', this.start, this);\r\n\r\n\t\tengine.globalEvent.addEventListener('jiugong-turntable-change-winPrize', this.winPrize, this);\r\n\t\tengine.globalEvent.addEventListener('jiugong-turntable-change-reset', this.reset, this);\r\n\t\tengine.globalEvent.addEventListener('jiugong-turntable-change-abnormal', this.reset, this);\r\n\t}\r\n\r\n\tinit(event: engine.Event) {\r\n\t\t//初始化场景\r\n\t\tlet gameView = this._gameView = new GameView();\r\n\t\tthis.addChild(gameView);\r\n\t\tthis._gameView.setup();\r\n\t}\r\n\tinitPrizeData(event: engine.Event){\r\n\t\tthis._gameView.setSetup();\r\n\t\tthis._gameView.setPrizeData(event.data.resources);\r\n\t}\r\n\r\n\t//开始抽奖\r\n\tstart(event: engine.Event){\r\n\t\tthis._gameView.startDraw();\r\n\t}\r\n\twinPrize(event: engine.Event){\r\n\t\tthis._gameView.setRecordID(event.data.prizeID)\r\n\t}\r\n\treset(){\r\n\t\tthis._gameView.reset();\r\n\t}\r\n\t// private visibilitychange(){\r\n\t// \tdocument.addEventListener('visibilitychange', function () {\r\n // if (document.visibilityState === 'hidden') {\r\n\t// \t\t\tconsole.log('放置后台');\r\n\t// \t\t\tengine.globalEvent.dispatchEvent('answer-game-visibilitychange',{hidden:true});\r\n // }\r\n // });\r\n\t// }\r\n}\r\n","/**\r\n * Created by rockyl on 2019-11-20.\r\n */\r\n\r\nimport {GameWrapper} from \"./game/GameWrapper\";\r\nimport {injectProps, prepareProps} from \"./props\";\r\n\r\nexport default function (props) {\r\n\tprepareProps();\r\n\tinjectProps(props);\r\n\r\n\tlet instance = new GameWrapper();\r\n\treturn instance;\r\n}\r\n"],"names":["__extends"],"mappings":";;;;;;UAKgB,UAAU,CAAC,IAAI;KAC9B,OAAO,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;CACvD,CAAC;AAED,UAAgB,gBAAgB,CAAC,IAAI;KACpC,OAAO,UAAU,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;CACrD,CAAC;AAED;;CCTO,IAAI,KAAK,GAAQ,EAAE,CAAC;AAE3B,UAAgB,YAAY;KAC3B,IAAI,SAAS,GAAG,QAAQ,EAAE,CAAC;KAE3B,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;CACrC,CAAC;AAED,U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
"name": "九宫格抽奖-更换奖池",
"desc": "九宫格抽奖模块-更换奖池",
"props": {
"horizontal": {
"alias": "横向间距",
"type": "number",
"default": 1
},
"vertical": {
"alias": "纵向间距",
"type": "number",
"default": 1
},
"circleNumber": {
"alias": "至少转的圈数",
"type": "number",
"default": 3
},
"tweenTime": {
"alias": "单个奖品节点动画时间(毫秒)",
"type": "number",
"default": 200
},
"slowTweenTime": {
"alias": "中奖后缓速递增时长",
"type": "number",
"default": 200
},
"icon_width": {
"alias": "奖品图宽度",
"type": "number",
"default": 110
},
"icon_height": {
"alias": "奖品图高度",
"type": "number",
"default": 110
},
"icon_X": {
"alias": "奖品X轴偏移量(底框背景有透明)",
"type": "number",
"default": 0
},
"icon_Y": {
"alias": "奖品Y轴偏移量(底框背景有透明)",
"type": "number",
"default": -20
},
"prizeName_size": {
"alias": "奖品名字字号",
"type": "number",
"default": 30
},
"prizeName_Ypos": {
"alias": "奖品名字相对于底框的高度",
"type": "number",
"default": 50
},
"prizeName_color": {
"alias": "奖品名字颜色值",
"type": "string",
"default": "#e8805d"
},
"prizeName_maxLength": {
"alias": "奖品名字最长显示长度",
"type": "number",
"default": 8
},
"prizeName_retainLength": {
"alias": "奖品名字超过长度保留多少字数",
"type": "number",
"default": 5
}
},
"assets": [
{
"name": "unchecked",
"url": "//yun.duiba.com.cn/aurora/assets/3351a20f982fea1fbcbbb3b85bc03f6b547c8bbc.png",
"uuid": "48dc9c00-92c3-4926-8d6b-9eb3e0d0668d",
"ext": ".png"
},
{
"name": "checked",
"url": " //yun.duiba.com.cn/aurora/assets/2a9f9ecc43eb912db553fa4685c1987a937f0198.png",
"uuid": "1d7bc84d-689d-4a6a-a023-e4a7b9659083",
"ext": ".png"
}
],
"events": {
"in": {
"jiugong-turntable-change-init": {
"alias": "初始化",
"data": {
}
},
"jiugong-turntable-change-prizeData": {
"alias": "奖品数据",
"data": {
}
},
"jiugong-turntable-change-start": {
"alias": "开始",
"data": {
}
},
"jiugong-turntable-change-winPrize": {
"alias": "中奖",
"data": {
}
},
"jiugong-turntable-change-abnormal": {
"alias": "异常",
"data": {
}
},
"jiugong-turntable-change-reset": {
"alias": "重置",
"data": {
}
}
},
"out": {
"jiugong-turntable-change-over": {
"alias": "结束",
"data": {
}
}
}
}
}
\ No newline at end of file
/**
* Created by rockyl on 2018/8/16.
*/
import {props} from "../props";
import { Turntable } from "./turntable";
export default class GameView extends engine.Container {
private _hasSetup;
private _turntable:Turntable;
constructor() {
super();
}
setup(){
if (this._hasSetup) {
return;
}
this._hasSetup = true;
let turntable = this._turntable = new Turntable();
this.addChild(turntable);
}
setPrizeData(res){
this._turntable.initData(res);
}
startDraw(){
this._turntable.startDraw();
}
setRecordID(prizeID){
this._turntable.setRecordID(prizeID)
}
reset(){
this._turntable.reset();
}
setSetup(){
this._hasSetup = false;
}
}
import { props } from '../props';
/**
* Created by rockyl on 2020-01-09.
*/
import GameView from "./GameView";
export class GameWrapper extends engine.Container {
private _gameView: GameView;
constructor() {
super();
engine.globalEvent.addEventListener('jiugong-turntable-change-init', this.init, this);
engine.globalEvent.addEventListener('jiugong-turntable-change-prizeData', this.initPrizeData, this);
engine.globalEvent.addEventListener('jiugong-turntable-change-start', this.start, this);
engine.globalEvent.addEventListener('jiugong-turntable-change-winPrize', this.winPrize, this);
engine.globalEvent.addEventListener('jiugong-turntable-change-reset', this.reset, this);
engine.globalEvent.addEventListener('jiugong-turntable-change-abnormal', this.reset, this);
}
init(event: engine.Event) {
//初始化场景
let gameView = this._gameView = new GameView();
this.addChild(gameView);
this._gameView.setup();
}
initPrizeData(event: engine.Event){
this._gameView.setSetup();
this._gameView.setPrizeData(event.data.resources);
}
//开始抽奖
start(event: engine.Event){
this._gameView.startDraw();
}
winPrize(event: engine.Event){
this._gameView.setRecordID(event.data.prizeID)
}
reset(){
this._gameView.reset();
}
// private visibilitychange(){
// document.addEventListener('visibilitychange', function () {
// if (document.visibilityState === 'hidden') {
// console.log('放置后台');
// engine.globalEvent.dispatchEvent('answer-game-visibilitychange',{hidden:true});
// }
// });
// }
}
import {getTextureByName} from "./utils";
import {getStage} from "./utils";
import { props } from '../props';
export class Turntable extends engine.Container{
private _turnTableNode:engine.Container;
private _vertical_Y = props.vertical || 20;//纵向间距
private _horizontal_X = props.horizontal || 20;//横向间距
private _prizeIndex = 0;
private _boxArray = [];
private _boxIndex = 0;//当前下标
private tweenTime = props.tweenTime || 200;//单个动画时间(毫秒)
private slowTweenTime = props.slowTweenTime || 200;
private circleNumber = 0;//圈数
private turntableOrder = [1,2,3,5,8,7,6,4];
private recordID = -1;//中奖奖品ID
private boxPrizeIndex = -1;//中奖奖品节点下标
private slowDown = false;//是否开始缓速
private isStop = false;
private _singleNodeWidth;//单个节点宽度
constructor(){
super()
}
public initData(res){
this.initTurntable(res);
this.setNodeOrder();
}
initTurntable(res){
let turnTableNode = null;
if(this._turnTableNode){
this.removeChild(this._turnTableNode);
this._turnTableNode = null;
this._boxArray = [];
this._prizeIndex = 0;
this._boxIndex = 0;
}
turnTableNode = this._turnTableNode = new engine.Container();
//turnTableNode.y = 50;
this.addChild(turnTableNode);
for (let index_Y = 0; index_Y < 3; index_Y++) {
for (let index_X = 0; index_X < 3; index_X++) {
if(index_X == 1 && index_Y == 1)continue;
let tmpNode:any = new engine.Container()
let unchecked = this.getImage('unchecked',1);
let checked = this.getImage('checked',0);
tmpNode.width = Math.max(unchecked.width,checked.width);
this._singleNodeWidth = this._singleNodeWidth ? this._singleNodeWidth : tmpNode.width;
tmpNode.height = Math.max(unchecked.height,checked.height);
tmpNode.x = index_X*(tmpNode.width + this._horizontal_X);
tmpNode.y = index_Y*(tmpNode.height + this._vertical_Y);
tmpNode.addChild(unchecked);
tmpNode.addChild(checked);
let prize =new engine.Sprite(engine.Texture.fromImage(res[this._prizeIndex].img)) ;
let prizeID = res[this._prizeIndex].id;
prize.width = props.icon_width;
prize.height = props.icon_height;
prize.x = (tmpNode.width - prize.width)/2 + props.icon_X;
prize.y = (tmpNode.height - prize.height)/2 + props.icon_Y;
tmpNode.prizeID = prizeID;
tmpNode.addChild(prize);
let titleLabel = new engine.Label();
titleLabel.fillColor = props.prizeName_color;
titleLabel.size = props.prizeName_size;
titleLabel.width = unchecked.width;
titleLabel.textAlign = engine.TEXT_ALIGN.CENTER;
titleLabel.x = 0;
titleLabel.y = props.prizeName_Ypos;
titleLabel.text = this.fixTitle(res[this._prizeIndex].name);
tmpNode.addChild(titleLabel)
this._prizeIndex ++ ;
this._boxArray.push(tmpNode);
turnTableNode.addChild(tmpNode);
}
}
turnTableNode.x = (750 - (this._singleNodeWidth*3 + this._horizontal_X*2))/2;
}
setNodeOrder(){
let tmpNodeArray = [];
for (let index = 0; index < this.turntableOrder.length; index++) {
let order = this.turntableOrder[index];
tmpNodeArray.push(this._boxArray[order-1]);
}
this._boxArray = tmpNodeArray;
}
fixTitle(name){
if(!name){
return ""
}
if(name.split("").length<props.prizeName_maxLength){
return name
}
let n = ""
for(let i=0;i<props.prizeName_retainLength;i++){
n += name.split("")[i]
}
n+="..."
return n
}
getImage(resName,alpha){
let tmpImage = new engine.Sprite(getTextureByName(resName));
tmpImage.x = 0
tmpImage.y = 0
tmpImage.alpha = alpha;
tmpImage.name = resName;
return tmpImage;
}
startDraw(){
let tmpCheckNode = this._boxArray[this._boxIndex].getChildByName('checked');
if(this.isStop){engine.Tween.removeTweens(tmpCheckNode);return}
if(this.slowDown)
{
if(this._boxIndex != this.getNodeIndexOFprize()){
this.tweenTime += this.slowTweenTime;
}else{
this.isStop = true;
this.twinkle(tmpCheckNode);
}
}
engine.Tween.get(tmpCheckNode)
.to({alpha:1},this.tweenTime/2)
.to({alpha:0},this.tweenTime/2)
.call(()=>{
if(this.circleNumber >= props.circleNumber && this.getSlowStart() == this._boxIndex){
this.slowDown = true;
}
this._boxIndex ++;
if(this._boxIndex >= this._boxArray.length){
this._boxIndex = 0;
this.circleNumber++;
}
this.startDraw();
})
}
//获取开始减速的下标
private getSlowStart(){
if(this.recordID < 0)return -1;
let tmpIndex = this.getNodeIndexOFprize();
if(tmpIndex < 4){
return tmpIndex + 4;
}else{
return tmpIndex - 4
}
}
//获取奖品节点下标
getNodeIndexOFprize(){
if(this.recordID < 0)return -1;
for (let index = 0; index < this._boxArray.length; index++) {
let element = this._boxArray[index];
if(element.prizeID === this.recordID){
return index;
}
}
return -1;
}
//中奖节点闪烁
twinkle(tmpNode){
engine.Tween.removeTweens(tmpNode)
let twinkleTime = 1;
engine.Tween.get(tmpNode, {loop:true})
.to({alpha:0}, 30)
.to({alpha:1}, 30)
.call(()=>{
if(twinkleTime > 5){
engine.Tween.removeTweens(tmpNode);
engine.globalEvent.dispatchEvent('jiugong-turntable-change-over')
return;
}else{
twinkleTime++;
}
})
}
setRecordID(prizeID){
this.recordID = prizeID;
}
reset(){
this._boxArray.forEach(element => {
engine.Tween.removeTweens(element.getChildByName('checked'));
});
this._boxIndex = 0;//当前下标
this.tweenTime = props.tweenTime || 200;//单个动画时间(毫秒)
this.slowTweenTime = props.slowTweenTime || 200;
this.circleNumber = 0;//圈数
this.recordID = -1;//中奖奖品ID
this.boxPrizeIndex = -1;//中奖奖品节点下标
this.slowDown = false;//是否开始缓速
this.isStop = false;
for (let index = 0; index < this._boxArray.length; index++) {
let element = this._boxArray[index];
element.getChildByName('checked').alpha = 0;
}
}
}
\ No newline at end of file
/**
* Created by rockyl on 2020-01-21.
*/
export function getTexture(uuid) {
return engine.Texture.from(getAssetByUUID(uuid).uuid);
}
export function getTextureByName(name) {
return getTexture(engine.getAssetByName(name).uuid);
}
export function playSound(name) {
engine.playSound(engine.getAssetByName(name).uuid, {keep: true});
}
export function getStage(){
return engine.gameStage.stage;
}
\ No newline at end of file
/**
* Created by rockyl on 2019-11-20.
*/
import {GameWrapper} from "./game/GameWrapper";
import {injectProps, prepareProps} from "./props";
export default function (props) {
prepareProps();
injectProps(props);
let instance = new GameWrapper();
return instance;
}
/**
* Created by rockyl on 2020-01-21.
*/
export let props: any = {};
export function prepareProps() {
let metaProps = getProps();
engine.injectProp(props, metaProps);
}
export function injectProps(p) {
engine.injectProp(props, p);
}
...@@ -47,37 +47,40 @@ ...@@ -47,37 +47,40 @@
var turnTableNode = this._turnTableNode = new engine.Container(); var turnTableNode = this._turnTableNode = new engine.Container();
this.addChild(turnTableNode); this.addChild(turnTableNode);
for (var index_Y = 0; index_Y < 3; index_Y++) { for (var index_Y = 0; index_Y < 3; index_Y++) {
var _loop_1 = function (index_X) { for (var index_X = 0; index_X < 3; index_X++) {
if (index_X == 1 && index_Y == 1) if (index_X == 1 && index_Y == 1)
return "continue"; continue;
var tmpNode = new engine.Container(); var tmpNode = new engine.Container();
var unchecked = this_1.getImage('unchecked', 1); var unchecked = this.getImage('unchecked', 1);
var checked = this_1.getImage('checked', 0); var checked = this.getImage('checked', 0);
tmpNode.width = Math.max(unchecked.width, checked.width); tmpNode.width = Math.max(unchecked.width, checked.width);
this_1._singleNodeWidth = this_1._singleNodeWidth ? this_1._singleNodeWidth : tmpNode.width; this._singleNodeWidth = this._singleNodeWidth ? this._singleNodeWidth : tmpNode.width;
tmpNode.height = Math.max(unchecked.height, checked.height); tmpNode.height = Math.max(unchecked.height, checked.height);
tmpNode.x = index_X * (tmpNode.width + this_1._horizontal_X); tmpNode.x = index_X * (tmpNode.width + this._horizontal_X);
tmpNode.y = index_Y * (tmpNode.height + this_1._vertical_Y); tmpNode.y = index_Y * (tmpNode.height + this._vertical_Y);
tmpNode.addChild(unchecked); checked.x = (tmpNode.width - checked.width) / 2;
tmpNode.addChild(checked); checked.y = (tmpNode.height - checked.height) / 2;
unchecked.x = (tmpNode.width - unchecked.width) / 2;
unchecked.y = (tmpNode.height - unchecked.height) / 2;
if (props.layer) {
tmpNode.addChild(checked);
tmpNode.addChild(unchecked);
}
else {
tmpNode.addChild(unchecked);
tmpNode.addChild(checked);
}
turnTableNode.addChild(tmpNode); turnTableNode.addChild(tmpNode);
var tmpTexture = engine.Texture.fromImage(res[this_1._prizeIndex].img, undefined); var prize = new engine.Sprite(engine.Texture.fromImage(res[this._prizeIndex].img));
var prizeID = res[this_1._prizeIndex].id; var prizeID = res[this._prizeIndex].id;
tmpTexture.addEventListener('loaded', function () { prize.width = props.icon_width;
var prize = new engine.Sprite(tmpTexture); prize.height = props.icon_height;
prize.width = props.icon_width; prize.x = (tmpNode.width - prize.width) / 2 + props.icon_X;
prize.height = props.icon_height; prize.y = (tmpNode.height - prize.height) / 2 + props.icon_Y;
prize.x = (tmpNode.width - prize.width) / 2 + props.icon_X; tmpNode.prizeID = prizeID;
prize.y = (tmpNode.height - prize.height) / 2 + props.icon_Y; tmpNode.addChild(prize);
tmpNode.prizeID = prizeID; this._prizeIndex++;
tmpNode.addChild(prize); this._boxArray.push(tmpNode);
}, this_1);
this_1._prizeIndex++;
this_1._boxArray.push(tmpNode);
};
var this_1 = this;
for (var index_X = 0; index_X < 3; index_X++) {
_loop_1(index_X);
} }
} }
turnTableNode.x = (750 - (this._singleNodeWidth * 3 + this._horizontal_X * 2)) / 2; turnTableNode.x = (750 - (this._singleNodeWidth * 3 + this._horizontal_X * 2)) / 2;
...@@ -188,7 +191,6 @@ ...@@ -188,7 +191,6 @@
}; };
return Turntable; return Turntable;
}(engine.Container)); }(engine.Container));
//# sourceMappingURL=turntable.js.map
var GameView = (function (_super) { var GameView = (function (_super) {
tslib.__extends(GameView, _super); tslib.__extends(GameView, _super);
......
{"version":3,"file":"index.js","sources":["src/custom/jiugong-turntable/src/game/utils.ts","src/custom/jiugong-turntable/src/props.ts","src/custom/jiugong-turntable/src/game/turntable.ts","src/custom/jiugong-turntable/src/game/GameView.ts","src/custom/jiugong-turntable/src/game/GameWrapper.ts","src/custom/jiugong-turntable/src/index.ts"],"sourcesContent":["\r\n/**\r\n * Created by rockyl on 2020-01-21.\r\n */\r\n\r\nexport function getTexture(uuid) {\r\n\treturn engine.Texture.from(getAssetByUUID(uuid).uuid);\r\n}\r\n\r\nexport function getTextureByName(name) {\r\n\treturn getTexture(engine.getAssetByName(name).uuid);\r\n}\r\n\r\nexport function playSound(name) {\r\n\tengine.playSound(engine.getAssetByName(name).uuid, {keep: true});\r\n}\r\nexport function getStage(){\r\n\treturn engine.gameStage.stage;\r\n}","/**\r\n * Created by rockyl on 2020-01-21.\r\n */\r\n\r\nexport let props: any = {};\r\n\r\nexport function prepareProps() {\r\n\tlet metaProps = getProps();\r\n\r\n\tengine.injectProp(props, metaProps);\r\n}\r\n\r\nexport function injectProps(p) {\r\n\tengine.injectProp(props, p);\r\n}\r\n","\r\nimport {getTextureByName} from \"./utils\";\r\nimport {getStage} from \"./utils\";\r\n\r\nimport { props } from '../props';\r\n\r\nexport class Turntable extends engine.Container{\r\n private _turnTableNode;\r\n private _vertical_Y = props.vertical || 20;//纵向间距\r\n private _horizontal_X = props.horizontal || 20;//横向间距\r\n private _prizeIndex = 0;\r\n\r\n private _boxArray = [];\r\n private _boxIndex = 0;//当前下标\r\n\r\n private tweenTime = props.tweenTime || 200;//单个动画时间(毫秒)\r\n private slowTweenTime = props.slowTweenTime || 200;\r\n private circleNumber = 0;//圈数\r\n\r\n private turntableOrder = [1,2,3,5,8,7,6,4]; \r\n private recordID = -1;//中奖奖品ID\r\n private boxPrizeIndex = -1;//中奖奖品节点下标 \r\n private slowDown = false;//是否开始缓速\r\n private isStop = false;\r\n\r\n private _singleNodeWidth;//单个节点宽度\r\n constructor(res){\r\n super()\r\n this.initTurntable(res);\r\n this.setNodeOrder();\r\n }\r\n initTurntable(res){\r\n let turnTableNode = this._turnTableNode = new engine.Container();\r\n //turnTableNode.y = 50;\r\n this.addChild(turnTableNode);\r\n for (let index_Y = 0; index_Y < 3; index_Y++) {\r\n for (let index_X = 0; index_X < 3; index_X++) { \r\n if(index_X == 1 && index_Y == 1)continue;\r\n let tmpNode:any = new engine.Container()\r\n\r\n let unchecked = this.getImage('unchecked',1);\r\n let checked = this.getImage('checked',0);\r\n\r\n tmpNode.width = Math.max(unchecked.width,checked.width);\r\n this._singleNodeWidth = this._singleNodeWidth ? this._singleNodeWidth : tmpNode.width;\r\n tmpNode.height = Math.max(unchecked.height,checked.height);\r\n tmpNode.x = index_X*(tmpNode.width + this._horizontal_X);\r\n tmpNode.y = index_Y*(tmpNode.height + this._vertical_Y);\r\n tmpNode.addChild(unchecked);\r\n tmpNode.addChild(checked);\r\n turnTableNode.addChild(tmpNode);\r\n\r\n let tmpTexture:engine.Texture = engine.Texture.fromImage(res[this._prizeIndex].img,undefined);\r\n let prizeID = res[this._prizeIndex].id;\r\n tmpTexture.addEventListener('loaded',()=>{\r\n let prize = new engine.Sprite(tmpTexture);\r\n prize.width = props.icon_width;\r\n prize.height = props.icon_height;\r\n prize.x = (tmpNode.width - prize.width)/2 + props.icon_X;\r\n prize.y = (tmpNode.height - prize.height)/2 + props.icon_Y;\r\n tmpNode.prizeID = prizeID;\r\n tmpNode.addChild(prize);\r\n },this)\r\n this._prizeIndex ++ ;\r\n this._boxArray.push(tmpNode); \r\n }\r\n }\r\n turnTableNode.x = (750 - (this._singleNodeWidth*3 + this._horizontal_X*2))/2;\r\n }\r\n\r\n setNodeOrder(){\r\n let tmpNodeArray = [];\r\n for (let index = 0; index < this.turntableOrder.length; index++) {\r\n let order = this.turntableOrder[index];\r\n tmpNodeArray.push(this._boxArray[order-1]);\r\n }\r\n this._boxArray = tmpNodeArray;\r\n }\r\n\r\n getImage(resName,alpha){\r\n let tmpImage = new engine.Sprite(getTextureByName(resName));\r\n tmpImage.x = 0\r\n tmpImage.y = 0\r\n tmpImage.alpha = alpha;\r\n tmpImage.name = resName;\r\n return tmpImage;\r\n }\r\n startDraw(){\r\n let tmpCheckNode = this._boxArray[this._boxIndex].getChildByName('checked');\r\n if(this.isStop){engine.Tween.removeTweens(tmpCheckNode);return}\r\n if(this.slowDown)\r\n {\r\n if(this._boxIndex != this.getNodeIndexOFprize()){\r\n this.tweenTime += this.slowTweenTime;\r\n }else{\r\n this.isStop = true;\r\n this.twinkle(tmpCheckNode);\r\n }\r\n }\r\n engine.Tween.get(tmpCheckNode)\r\n .to({alpha:1},this.tweenTime/2)\r\n .to({alpha:0},this.tweenTime/2)\r\n .call(()=>{\r\n if(this.circleNumber >= props.circleNumber && this.getSlowStart() == this._boxIndex){\r\n this.slowDown = true;\r\n }\r\n this._boxIndex ++;\r\n if(this._boxIndex >= this._boxArray.length){\r\n this._boxIndex = 0;\r\n this.circleNumber++;\r\n }\r\n \r\n this.startDraw();\r\n \r\n \r\n })\r\n }\r\n //获取开始减速的下标\r\n private getSlowStart(){\r\n if(this.recordID < 0)return -1;\r\n let tmpIndex = this.getNodeIndexOFprize();\r\n if(tmpIndex < 4){\r\n return tmpIndex + 4;\r\n }else{\r\n return tmpIndex - 4\r\n }\r\n }\r\n //获取奖品节点下标\r\n getNodeIndexOFprize(){\r\n if(this.recordID < 0)return -1;\r\n for (let index = 0; index < this._boxArray.length; index++) {\r\n let element = this._boxArray[index];\r\n if(element.prizeID === this.recordID){\r\n return index;\r\n } \r\n }\r\n return -1;\r\n }\r\n //中奖节点闪烁\r\n twinkle(tmpNode){\r\n engine.Tween.removeTweens(tmpNode)\r\n let twinkleTime = 1;\r\n engine.Tween.get(tmpNode, {loop:true})\r\n .to({alpha:0}, 30)\r\n .to({alpha:1}, 30)\r\n .call(()=>{\r\n if(twinkleTime > 5){\r\n engine.Tween.removeTweens(tmpNode);\r\n engine.globalEvent.dispatchEvent('jiugong-turntable-over')\r\n return;\r\n }else{\r\n twinkleTime++;\r\n }\r\n })\r\n }\r\n setRecordID(prizeID){\r\n this.recordID = prizeID;\r\n }\r\n reset(){\r\n engine.Tween.removeAllTweens();\r\n this._boxIndex = 0;//当前下标\r\n this.tweenTime = props.tweenTime || 200;//单个动画时间(毫秒)\r\n this.slowTweenTime = props.slowTweenTime || 200;\r\n this.circleNumber = 0;//圈数\r\n this.recordID = -1;//中奖奖品ID\r\n this.boxPrizeIndex = -1;//中奖奖品节点下标 \r\n this.slowDown = false;//是否开始缓速\r\n this.isStop = false;\r\n for (let index = 0; index < this._boxArray.length; index++) {\r\n let element = this._boxArray[index];\r\n element.getChildByName('checked').alpha = 0;\r\n }\r\n \r\n }\r\n\r\n}","\r\n/**\r\n * Created by rockyl on 2018/8/16.\r\n */\r\n\r\nimport {props} from \"../props\";\r\nimport { Turntable } from \"./turntable\";\r\n\r\n\r\n\r\n\r\n\r\nexport default class GameView extends engine.Container {\r\n\r\n\t\r\n\tprivate _hasSetup;\r\n\tprivate _turntable:Turntable;\r\n\tconstructor() {\r\n\t\tsuper();\t\r\n\t}\r\n\t setup(res){\r\n\t\tif (this._hasSetup) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tthis._hasSetup = true;\r\n\t\t\r\n\t\tlet turntable = this._turntable = new Turntable(res);\r\n\t\tthis.addChild(turntable);\r\n\t}\r\n\tstartDraw(){\r\n\t\tthis._turntable.startDraw();\r\n\t}\r\n\tsetRecordID(prizeID){\r\n\t\tthis._turntable.setRecordID(prizeID)\r\n\t}\r\n\treset(){\r\n\t\tthis._turntable.reset();\r\n\t}\r\n}\r\n","\r\n\r\nimport { props } from './../props';\r\n\r\n\r\n/**\r\n * Created by rockyl on 2020-01-09.\r\n */\r\n\r\nimport GameView from \"./GameView\";\r\n\r\nexport class GameWrapper extends engine.Container {\r\n\tprivate _gameView: GameView;\r\n\r\n\tconstructor() {\r\n\t\tsuper();\r\n\r\n\t\tengine.globalEvent.addEventListener('jiugong-turntable-init', this.init, this);\r\n\r\n\t\tengine.globalEvent.addEventListener('jiugong-turntable-start', this.start, this);\r\n\r\n\t\tengine.globalEvent.addEventListener('jiugong-turntable-winPrize', this.winPrize, this);\r\n\t\tengine.globalEvent.addEventListener('jiugong-turntable-reset', this.reset, this);\r\n\t\tengine.globalEvent.addEventListener('jiugong-turntable-abnormal', this.reset, this);\r\n\t}\r\n\r\n\tinit(event: engine.Event) {\r\n\t\t//初始化场景\r\n\t\tlet gameView = this._gameView = new GameView();\r\n\t\tthis.addChild(gameView);\r\n\t\tconsole.log('奖品图',event.data.resources); \r\n\t\tthis._gameView.setup(event.data.resources);\r\n\t}\r\n\r\n\t//开始抽奖\r\n\tstart(event: engine.Event){\r\n\t\tthis._gameView.startDraw();\r\n\t}\r\n\twinPrize(event: engine.Event){\r\n\t\tthis._gameView.setRecordID(event.data.prizeID)\r\n\t}\r\n\treset(){\r\n\t\tthis._gameView.reset();\r\n\t}\r\n\t// private visibilitychange(){\r\n\t// \tdocument.addEventListener('visibilitychange', function () {\r\n // if (document.visibilityState === 'hidden') {\r\n\t// \t\t\tconsole.log('放置后台');\r\n\t// \t\t\tengine.globalEvent.dispatchEvent('answer-game-visibilitychange',{hidden:true});\r\n // }\r\n // });\r\n\t// }\r\n}\r\n","/**\r\n * Created by rockyl on 2019-11-20.\r\n */\r\n\r\nimport {GameWrapper} from \"./game/GameWrapper\";\r\nimport {injectProps, prepareProps} from \"./props\";\r\n\r\nexport default function (props) {\r\n\tprepareProps();\r\n\tinjectProps(props);\r\n\r\n\tlet instance = new GameWrapper();\r\n\treturn instance;\r\n}\r\n"],"names":["__extends"],"mappings":";;;;;;UAKgB,UAAU,CAAC,IAAI;KAC9B,OAAO,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;CACvD,CAAC;AAED,UAAgB,gBAAgB,CAAC,IAAI;KACpC,OAAO,UAAU,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;CACrD,CAAC;AAED;;CCTO,IAAI,KAAK,GAAQ,EAAE,CAAC;AAE3B,UAAgB,YAAY;KAC3B,IAAI,SAAS,GAAG,QAAQ,EAAE,CAAC;KAE3B,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;CACrC,CAAC;AAED,UAAgB,WAAW,CAAC,CAAC;KAC5B,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;CAC7B,CAAC;;;CCRD;KAA+BA,mCAAgB;KAoB3C,mBAAY,GAAG;SAAf,YACI,iBAAO,SAGV;SAtBO,iBAAW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D,2BAAK,GAAL,UAAM,KAAmB;SACxB,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE,CAAC;MAC3B;KACD,8BAAQ,GAAR,UAAS,KAAmB;SAC3B,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;MAC9C;KACD,2BAAK,GAAL;SACC,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;MACvB;KASF,kBAAC;CAAD,CAAC,CAzCgC,MAAM,CAAC,SAAS,GAyChD;;;iBC7CwB,KAAK;KAC7B,YAAY,EAAE,CAAC;KACf,WAAW,CAAC,KAAK,CAAC,CAAC;KAEnB,IAAI,QAAQ,GAAG,IAAI,WAAW,EAAE,CAAC;KACjC,OAAO,QAAQ,CAAC;CACjB,CAAC;;;;;;;;;"} {"version":3,"file":"index.js","sources":["src/custom/jiugong-turntable/src/game/utils.ts","src/custom/jiugong-turntable/src/props.ts","src/custom/jiugong-turntable/src/game/turntable.ts","src/custom/jiugong-turntable/src/game/GameView.ts","src/custom/jiugong-turntable/src/game/GameWrapper.ts","src/custom/jiugong-turntable/src/index.ts"],"sourcesContent":["\r\n/**\r\n * Created by rockyl on 2020-01-21.\r\n */\r\n\r\nexport function getTexture(uuid) {\r\n\treturn engine.Texture.from(getAssetByUUID(uuid).uuid);\r\n}\r\n\r\nexport function getTextureByName(name) {\r\n\treturn getTexture(engine.getAssetByName(name).uuid);\r\n}\r\n\r\nexport function playSound(name) {\r\n\tengine.playSound(engine.getAssetByName(name).uuid, {keep: true});\r\n}\r\nexport function getStage(){\r\n\treturn engine.gameStage.stage;\r\n}","/**\r\n * Created by rockyl on 2020-01-21.\r\n */\r\n\r\nexport let props: any = {};\r\n\r\nexport function prepareProps() {\r\n\tlet metaProps = getProps();\r\n\r\n\tengine.injectProp(props, metaProps);\r\n}\r\n\r\nexport function injectProps(p) {\r\n\tengine.injectProp(props, p);\r\n}\r\n","\r\nimport {getTextureByName} from \"./utils\";\r\nimport {getStage} from \"./utils\";\r\n\r\nimport { props } from '../props';\r\n\r\nexport class Turntable extends engine.Container{\r\n private _turnTableNode;\r\n private _vertical_Y = props.vertical || 20;//纵向间距\r\n private _horizontal_X = props.horizontal || 20;//横向间距\r\n private _prizeIndex = 0;\r\n\r\n private _boxArray = [];\r\n private _boxIndex = 0;//当前下标\r\n\r\n private tweenTime = props.tweenTime || 200;//单个动画时间(毫秒)\r\n private slowTweenTime = props.slowTweenTime || 200;\r\n private circleNumber = 0;//圈数\r\n\r\n private turntableOrder = [1,2,3,5,8,7,6,4]; \r\n private recordID = -1;//中奖奖品ID\r\n private boxPrizeIndex = -1;//中奖奖品节点下标 \r\n private slowDown = false;//是否开始缓速\r\n private isStop = false;\r\n\r\n private _singleNodeWidth;//单个节点宽度\r\n constructor(res){\r\n super()\r\n this.initTurntable(res);\r\n this.setNodeOrder();\r\n }\r\n initTurntable(res){\r\n let turnTableNode = this._turnTableNode = new engine.Container();\r\n //turnTableNode.y = 50;\r\n this.addChild(turnTableNode);\r\n for (let index_Y = 0; index_Y < 3; index_Y++) {\r\n for (let index_X = 0; index_X < 3; index_X++) { \r\n if(index_X == 1 && index_Y == 1)continue;\r\n let tmpNode:any = new engine.Container()\r\n\r\n let unchecked = this.getImage('unchecked',1);\r\n let checked = this.getImage('checked',0);\r\n \r\n tmpNode.width = Math.max(unchecked.width,checked.width);\r\n this._singleNodeWidth = this._singleNodeWidth ? this._singleNodeWidth : tmpNode.width;\r\n \r\n tmpNode.height = Math.max(unchecked.height,checked.height);\r\n tmpNode.x = index_X*(tmpNode.width + this._horizontal_X);\r\n tmpNode.y = index_Y*(tmpNode.height + this._vertical_Y);\r\n\r\n checked.x = (tmpNode.width -checked.width)/2\r\n checked.y = (tmpNode.height -checked.height)/2\r\n\r\n unchecked.x = (tmpNode.width -unchecked.width)/2\r\n unchecked.y = (tmpNode.height -unchecked.height)/2\r\n\r\n if(props.layer){\r\n \r\n tmpNode.addChild(checked);\r\n tmpNode.addChild(unchecked);\r\n \r\n }else{\r\n tmpNode.addChild(unchecked);\r\n tmpNode.addChild(checked);\r\n }\r\n\r\n turnTableNode.addChild(tmpNode);\r\n\r\n // let tmpTexture:engine.Texture = engine.Texture.fromImage(res[this._prizeIndex].img,undefined);\r\n // let prizeID = res[this._prizeIndex].id;\r\n // tmpTexture.addEventListener('loaded',()=>{\r\n // let prize = new engine.Sprite(tmpTexture);\r\n // prize.width = props.icon_width;\r\n // prize.height = props.icon_height;\r\n // prize.x = (tmpNode.width - prize.width)/2 + props.icon_X;\r\n // prize.y = (tmpNode.height - prize.height)/2 + props.icon_Y;\r\n // tmpNode.prizeID = prizeID;\r\n // tmpNode.addChild(prize);\r\n // },this)\r\n\r\n let prize =new engine.Sprite(engine.Texture.fromImage(res[this._prizeIndex].img)) ;\r\n let prizeID = res[this._prizeIndex].id;\r\n prize.width = props.icon_width;\r\n prize.height = props.icon_height;\r\n prize.x = (tmpNode.width - prize.width)/2 + props.icon_X;\r\n prize.y = (tmpNode.height - prize.height)/2 + props.icon_Y;\r\n tmpNode.prizeID = prizeID;\r\n tmpNode.addChild(prize);\r\n\r\n this._prizeIndex ++ ;\r\n this._boxArray.push(tmpNode); \r\n }\r\n }\r\n turnTableNode.x = (750 - (this._singleNodeWidth*3 + this._horizontal_X*2))/2;\r\n }\r\n\r\n setNodeOrder(){\r\n let tmpNodeArray = [];\r\n for (let index = 0; index < this.turntableOrder.length; index++) {\r\n let order = this.turntableOrder[index];\r\n tmpNodeArray.push(this._boxArray[order-1]);\r\n }\r\n this._boxArray = tmpNodeArray;\r\n }\r\n\r\n getImage(resName,alpha){\r\n let tmpImage = new engine.Sprite(getTextureByName(resName));\r\n tmpImage.x = 0\r\n tmpImage.y = 0\r\n tmpImage.alpha = alpha;\r\n tmpImage.name = resName;\r\n return tmpImage;\r\n }\r\n startDraw(){\r\n let tmpCheckNode = this._boxArray[this._boxIndex].getChildByName('checked');\r\n if(this.isStop){engine.Tween.removeTweens(tmpCheckNode);return}\r\n if(this.slowDown)\r\n {\r\n if(this._boxIndex != this.getNodeIndexOFprize()){\r\n this.tweenTime += this.slowTweenTime;\r\n }else{\r\n this.isStop = true;\r\n this.twinkle(tmpCheckNode);\r\n }\r\n }\r\n engine.Tween.get(tmpCheckNode)\r\n .to({alpha:1},this.tweenTime/2)\r\n .to({alpha:0},this.tweenTime/2)\r\n .call(()=>{\r\n if(this.circleNumber >= props.circleNumber && this.getSlowStart() == this._boxIndex){\r\n this.slowDown = true;\r\n }\r\n this._boxIndex ++;\r\n if(this._boxIndex >= this._boxArray.length){\r\n this._boxIndex = 0;\r\n this.circleNumber++;\r\n }\r\n \r\n this.startDraw();\r\n \r\n \r\n })\r\n }\r\n //获取开始减速的下标\r\n private getSlowStart(){\r\n if(this.recordID < 0)return -1;\r\n let tmpIndex = this.getNodeIndexOFprize();\r\n if(tmpIndex < 4){\r\n return tmpIndex + 4;\r\n }else{\r\n return tmpIndex - 4\r\n }\r\n }\r\n //获取奖品节点下标\r\n getNodeIndexOFprize(){\r\n if(this.recordID < 0)return -1;\r\n for (let index = 0; index < this._boxArray.length; index++) {\r\n let element = this._boxArray[index];\r\n if(element.prizeID === this.recordID){\r\n return index;\r\n } \r\n }\r\n return -1;\r\n }\r\n //中奖节点闪烁\r\n twinkle(tmpNode){\r\n engine.Tween.removeTweens(tmpNode)\r\n let twinkleTime = 1;\r\n engine.Tween.get(tmpNode, {loop:true})\r\n .to({alpha:0}, 30)\r\n .to({alpha:1}, 30)\r\n .call(()=>{\r\n if(twinkleTime > 5){\r\n engine.Tween.removeTweens(tmpNode);\r\n engine.globalEvent.dispatchEvent('jiugong-turntable-over')\r\n return;\r\n }else{\r\n twinkleTime++;\r\n }\r\n })\r\n }\r\n setRecordID(prizeID){\r\n this.recordID = prizeID;\r\n }\r\n reset(){\r\n engine.Tween.removeAllTweens();\r\n this._boxIndex = 0;//当前下标\r\n this.tweenTime = props.tweenTime || 200;//单个动画时间(毫秒)\r\n this.slowTweenTime = props.slowTweenTime || 200;\r\n this.circleNumber = 0;//圈数\r\n this.recordID = -1;//中奖奖品ID\r\n this.boxPrizeIndex = -1;//中奖奖品节点下标 \r\n this.slowDown = false;//是否开始缓速\r\n this.isStop = false;\r\n for (let index = 0; index < this._boxArray.length; index++) {\r\n let element = this._boxArray[index];\r\n element.getChildByName('checked').alpha = 0;\r\n }\r\n \r\n }\r\n\r\n}","\r\n/**\r\n * Created by rockyl on 2018/8/16.\r\n */\r\n\r\nimport {props} from \"../props\";\r\nimport { Turntable } from \"./turntable\";\r\n\r\n\r\n\r\n\r\n\r\nexport default class GameView extends engine.Container {\r\n\r\n\t\r\n\tprivate _hasSetup;\r\n\tprivate _turntable:Turntable;\r\n\tconstructor() {\r\n\t\tsuper();\t\r\n\t}\r\n\t setup(res){\r\n\t\tif (this._hasSetup) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tthis._hasSetup = true;\r\n\t\t\r\n\t\tlet turntable = this._turntable = new Turntable(res);\r\n\t\tthis.addChild(turntable);\r\n\t}\r\n\tstartDraw(){\r\n\t\tthis._turntable.startDraw();\r\n\t}\r\n\tsetRecordID(prizeID){\r\n\t\tthis._turntable.setRecordID(prizeID)\r\n\t}\r\n\treset(){\r\n\t\tthis._turntable.reset();\r\n\t}\r\n}\r\n","\r\n\r\nimport { props } from './../props';\r\n\r\n\r\n/**\r\n * Created by rockyl on 2020-01-09.\r\n */\r\n\r\nimport GameView from \"./GameView\";\r\n\r\nexport class GameWrapper extends engine.Container {\r\n\tprivate _gameView: GameView;\r\n\r\n\tconstructor() {\r\n\t\tsuper();\r\n\r\n\t\tengine.globalEvent.addEventListener('jiugong-turntable-init', this.init, this);\r\n\r\n\t\tengine.globalEvent.addEventListener('jiugong-turntable-start', this.start, this);\r\n\r\n\t\tengine.globalEvent.addEventListener('jiugong-turntable-winPrize', this.winPrize, this);\r\n\t\tengine.globalEvent.addEventListener('jiugong-turntable-reset', this.reset, this);\r\n\t\tengine.globalEvent.addEventListener('jiugong-turntable-abnormal', this.reset, this);\r\n\t}\r\n\r\n\tinit(event: engine.Event) {\r\n\t\t//初始化场景\r\n\t\tlet gameView = this._gameView = new GameView();\r\n\t\tthis.addChild(gameView);\r\n\t\tconsole.log('奖品图',event.data.resources); \r\n\t\tthis._gameView.setup(event.data.resources);\r\n\t}\r\n\r\n\t//开始抽奖\r\n\tstart(event: engine.Event){\r\n\t\tthis._gameView.startDraw();\r\n\t}\r\n\twinPrize(event: engine.Event){\r\n\t\tthis._gameView.setRecordID(event.data.prizeID)\r\n\t}\r\n\treset(){\r\n\t\tthis._gameView.reset();\r\n\t}\r\n\t// private visibilitychange(){\r\n\t// \tdocument.addEventListener('visibilitychange', function () {\r\n // if (document.visibilityState === 'hidden') {\r\n\t// \t\t\tconsole.log('放置后台');\r\n\t// \t\t\tengine.globalEvent.dispatchEvent('answer-game-visibilitychange',{hidden:true});\r\n // }\r\n // });\r\n\t// }\r\n}\r\n","/**\r\n * Created by rockyl on 2019-11-20.\r\n */\r\n\r\nimport {GameWrapper} from \"./game/GameWrapper\";\r\nimport {injectProps, prepareProps} from \"./props\";\r\n\r\nexport default function (props) {\r\n\tprepareProps();\r\n\tinjectProps(props);\r\n\r\n\tlet instance = new GameWrapper();\r\n\treturn instance;\r\n}\r\n"],"names":["__extends"],"mappings":";;;;;;UAKgB,UAAU,CAAC,IAAI;KAC9B,OAAO,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;CACvD,CAAC;AAED,UAAgB,gBAAgB,CAAC,IAAI;KACpC,OAAO,UAAU,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;CACrD,CAAC;AAED;;CCTO,IAAI,KAAK,GAAQ,EAAE,CAAC;AAE3B,UAAgB,YAAY;KAC3B,IAAI,SAAS,GAAG,QAAQ,EAAE,CAAC;KAE3B,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;CAC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 @@ ...@@ -46,6 +46,11 @@
"alias": "奖品Y轴偏移量(底框背景有透明)", "alias": "奖品Y轴偏移量(底框背景有透明)",
"type": "number", "type": "number",
"default": -20 "default": -20
},
"layer": {
"alias": "中奖标志是否在最下层",
"type": "boolean",
"default": false
} }
}, },
"assets": [ "assets": [
......
...@@ -40,27 +40,53 @@ export class Turntable extends engine.Container{ ...@@ -40,27 +40,53 @@ export class Turntable extends engine.Container{
let unchecked = this.getImage('unchecked',1); let unchecked = this.getImage('unchecked',1);
let checked = this.getImage('checked',0); let checked = this.getImage('checked',0);
tmpNode.width = Math.max(unchecked.width,checked.width); tmpNode.width = Math.max(unchecked.width,checked.width);
this._singleNodeWidth = this._singleNodeWidth ? this._singleNodeWidth : tmpNode.width; this._singleNodeWidth = this._singleNodeWidth ? this._singleNodeWidth : tmpNode.width;
tmpNode.height = Math.max(unchecked.height,checked.height); tmpNode.height = Math.max(unchecked.height,checked.height);
tmpNode.x = index_X*(tmpNode.width + this._horizontal_X); tmpNode.x = index_X*(tmpNode.width + this._horizontal_X);
tmpNode.y = index_Y*(tmpNode.height + this._vertical_Y); tmpNode.y = index_Y*(tmpNode.height + this._vertical_Y);
tmpNode.addChild(unchecked);
tmpNode.addChild(checked); checked.x = (tmpNode.width -checked.width)/2
checked.y = (tmpNode.height -checked.height)/2
unchecked.x = (tmpNode.width -unchecked.width)/2
unchecked.y = (tmpNode.height -unchecked.height)/2
if(props.layer){
tmpNode.addChild(checked);
tmpNode.addChild(unchecked);
}else{
tmpNode.addChild(unchecked);
tmpNode.addChild(checked);
}
turnTableNode.addChild(tmpNode); turnTableNode.addChild(tmpNode);
let tmpTexture:engine.Texture = engine.Texture.fromImage(res[this._prizeIndex].img,undefined); // let tmpTexture:engine.Texture = engine.Texture.fromImage(res[this._prizeIndex].img,undefined);
// let prizeID = res[this._prizeIndex].id;
// tmpTexture.addEventListener('loaded',()=>{
// let prize = new engine.Sprite(tmpTexture);
// prize.width = props.icon_width;
// prize.height = props.icon_height;
// prize.x = (tmpNode.width - prize.width)/2 + props.icon_X;
// prize.y = (tmpNode.height - prize.height)/2 + props.icon_Y;
// tmpNode.prizeID = prizeID;
// tmpNode.addChild(prize);
// },this)
let prize =new engine.Sprite(engine.Texture.fromImage(res[this._prizeIndex].img)) ;
let prizeID = res[this._prizeIndex].id; let prizeID = res[this._prizeIndex].id;
tmpTexture.addEventListener('loaded',()=>{ prize.width = props.icon_width;
let prize = new engine.Sprite(tmpTexture); prize.height = props.icon_height;
prize.width = props.icon_width; prize.x = (tmpNode.width - prize.width)/2 + props.icon_X;
prize.height = props.icon_height; prize.y = (tmpNode.height - prize.height)/2 + props.icon_Y;
prize.x = (tmpNode.width - prize.width)/2 + props.icon_X; tmpNode.prizeID = prizeID;
prize.y = (tmpNode.height - prize.height)/2 + props.icon_Y; tmpNode.addChild(prize);
tmpNode.prizeID = prizeID;
tmpNode.addChild(prize);
},this)
this._prizeIndex ++ ; this._prizeIndex ++ ;
this._boxArray.push(tmpNode); this._boxArray.push(tmpNode);
} }
......
const W = 600
const H = 600
const MAX_ROW = 3;
const MAX_COL = 3;
const GAP = 10;
const w = W / MAX_COL;
const h = H / MAX_ROW;
export default class GameView extends engine.Container{
constructor(){
super()
}
start(){
}
setup(){
}
cutPicture(parent, url, MAX_ROW, MAX_COL){
const sprite = []
for(let row = 0; row < MAX_ROW; row++) {
for(let col = 0; col < MAX_COL; col++) {
// 创建图片子节点
const child = new engine.Sprite.fromImage(url);
sprite.push(child)
child.scaleX =
}
}
}
}
\ No newline at end of file
import {props} from '../props'
import { getTexture } from "./utils";
const W = 600
const H = 600
const MAX_ROW = 3;
const MAX_COL = 3;
const GAP = 10;
const w = W / MAX_COL;
const h = H / MAX_ROW;
export default class GameView extends engine.Container{
constructor(){
super()
this.once(engine.Event.ADDED_TO_STAGE,this.setup,this);
}
start(){
}
pictures:engine.Sprite[]
private picturesWrapper: engine.Sprite;
setup(){
const getSprites = this.cutPicture(this.picturesWrapper,props.picUrl,MAX_ROW,MAX_COL)
this.pictures = getSprites[0];
const parent = new engine.Sprite();
this.picturesWrapper = parent;
this.addChild(parent);
}
// 切图
cutPicture(parent, url, MAX_ROW, MAX_COL){
const sprite = []
const spritePos = []
// 正确的图片顺序
for(let row = 0; row < MAX_ROW; row++) {
for(let col = 0; col < MAX_COL; col++) {
// 创建图片子节点
const child = engine.Sprite.fromImage(url);
sprite.push(child)
child.scaleX = 1 / MAX_COL;
child.scaleY = 1 / MAX_ROW;
parent.addChild(child);
child.x = col * (W / MAX_COL + GAP);
child.y = row * (H / MAX_ROW + GAP);
spritePos.push([child.x,child.y]);
child.addEventListener(engine.Event.COMPLETE, () => {
const uvs = new Float32Array([
col / MAX_COL,
row / MAX_ROW,
(col + 1) / MAX_COL,
row / MAX_ROW,
(col + 1) / MAX_COL,
(row + 1) / MAX_ROW,
col / MAX_COL,
(row + 1) / MAX_ROW,
]);
child.uvs = uvs;
});
}
}
return [sprite,spritePos];
}
// 随机函数
getRandomArray(array){
array.sort(()=>{
return 0.5 - Math.random();
})
}
}
\ No newline at end of file
export function getTexture(uuid) {
return engine.Texture.from(getAssetByUUID(uuid).uuid);
}
export function getTextureByName(name) {
return getTexture(engine.getAssetByName(name).uuid);
}
export function playSound(name) {
engine.playSound(engine.getAssetByName(name).uuid, {keep: true});
}
export function createSvga(name, anchorName?) {
let inst = new svga.Svga();
inst.source = 'asset://' + engine.getAssetByName(name).uuid;
return inst;
}
\ No newline at end of file
{
"name": "拼图",
"desc": "拼图模块1.0",
"props": {
"MAX_COL": {
"alias": "图片分成几列",
"type": "number",
"default": 3
},
"MAX_ROW": {
"alias": "图片分成几行",
"type": "number",
"default": 4
},
"W": {
"alias": "图片的宽度",
"type": "number",
"default": 618
},
"H": {
"alias": "图片的高度",
"type": "number",
"default": 827
},
"OFFSET_X": {
"alias": "OFFSET_X",
"type": "number",
"default": 0
},
"OFFSET_Y": {
"alias": "OFFSET_Y",
"type": "number",
"default": 0
},
"GAP": {
"alias": "图片间隙",
"type": "number",
"default": 0
},
"GAME_TIME": {
"alias": "游戏时间",
"type": "number",
"default": 50
}
},
"assets": [
{
"name": "遮罩",
"url": "//yun.duiba.com.cn/aurora/assets/5b3e30496b2d9fdafb0cf3835fd6704ce10e45b4.png",
"uuid": "888",
"ext": ".png"
}
],
"events": {
"in": {
"pictures-start": {
"alias": "开始",
"data": {
"picUrl":"图片路径",
"blockUrl":"blockUrl"
}
},
"pictures-stop": {
"alias": "停止"
}
},
"out": {
"pictures-time-update": {
"alias": "倒计时更新",
"data": {
"time":"剩余时间"
}
},
"pictures-game-fail": {
"alias": "游戏结束",
"data": {
"reason": "结束原因(1:时间到了)"
}
},
"pictures-game-success": {
"alias": "游戏成功",
"data": {
"time": "游戏消耗时间"
}
}
}
}
}
\ No newline at end of file
export let props: any = {};
export function prepareProps() {
let metaProps = getProps();
engine.injectProp(props, metaProps);
}
export function injectProps(p) {
engine.injectProp(props, p);
}
\ No newline at end of file
/**
* Created by renjianfeng on 2020-03-13.
*/
const customId = 'p2demo';
(async function () {
let customModule = await fetch(`../meta.json`);
customModule = await customModule.json();
console.log(customModule);
await loadAssets(customModule.assets);
launchWithCustomModule(customModule);
})();
function launchWithCustomModule(customModule) {
//engine.registerCustomCodeModule(customModule);
engine.registerCustomModule(customId, window[customId]);
const { props: propsOption, assets } = customModule;
let props = engine.computeProps(customModuleProps, propsOption);
const customModuleIns = {
id: customId,
props,
assets,
};
engine.registerCustomModules([customModuleIns]);
engine.launchWithConfig({
options: {
entrySceneView: 'entry',
},
assets: [],
views: [{
name: 'entry',
type: 'node',
properties: {
x: 0,
y: 0,
}
}],
customs: [],
}, null, function () {
setTimeout(() => {
engine.addCustomModule(customId, engine.gameStage.sceneContainer.getChildAt(0));
}, 100);
setTimeout(() => {
engine.globalEvent.dispatchEvent('pictures-start', { });
const d = engine.gameStage.sceneContainer.getChildAt(0);
}, 100);
// setTimeout(() => {
// engine.globalEvent.dispatchEvent('pictures-start', {
// picUrl: "http://yun.duiba.com.cn/aurora/assets/e1593b97c27077b85b92f7eaaeae1ed64a1eb79a.png",
// // picUrl: "http://yun.duiba.com.cn/aurora/assets/d23e73d37ec01931e48cbd0a4095367044c5675c.png"
// blockUrl: "888"
// });
// }, 30*1000);
});
engine.globalEvent.addEventListener('pictures-time-update', (e) => {
// console.log(e.type, e.data);
});
engine.globalEvent.addEventListener('pictures-game-fail', (e) => {
console.log(e.type, e.data);
});
engine.globalEvent.addEventListener('pictures-game-success', (e) => {
console.log(e.type, e.data);
});
}
function getAssetByUUID(uuid) {
return engine.resolveCustomAsset(customId, uuid);
}
function getProps() {
return engine.getProps(customId);
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>美食从天而降</title>
<meta name="viewport"
content="width=device-width,initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no"/>
<meta name="apple-mobile-web-app-capable" content="yes"/>
<meta name="full-screen" content="true"/>
<meta name="screen-orientation" content="portrait"/>
<meta name="x5-fullscreen" content="true"/>
<meta name="360-fullscreen" content="true"/>
<style>
html,
body {
padding: 0;
margin: 0;
border: 0;
width: 100%;
height: 100%;
overflow: hidden;
position: absolute;
background-color: gray;
}
.game-container{
width: 100%;
height: 100%;
line-height:0;
font-size:0;
}
</style>
</head>
<body>
<div id="game-container" class="game-container"></div>
<script crossorigin="anonymous" src="//yun.duiba.com.cn/editor/zeroing/libs/engine.1de84ff79dba19e949088de63aa75af51a515e5c.js"></script>
<script crossorigin="anonymous" src="//yun.duiba.com.cn/editor/zeroing/libs/svga.fd3923ae6e664251ca7981801a65809cc5f36bc3.js"></script>
<script src="//yun.duiba.com.cn/js-libs/p2.js/0.7.1/p2.min.js"></script>
<!-- <script src="//yun.duiba.com.cn/editor/zeroing/libs/engine.ebc906f6b50b8da0a669f77027981d5f3cb560ce.js"></script> -->
<!-- <script src="http://localhost:4002/debug/engine.js"></script>
<script src="http://localhost:4003/debug/engine-svga.js"></script> -->
<!--<script src="//yun.duiba.com.cn/editor/zeroing/libs/engine.9a9dbfda4cb2dd5508ecddfe3d95dfd88063f7b5.js"></script>-->
<script src="app.js"></script>
<script src="props.js"></script>
<script src="load-assets.js"></script>
<script src="main.js"></script>
<script>
</script>
</body>
\ No newline at end of file
/**
* Created by rockyl on 2020-01-21.
*/
const assets = [
{
"name": "玩家icon",
"url": "//yun.duiba.com.cn/aurora/assets/5b3e30496b2d9fdafb0cf3835fd6704ce10e45b4.png",
"uuid": "888",
"ext": ".png"
},
{
"name": "雨滴",
"url": "//yun.duiba.com.cn/aurora/assets/8564c8c9be3aead71b05a0bab8d7d07ac3f778a1.png",
"uuid": "264a6192-d7bf-45e8-8f15-6ba2c439a532",
"ext": ".png"
},
{
"name": "炸弹",
"url": "//yun.duiba.com.cn/aurora/assets/171e92283cd13c013ee1b76d28d252ff08815d47.png",
"uuid": "eb88b42d-e151-4c1b-94b9-7c16f7bfac29",
"ext": ".png"
},
{
"name": "石块",
"url": "//yun.duiba.com.cn/aurora/assets/99b0af0c59fe79a415a3f032149cfacc27e3ac2c.png",
"uuid": "ab1bdabc-21ba-46bf-9299-6c638f766c88",
"ext": ".png"
},
{
"name": "水花",
"url": "//yun.duiba.com.cn/aurora/assets/93d37b4a0e367e80e375308a6b4414d72d7666fc.svga",
"uuid": "b521bf94-20e1-44dd-8eca-d24996cbaeae",
"ext": ".svga"
},
{
"name": "炸弹",
"url": "//yun.duiba.com.cn/aurora/assets/4dd18f0689c663bbcf710a7afc4d929084d97d36.svga",
"uuid": "322edf39-805b-4e84-9d07-5573dfeebc0e",
"ext": ".svga"
},
{
"name": "玩家",
"url": "//yun.duiba.com.cn/aurora/assets/b66300c5d4f27134b0aac3dc90a3220e8ae572eb.svga",
"uuid": "71d8dcbc-3931-471a-b585-b3ae01b25aa6",
"ext": ".svga"
}
];
function loadAssets(customModuleAssets, onProgress, onComplete){
return engine.loadAssets(assets.concat(...customModuleAssets), onProgress, onComplete);
}
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('tslib')) :
typeof define === 'function' && define.amd ? define(['tslib'], factory) :
(global = global || self, global.p2demo = factory(global.tslib));
}(this, (function (tslib) { 'use strict';
function getTexture(uuid) {
return engine.Texture.from(getAssetByUUID(uuid).uuid);
}
function getTextureByName(name) {
return getTexture(engine.getAssetByName(name).uuid);
}
var OptionState;
(function (OptionState) {
OptionState[OptionState["CHOICE_RIGHT"] = 0] = "CHOICE_RIGHT";
OptionState[OptionState["CHOICE_WRONG"] = 1] = "CHOICE_WRONG";
OptionState[OptionState["CHOICE_SELECT"] = 2] = "CHOICE_SELECT";
})(OptionState || (OptionState = {}));
var GameState;
(function (GameState) {
GameState[GameState["STATE_START"] = 0] = "STATE_START";
GameState[GameState["STATE_END"] = 1] = "STATE_END";
})(GameState || (GameState = {}));
//# sourceMappingURL=utils.js.map
var GameView = (function (_super) {
tslib.__extends(GameView, _super);
function GameView() {
var _this = _super.call(this) || this;
_this.factor = 10;
_this.isDebug = 0;
_this.once(engine.Event.ADDED_TO_STAGE, _this.setup, _this);
return _this;
}
GameView.prototype.createBall = function (r) {
var shape = new engine.Shape();
shape.beginFill(0xfff000);
shape.drawCircle(0, 0, r);
shape.endFill();
return shape;
};
GameView.prototype.start = function () {
console.log('start');
this.stage.addEventListener(engine.MouseEvent.CLICK, this.onClick, this);
};
GameView.prototype.createBitmapByName = function (name) {
var imgContainer = new engine.Sprite();
var img = new engine.Sprite(getTextureByName(name));
img.anchorX = img.width / 2;
img.anchorY = img.height / 2;
img.x = -img.width / 2;
img.y = -img.height / 2;
imgContainer.addChild(img);
return imgContainer;
};
GameView.prototype.createBox = function (width, height) {
var shape = new engine.Shape();
shape.beginFill(0xfff000);
shape.drawRect(-width / 2, -height / 2, width, height);
shape.endFill();
return shape;
};
GameView.prototype.onClick = function (e) {
var _a = this, world = _a.world, factor = _a.factor;
var positionX = (e.stageX / factor);
var positionY = ((engine.gameStage.stage.height - e.stageY) / factor);
var display;
if (Math.random() > .5) {
var boxShape = new p2.Box({ width: 306 / factor, height: 172 / factor });
var boxBody = new p2.Body({ mass: 1, position: [positionX, positionY], angularVelocity: 1 });
boxBody.addShape(boxShape);
world.addBody(boxBody);
if (this.isDebug) {
display = this.createBox(boxShape.width * factor, boxShape.height * factor);
}
else {
display = this.createBitmapByName("block");
}
}
else {
var boxShape = new p2.Circle({ radius: 120 / 2 / factor });
var boxBody = new p2.Body({ mass: 1, position: [positionX, positionY] });
boxBody.addShape(boxShape);
world.addBody(boxBody);
if (this.isDebug) {
display = this.createBall(boxShape.radius * factor);
}
else {
display = this.createBitmapByName("ball");
}
}
boxBody.displays = [display];
this.addChild(display);
};
GameView.prototype.setup = function () {
console.log('setup');
var world = new p2.World({
gravity: [0, -10],
});
world.sleepMode = p2.World.BODY_SLEEPING;
var planeShape = new p2.Plane();
var planeBody = new p2.Body();
planeBody.addShape(planeShape);
planeBody.displays = [];
world.addBody(planeBody);
this.world = world;
this.stage.addEventListener(engine.Event.ENTER_FRAME, this.onEnterFrame, this);
};
GameView.prototype.onEnterFrame = function () {
var _a = this, world = _a.world, factor = _a.factor;
world.step(60 / 1000);
var stageHeight = engine.gameStage.stage.height;
var l = world.bodies.length;
for (var i = 0; i < l; i++) {
var boxBody = world.bodies[i];
var box = boxBody.displays[0];
if (box) {
box.x = boxBody.position[0] * factor;
box.y = stageHeight - boxBody.position[1] * factor;
box.rotation = 360 - (boxBody.angle + boxBody.shapes[0].angle) * 180 / Math.PI;
if (boxBody.sleepState == p2.Body.SLEEPING) {
box.alpha = 0.5;
}
else {
box.alpha = 1;
}
}
}
};
return GameView;
}(engine.Container));
var props = {};
function prepareProps() {
var metaProps = getProps();
engine.injectProp(props, metaProps);
}
function injectProps(p) {
engine.injectProp(props, p);
}
//# sourceMappingURL=props.js.map
var GameWrapper = (function (_super) {
tslib.__extends(GameWrapper, _super);
function GameWrapper() {
var _this = _super.call(this) || this;
engine.globalEvent.addEventListener('pictures-start', _this.start, _this);
engine.globalEvent.addEventListener('pictures-stop', _this.stop, _this);
var gameView = _this._gameView = new GameView();
_this.addChild(gameView);
return _this;
}
GameWrapper.prototype.start = function (event) {
injectProps(event.data);
this._gameView.start();
};
GameWrapper.prototype.stop = function (event) {
};
return GameWrapper;
}(engine.Container));
//# sourceMappingURL=GameWrapper.js.map
function index (props) {
prepareProps();
injectProps(props);
var instance = new GameWrapper();
return instance;
}
//# sourceMappingURL=index.js.map
return index;
})));
//# sourceMappingURL=main.js.map
\ No newline at end of file
{"version":3,"file":"index.js","sources":["src/custom/answer-game/src/game/utils.ts","src/custom/p2demo/src/game/GameView.ts","src/custom/p2demo/src/props.ts","src/custom/p2demo/src/game/GameWrapper.ts","src/custom/p2demo/src/index.ts"],"sourcesContent":["\n/**\n * Created by rockyl on 2020-01-21.\n */\n\nexport function getTexture(uuid) {\n\treturn engine.Texture.from(getAssetByUUID(uuid).uuid);\n}\n\nexport function getTextureByName(name) {\n\treturn getTexture(engine.getAssetByName(name).uuid);\n}\n\nexport function playSound(name) {\n\tengine.playSound(engine.getAssetByName(name).uuid, {keep: true});\n}\nexport function getStage(){\n\treturn engine.gameStage.stage;\n}\n\n\nexport enum OptionState{\n\tCHOICE_RIGHT,//选对\n\tCHOICE_WRONG,//选错\n\tCHOICE_SELECT,//选中\n}\n\nexport enum GameState{\n\tSTATE_START,//开始 选择中\n\tSTATE_END,//倒计时结束\n}","import { Tool } from \"../../../seabed-game/src/game/Tools\";\nimport { getTextureByName } from \"../../../answer-game/src/game/utils\";\n\nexport default class GameView extends engine.Container {\n world: p2.World;\n factor: number = 10;\n isDebug = 0;\n constructor() {\n super();\n this.once(engine.Event.ADDED_TO_STAGE, this.setup, this);\n }\n\n private createBall(r: number) {\n var shape = new engine.Shape();\n shape.beginFill(0xfff000);\n shape.drawCircle(0, 0, r);\n shape.endFill();\n return shape;\n }\n\n start() {\n console.log('start');\n this.stage.addEventListener(engine.MouseEvent.CLICK, this.onClick, this);\n }\n\n createBitmapByName(name) {\n const imgContainer = new engine.Sprite();\n const img = new engine.Sprite(getTextureByName(name));\n img.anchorX = img.width / 2;\n img.anchorY = img.height / 2;\n img.x = -img.width / 2;\n img.y = -img.height / 2;\n imgContainer.addChild(img);\n return imgContainer\n }\n\n private createBox(width: number, height: number): engine.Shape {\n var shape = new engine.Shape();\n shape.beginFill(0xfff000);\n shape.drawRect(-width / 2, -height / 2, width, height);\n shape.endFill();\n return shape;\n }\n\n onClick(e: engine.MouseEvent) {\n\n // const ball = this.createBitmapByName('ball');\n // this.addChild(ball);\n // engine.Tween.get(ball, { loop: true }).to({ rotation: 360 }, 1000);\n // return;\n\n // const box = this.createBitmapByName('block');\n // this.addChild(box);\n // engine.Tween.get(box, { loop: true }).to({ rotation: 360 }, 1000);\n // return;\n\n // const box = this.createBox(750, 100)\n // this.addChild(box);\n // box.x = 750/2;\n // box.y = 1624/2;\n // engine.Tween.get(box, { loop: true }).to({ rotation: 360 }, 1000)\n // return;\n\n // const ball = this.createBall(750/2);\n // this.addChild(ball);\n // ball.x = e.stageX;\n // ball.y = e.stageY;\n // return;\n const { world, factor } = this;\n var positionX: number = (e.stageX / factor);\n var positionY: number = ((engine.gameStage.stage.height - e.stageY) / factor);\n var display: engine.DisplayObject;\n\n if (Math.random() > .5) {\n //添加方形刚体\n var boxShape: p2.Shape = new p2.Box({ width: 306 / factor, height: 172 / factor });\n var boxBody: p2.Body = new p2.Body({ mass: 1, position: [positionX, positionY], angularVelocity: 1 });\n boxBody.addShape(boxShape);\n world.addBody(boxBody);\n\n if (this.isDebug) {\n display = this.createBox((<p2.Box>boxShape).width * factor, (<p2.Box>boxShape).height * factor);\n } else {\n display = this.createBitmapByName(\"block\");\n }\n }\n else {\n //添加圆形刚体\n var boxShape: p2.Shape = new p2.Circle({ radius: 120 / 2 / factor });\n var boxBody: p2.Body = new p2.Body({ mass: 1, position: [positionX, positionY] });\n boxBody.addShape(boxShape);\n world.addBody(boxBody);\n\n if (this.isDebug) {\n display = this.createBall((<p2.Circle>boxShape).radius * factor);\n } else {\n display = this.createBitmapByName(\"ball\");\n }\n\n // display.width = (<p2.Circle>boxShape).radius * 2 * factor;\n // display.height = (<p2.Circle>boxShape).radius * 2 * factor;\n\n }\n\n // display.anchorX = display.width / 2;\n // display.anchorY = display.height / 2;\n\n boxBody.displays = [display];\n\n this.addChild(display);\n\n }\n\n setup() {\n console.log('setup');\n\n //创建world\n var world: p2.World = new p2.World({\n gravity: [0, -10],\n });\n\n world.sleepMode = p2.World.BODY_SLEEPING;\n\n //创建plane\n var planeShape: p2.Plane = new p2.Plane();\n var planeBody: p2.Body = new p2.Body();\n planeBody.addShape(planeShape);\n planeBody.displays = [];\n world.addBody(planeBody);\n this.world = world;\n\n this.stage.addEventListener(engine.Event.ENTER_FRAME, this.onEnterFrame, this)\n }\n\n onEnterFrame() {\n const { world, factor } = this;\n world.step(60 / 1000);\n const stageHeight = engine.gameStage.stage.height;\n var l = world.bodies.length;\n\n for (var i: number = 0; i < l; i++) {\n var boxBody: p2.Body = world.bodies[i];\n var box = boxBody.displays[0];\n if (box) {\n box.x = boxBody.position[0] * factor;\n box.y = stageHeight - boxBody.position[1] * factor;\n\n box.rotation = 360 - (boxBody.angle + boxBody.shapes[0].angle) * 180 / Math.PI;\n if (boxBody.sleepState == p2.Body.SLEEPING) {\n box.alpha = 0.5;\n }\n else {\n box.alpha = 1;\n }\n }\n }\n\n }\n\n}\n","/**\n * Created by rockyl on 2020-01-21.\n */\n\nexport let props: any = {};\n\nexport function prepareProps() {\n\tlet metaProps = getProps();\n\n\tengine.injectProp(props, metaProps);\n}\n\nexport function injectProps(p) {\n\tengine.injectProp(props, p);\n}\n","/**\n * Created by rockyl on 2020-01-09.\n */\n\nimport GameView from \"./GameView\";\nimport { injectProps } from \"../props\";\n\n\nexport class GameWrapper extends engine.Container {\n\t// private _status;\n\tprivate _gameView: GameView;\n\n\n\n\n\n\tconstructor() {\n\t\tsuper();\n\n\t\tengine.globalEvent.addEventListener('pictures-start', this.start, this);\n\t\tengine.globalEvent.addEventListener('pictures-stop', this.stop, this);\n\n\t\t//创建实例\n\t\tlet gameView = this._gameView = new GameView();\n\t\tthis.addChild(gameView);\n\n\t}\n\n\tstart(event: engine.Event) {\n\t\tinjectProps(event.data);\n\n\t\t// this._status = 1;\n\n\t\tthis._gameView.start();\n\t}\n\tstop(event: engine.Event) {\n\t\t\n\t}\n}\n","/**\n * Created by rockyl on 2019-11-20.\n */\n\nimport {GameWrapper} from \"./game/GameWrapper\";\nimport {injectProps, prepareProps} from \"./props\";\n\nexport default function (props) {\n\tprepareProps();\n\tinjectProps(props);\n\n\tlet instance = new GameWrapper();\n\t\n\treturn instance;\n}\n"],"names":["__extends"],"mappings":";;;;;;UAKgB,UAAU,CAAC,IAAI;KAC9B,OAAO,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;CACvD,CAAC;UAEe,gBAAgB,CAAC,IAAI;KACpC,OAAO,UAAU,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;CACrD,CAAC;CAUD,IAAY,WAIX;CAJD,WAAY,WAAW;KACtB,6DAAY,CAAA;KACZ,6DAAY,CAAA;KACZ,+DAAa,CAAA;CACd,CAAC,EAJW,WAAW,KAAX,WAAW,QAItB;CAED,IAAY,SAGX;CAHD,WAAY,SAAS;KACpB,uDAAW,CAAA;KACX,mDAAS,CAAA;CACV,CAAC,EAHW,SAAS,KAAT,SAAS,QAGpB;;;CC3BD;KAAsCA,kCAAgB;KAIpD;SAAA,YACE,iBAAO,SAER;SALD,YAAM,GAAW,EAAE,CAAC;SACpB,aAAO,GAAG,CAAC,CAAC;SAGV,KAAI,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,cAAc,EAAE,KAAI,CAAC,KAAK,EAAE,KAAI,CAAC,CAAC;;MAC1D;KAEO,6BAAU,GAAlB,UAAmB,CAAS;SAC1B,IAAI,KAAK,GAAG,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;SAC/B,KAAK,CAAC,SAAS,CAA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AC,UAAU,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;CACrC,CAAC;AAED,UAAgB,WAAW,CAAC,CAAC;KAC5B,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;CAC7B,CAAC;;;CCND;KAAiCA,qCAAgB;KAQhD;SAAA,YACC,iBAAO,SASP;SAPA,MAAM,CAAC,WAAW,CAAC,gBAAgB,CAAC,gBAAgB,EAAE,KAAI,CAAC,KAAK,EAAE,KAAI,CAAC,CAAC;SACxE,MAAM,CAAC,WAAW,CAAC,gBAAgB,CAAC,eAAe,EAAE,KAAI,CAAC,IAAI,EAAE,KAAI,CAAC,CAAC;SAGtE,IAAI,QAAQ,GAAG,KAAI,CAAC,SAAS,GAAG,IAAI,QAAQ,EAAE,CAAC;SAC/C,KAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;;MAExB;KAED,2BAAK,GAAL,UAAM,KAAmB;SACxB,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;SAIxB,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;MACvB;KACD,0BAAI,GAAJ,UAAK,KAAmB;MAEvB;KACF,kBAAC;CAAD,CAAC,CA9BgC,MAAM,CAAC,SAAS,GA8BhD;;;iBC/BwB,KAAK;KAC7B,YAAY,EAAE,CAAC;KACf,WAAW,CAAC,KAAK,CAAC,CAAC;KAEnB,IAAI,QAAQ,GAAG,IAAI,WAAW,EAAE,CAAC;KAEjC,OAAO,QAAQ,CAAC;CACjB,CAAC;;;;;;;;;"}
\ No newline at end of file
/**
* Created by rockyl on 2020-01-21.
*/
let customModuleProps = {
};
{
"name": "拼图",
"desc": "拼图模块1.0",
"props": {
"MAX_COL": {
"alias": "图片分成几列",
"type": "number",
"default": 3
},
"MAX_ROW": {
"alias": "图片分成几行",
"type": "number",
"default": 4
},
"W": {
"alias": "图片的宽度",
"type": "number",
"default": 618
},
"H": {
"alias": "图片的高度",
"type": "number",
"default": 827
},
"OFFSET_X": {
"alias": "OFFSET_X",
"type": "number",
"default": 0
},
"OFFSET_Y": {
"alias": "OFFSET_Y",
"type": "number",
"default": 0
},
"GAP": {
"alias": "图片间隙",
"type": "number",
"default": 0
},
"GAME_TIME": {
"alias": "游戏时间",
"type": "number",
"default": 10
}
},
"assets": [
{
"name": "block",
"url": "//yun.duiba.com.cn/aurora/assets/f91184b338ef9540b167eebe7d58e71402e8d9d9.png",
"uuid": "888",
"ext": ".png"
},
{
"name": "ball",
"url": "//yun.duiba.com.cn/aurora/assets/3dc11f2d91659b7e7e1d06a9853cbc9f818e1ea2.png",
"uuid": "999",
"ext": ".png"
}
],
"events": {
"in": {
"pictures-start": {
"alias": "开始",
"data": {
"picUrl":"图片路径",
"blockUrl":"blockUrl",
"row":"行",
"column":"列",
"gameTime":"游戏时间"
}
},
"pictures-stop": {
"alias": "停止"
}
},
"out": {
"pictures-time-update": {
"alias": "倒计时更新",
"data": {
"time":"剩余时间"
}
},
"pictures-game-fail": {
"alias": "游戏结束",
"data": {
"reason": "结束原因(1:时间到了)"
}
},
"pictures-game-success": {
"alias": "游戏成功",
"data": {
"time": "游戏消耗时间"
}
}
}
}
}
\ No newline at end of file
import { Tool } from "../../../seabed-game/src/game/Tools";
import { getTextureByName } from "../../../answer-game/src/game/utils";
export default class GameView extends engine.Container {
world: p2.World;
factor: number = 10;
isDebug = 0;
constructor() {
super();
this.once(engine.Event.ADDED_TO_STAGE, this.setup, this);
}
private createBall(r: number) {
var shape = new engine.Shape();
shape.beginFill(0xfff000);
shape.drawCircle(0, 0, r);
shape.endFill();
return shape;
}
start() {
console.log('start');
this.stage.addEventListener(engine.MouseEvent.CLICK, this.onClick, this);
}
createBitmapByName(name) {
const imgContainer = new engine.Sprite();
const img = new engine.Sprite(getTextureByName(name));
img.anchorX = img.width / 2;
img.anchorY = img.height / 2;
img.x = -img.width / 2;
img.y = -img.height / 2;
imgContainer.addChild(img);
return imgContainer
}
private createBox(width: number, height: number): engine.Shape {
var shape = new engine.Shape();
shape.beginFill(0xfff000);
shape.drawRect(-width / 2, -height / 2, width, height);
shape.endFill();
return shape;
}
onClick(e: engine.MouseEvent) {
// const ball = this.createBitmapByName('ball');
// this.addChild(ball);
// engine.Tween.get(ball, { loop: true }).to({ rotation: 360 }, 1000);
// return;
// const box = this.createBitmapByName('block');
// this.addChild(box);
// engine.Tween.get(box, { loop: true }).to({ rotation: 360 }, 1000);
// return;
// const box = this.createBox(750, 100)
// this.addChild(box);
// box.x = 750/2;
// box.y = 1624/2;
// engine.Tween.get(box, { loop: true }).to({ rotation: 360 }, 1000)
// return;
// const ball = this.createBall(750/2);
// this.addChild(ball);
// ball.x = e.stageX;
// ball.y = e.stageY;
// return;
const { world, factor } = this;
var positionX: number = (e.stageX / factor);
var positionY: number = ((engine.gameStage.stage.height - e.stageY) / factor);
var display: engine.DisplayObject;
if (Math.random() > .5) {
//添加方形刚体
var boxShape: p2.Shape = new p2.Box({ width: 306 / factor, height: 172 / factor });
var boxBody: p2.Body = new p2.Body({ mass: 1, position: [positionX, positionY], angularVelocity: 1 });
boxBody.addShape(boxShape);
world.addBody(boxBody);
if (this.isDebug) {
display = this.createBox((<p2.Box>boxShape).width * factor, (<p2.Box>boxShape).height * factor);
} else {
display = this.createBitmapByName("block");
}
}
else {
//添加圆形刚体
var boxShape: p2.Shape = new p2.Circle({ radius: 120 / 2 / factor });
var boxBody: p2.Body = new p2.Body({ mass: 1, position: [positionX, positionY] });
boxBody.addShape(boxShape);
world.addBody(boxBody);
if (this.isDebug) {
display = this.createBall((<p2.Circle>boxShape).radius * factor);
} else {
display = this.createBitmapByName("ball");
}
// display.width = (<p2.Circle>boxShape).radius * 2 * factor;
// display.height = (<p2.Circle>boxShape).radius * 2 * factor;
}
// display.anchorX = display.width / 2;
// display.anchorY = display.height / 2;
boxBody.displays = [display];
this.addChild(display);
}
setup() {
console.log('setup');
//创建world
var world: p2.World = new p2.World({
gravity: [0, -10],
});
world.sleepMode = p2.World.BODY_SLEEPING;
//创建plane
var planeShape: p2.Plane = new p2.Plane();
var planeBody: p2.Body = new p2.Body();
planeBody.addShape(planeShape);
planeBody.displays = [];
world.addBody(planeBody);
this.world = world;
this.stage.addEventListener(engine.Event.ENTER_FRAME, this.onEnterFrame, this)
}
onEnterFrame() {
const { world, factor } = this;
world.step(60 / 1000);
const stageHeight = engine.gameStage.stage.height;
var l = world.bodies.length;
for (var i: number = 0; i < l; i++) {
var boxBody: p2.Body = world.bodies[i];
var box = boxBody.displays[0];
if (box) {
box.x = boxBody.position[0] * factor;
box.y = stageHeight - boxBody.position[1] * factor;
box.rotation = 360 - (boxBody.angle + boxBody.shapes[0].angle) * 180 / Math.PI;
if (boxBody.sleepState == p2.Body.SLEEPING) {
box.alpha = 0.5;
}
else {
box.alpha = 1;
}
}
}
}
}
/**
* Created by rockyl on 2020-01-09.
*/
import GameView from "./GameView";
import { injectProps } from "../props";
export class GameWrapper extends engine.Container {
// private _status;
private _gameView: GameView;
constructor() {
super();
engine.globalEvent.addEventListener('pictures-start', this.start, this);
engine.globalEvent.addEventListener('pictures-stop', this.stop, this);
//创建实例
let gameView = this._gameView = new GameView();
this.addChild(gameView);
}
start(event: engine.Event) {
injectProps(event.data);
// this._status = 1;
this._gameView.start();
}
stop(event: engine.Event) {
}
}
/**
* Created by rockyl on 2020-02-03.
*/
import {Goods} from "./Goods";
import ObjectPool = engine.ObjectPool;
export const PoolName: string = 'goods';
ObjectPool.registerPool(PoolName, function () {
return new Goods();
}, function (item: Goods, data) {
item.reset();
});
import { props } from "../props";
const urls = [];
const picMap = {};
const posMap = {};
export default (parent, url, MAX_COL, MAX_ROW) => {
if (picMap[url]) {
const pics:any[] = picMap[url];
for (const pic of pics) {
parent.addChild(pic);
}
return [picMap[url], posMap[url]]
}
const W = props.W;
const H = props.H;
const GAP = props.GAP;
const spr = [];
const pos = []
for (let row = 0; row < MAX_ROW; row++) {
for (let col = 0; col < MAX_COL; col++) {
const child = engine.Sprite.fromImage(url);
spr.push(child);
child.scaleX = 1 / MAX_COL;
child.scaleY = 1 / MAX_ROW;
parent.addChild(child);
child.x = col * (W / MAX_COL + GAP);
child.y = row * (H / MAX_ROW + GAP);
pos.push([child.x, child.y]);
// child.texture.addEventListener('update', () => {
child.addEventListener(engine.Event.COMPLETE, () => {
const uvs = new Float32Array([
col / MAX_COL,
row / MAX_ROW,
(col + 1) / MAX_COL,
row / MAX_ROW,
(col + 1) / MAX_COL,
(row + 1) / MAX_ROW,
col / MAX_COL,
(row + 1) / MAX_ROW,
]);
child.uvs = uvs;
// spr.push(child);
});
}
}
picMap[url] = spr.concat([]);
posMap[url] = pos.concat([]);;
// console.log(spr);
return [spr, pos];
};
/**
* Created by rockyl on 2020-01-21.
*/
export function getTexture(uuid) {
return engine.Texture.from(getAssetByUUID(uuid).uuid);
}
export function getTextureByName(name) {
return getTexture(engine.getAssetByName(name).uuid);
}
export function playSound(name) {
engine.playSound(engine.getAssetByName(name).uuid, {keep: true});
}
export function createSvga(name, anchorName?) {
let inst = new svga.Svga();
inst.source = 'asset://' + engine.getAssetByName(name).uuid;
return inst;
}
export function getIndexFromRC(row,col,maxCol){
let index;
index = row * maxCol + col ;
return index
}
export function getRandomArray(array){
array.sort(function() {
return .5 - Math.random();
});
}
\ No newline at end of file
/**
* Created by rockyl on 2019-11-20.
*/
import {GameWrapper} from "./game/GameWrapper";
import {injectProps, prepareProps} from "./props";
export default function (props) {
prepareProps();
injectProps(props);
let instance = new GameWrapper();
return instance;
}
/**
* Created by rockyl on 2020-01-21.
*/
export let props: any = {};
export function prepareProps() {
let metaProps = getProps();
engine.injectProp(props, metaProps);
}
export function injectProps(p) {
engine.injectProp(props, p);
}
{"version":3,"file":"index.js","sources":["src/custom/pick-tea/src/props.ts","src/custom/pick-tea/src/game/utils.ts","src/custom/pick-tea/src/game/GameView.ts","src/custom/pick-tea/src/game/GameWrapper.ts","src/custom/pick-tea/src/index.ts"],"sourcesContent":["/**\r\n * Created by rockyl on 2020-01-21.\r\n */\r\n\r\nexport let props: any = {};\r\n\r\nexport function prepareProps() {\r\n\tlet metaProps = getProps();\r\n\r\n\tengine.injectProp(props, metaProps);\r\n}\r\n\r\nexport function injectProps(p) {\r\n\tengine.injectProp(props, p);\r\n}\r\n","/**\r\n * Created by rockyl on 2020-01-21.\r\n */\r\nconst showlog = false;\r\nexport function getTexture(uuid) {\r\n\treturn engine.Texture.from(getAssetByUUID(uuid).uuid);\r\n}\r\n\r\nexport function getTextureByName(name) {\r\n\treturn getTexture(engine.getAssetByName(name).uuid);\r\n}\r\n\r\nexport function playSound(name) {\r\n\t//console.log('playSound', name)\r\n\tengine.playSound(engine.getAssetByName(name).uuid, { keep: true });\r\n}\r\nexport function createSvga(name, anchorName?) {\r\n\tlet inst = new svga.Svga();\r\n\tinst.source = 'asset://' + engine.getAssetByName(name).uuid;\r\n\treturn inst;\r\n}\r\nexport function showLog(abjname, obj?) {\r\n\tif (showlog) {\r\n\t\tconsole.log(abjname)\r\n\t\tif (obj)\r\n\t\t\tconsole.log(obj)\r\n\t}\r\n\t// let inst = new svga.Svga();\r\n\t// inst.source = 'asset://' + engine.getAssetByName(name).uuid;\r\n\t// return inst;\r\n}","/**\r\n * Created by rockyl on 2018/8/16.\r\n */\r\n\r\nimport { props } from \"../props\";\r\nimport { playSound, createSvga } from \"./utils\";\r\nimport ObjectPool = engine.ObjectPool;\r\nimport { getTextureByName } from \"./utils\";\r\nimport { showLog } from \"./utils\";\r\nimport { Tealeaf } from \"./Tealeaf\";\r\n\r\n\r\nconst MAXX = -8;\r\nexport default class GameView extends engine.Container {\r\n\r\n\tprivate _hasSetup;\r\n\r\n\t/**采茶叶自定义模块*/\r\n\tprivate teaImgSource: any;\r\n\tprivate tealeaf: Tealeaf;\r\n\tprivate teaHalfImg: engine.Image;\r\n\tprivate nowPercentage: any = 0;\r\n\tprivate progressbarBgImg: engine.Image;\r\n\tprivate progressbarImg: engine.Image;\r\n\tprivate teaFullFlagImg: engine.Image;\r\n\tprivate teaHalfFlagImg: engine.Image;\r\n\tprivate teaStarImg: engine.Image;\r\n\tprivate frontImg: engine.Image;\r\n\tprivate verseImg: engine.Image;\r\n\tprivate handGraspBgImg: engine.Image;\r\n\t//采茶背景层\r\n\tprivate pickTeaBg: engine.Container;\r\n\t//采茶进度计时器\r\n\tprivate pickTeaTimer: any\r\n\t//茶叶的数量进度 100/240\r\n\tprivate pickTeaCount: engine.Label;\r\n\t//语句\r\n\tprivate verseLabel: engine.TextField;\r\n\t//篮子集合\r\n\tprivate basketSvgaGroup: any;\r\n\r\n\tprivate basketLevel: any;\r\n\t//纸篮子svga\r\n\tprivate paperBasketSvga\r\n\t//布篮子svga\r\n\tprivate clothBasketSvga\r\n\t//竹篮子svga\r\n\tprivate bambooBasketSvga\r\n\t//木篮子svga\r\n\tprivate woodBasketSvga\r\n\t//+1\r\n\tprivate addOneSvga\r\n\t//采茶叶\r\n\tprivate pickTeaSvga\r\n\t//茶叶向上飞\r\n\tprivate teaSkyUpSvga\r\n\t//手抓去\r\n\tprivate handGraspSvga\r\n\t//半缺旋转\r\n\tprivate teaFullRotation\r\n\r\n\tprivate allFrames;\r\n\t/**采茶叶自定义模块*/\r\n\r\n\t//玩家\r\n\tprivate player: engine.Container;\r\n\r\n\t//触摸层\r\n\tprivate rectBg: engine.Rect;\r\n\t//npc层\r\n\t//private NpcBg: engine.Container;\r\n\r\n\t//当前分数\r\n\tprivate score\r\n\t//游戏状态\r\n\tprivate gameIng;\r\n\t//npc出身计时器\r\n\tprivate timer\r\n\t//倒计时计时器\r\n\tprivate countdownTimer: any\r\n\t//倒计时\r\n\tprivate countdown: number\r\n\t//当前速度\r\n\tprivate speed: number\r\n\r\n\tprivate schedule: any\r\n\t// 当前场景上面的物品\r\n\tprivate goodsItems = []\r\n\r\n\r\n\tconstructor() {\r\n\t\tsuper();\r\n\t\tthis.once(engine.Event.ADDED_TO_STAGE, this.setup, this);\r\n\t}\r\n\r\n\tprivate waterSvga\r\n\tprivate boomSvga\r\n\tprivate playerSvga\r\n\tprivate _touchEnabled = true\r\n\tsetup() {\r\n\t\tif (this._hasSetup) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tthis._hasSetup = true;\r\n\t\tthis.pickTeaBg = new engine.Container();\r\n\t\tthis.basketLevel = null;\r\n\t\t// let bgGroud = new engine.Image()\r\n\t\t// bgGroud.source = '//yun.duiba.com.cn/aurora/assets/a988c47db8d3131faad175c7c2944773392be643.png'\r\n\t\t// this.addChild(bgGroud);\r\n\r\n\t\tthis.addChild(this.pickTeaBg);\r\n\t\tthis.teaHalfImg = new engine.Image();\r\n\r\n\t\tthis.paperBasketSvga = createSvga(\"采茶童-纸篮子\");\r\n\t\tthis.clothBasketSvga = createSvga(\"采茶童-布篮子\");\r\n\t\tthis.bambooBasketSvga = createSvga(\"采茶童-竹编篮\");\r\n\t\tthis.woodBasketSvga = createSvga(\"采茶童-木篮子\");\r\n\t\tthis.addOneSvga = createSvga(\"+1\");\r\n\t\tthis.pickTeaSvga = createSvga(\"采茶叶\");\r\n\r\n\t\tthis.teaSkyUpSvga = createSvga(\"茶叶向上飞\");\r\n\t\tthis.handGraspSvga = createSvga(\"手抓去\");\r\n\r\n\t\tthis.frontImg = new engine.Image(getTextureByName('前景'));\r\n\r\n\t\tthis.pickTeaBg.addChild(this.paperBasketSvga);\r\n\t\tthis.pickTeaBg.addChild(this.clothBasketSvga);\r\n\t\tthis.pickTeaBg.addChild(this.bambooBasketSvga);\r\n\t\tthis.pickTeaBg.addChild(this.woodBasketSvga);\r\n\t\t//this.pickTeaBg.addChild(this.addOneSvga);\r\n\t\tthis.pickTeaBg.addChild(this.pickTeaSvga);\r\n\t\tthis.pickTeaBg.addChild(this.teaSkyUpSvga);\r\n\t\t//this.pickTeaBg.addChild(this.handGraspSvga);\r\n\t\tthis.basketSvgaGroup = [this.paperBasketSvga, this.clothBasketSvga, this.bambooBasketSvga, this.woodBasketSvga]\r\n\r\n\t\tthis.progressbarBgImg = new engine.Image(getTextureByName('进度条底框'));\r\n\t\tthis.progressbarImg = new engine.Image(getTextureByName('进度'));\r\n\t\tthis.teaHalfFlagImg = new engine.Image(getTextureByName('茶叶进度缺'));\r\n\t\tthis.teaFullFlagImg = new engine.Image(getTextureByName('茶叶进度满'));\r\n\t\tthis.teaStarImg = new engine.Image(getTextureByName('小茶叶'));\r\n\r\n\t\tthis.handGraspBgImg = new engine.Image(getTextureByName('茶叶收取底图'));\r\n\t\tthis.verseImg = new engine.Image(getTextureByName('气泡框'));\r\n\t\tthis.pickTeaBg.addChild(this.verseImg);\r\n\r\n\r\n\t\tlet mask = new engine.Rect();\r\n\t\tmask.width = 600;\r\n\t\tmask.height = 50;\r\n\t\tmask.x = 10;\r\n\t\tmask.y = 0;\r\n\t\tmask.alpha = 1;\r\n\r\n\t\tthis.progressbarImg.mask = mask\r\n\t\tshowLog(this.progressbarImg.mask)\r\n\r\n\t\tthis.addChild(this.frontImg);\r\n\r\n\t\tthis.progressbarBgImg.addChild(this.progressbarImg);\r\n\r\n\t\tthis.progressbarBgImg.addChild(mask);\r\n\t\tshowLog('遮罩坐标')\r\n\t\tshowLog(mask.x, mask.y)\r\n\t\tthis.progressbarBgImg.addChild(this.addOneSvga);\r\n\r\n\t\tthis.progressbarBgImg.addChild(this.handGraspBgImg);\r\n\r\n\t\tthis.handGraspBgImg.addChild(this.handGraspSvga);\r\n\r\n\t\tthis.progressbarBgImg.addChild(this.teaHalfFlagImg);\r\n\t\tthis.progressbarBgImg.addChild(this.teaFullFlagImg);\r\n\t\tthis.progressbarBgImg.addChild(this.teaStarImg);\r\n\t\tthis.pickTeaCount = new engine.Label();\r\n\t\tthis.progressbarBgImg.addChild(this.pickTeaCount);\r\n\r\n\t\tthis.addChild(this.progressbarBgImg);\r\n\t\tthis.initView();\r\n\r\n\t\t// setTimeout(() => {\r\n\t\t// \tthis.setPickTeaLevel(1)\r\n\t\t// \tthis.setTeaNum({ totalNum: 150, nowNum: 60, serverData: 1585290768011 })\r\n\t\t// \t//this.setTeaNum({ totalNum: 100, nowNum: 0 })\r\n\t\t// }, 500)\r\n\t\t// setTimeout(() => {\r\n\t\t// \tthis.handGrasp();\r\n\r\n\t\t// \tthis.setTeaNum({ totalNum: 10, nowNum: 0, serverData: 1585290768011 })\r\n\r\n\t\t// }, 12000)\r\n\t\t//playSound('采茶叶');\r\n\r\n\t}\r\n\treset() {\r\n\t\tthis.initView()\r\n\t}\r\n\tstart() {\r\n\r\n\t}\r\n\tpause() {\r\n\t\tthis.gameIng = false;\r\n\t}\r\n\trevive() {\r\n\t\tthis.gameIng = true;\r\n\t}\r\n\r\n\tresume() {\r\n\t\tthis.reset();\r\n\t\tthis.start()\r\n\t}\r\n\r\n\tinitView() {\r\n\t\tthis.pickTeaBg.mouseEnabled = false;\r\n\t\tthis.teaHalfImg.visible = false;\r\n\t\t//this.teaHalfImg.source = '';\r\n\t\tthis.pickTeaSvga.visible = false;\r\n\t\tthis.teaSkyUpSvga.visible = false;\r\n\t\tthis.verseImg.visible = false;\r\n\t\tthis.frontImg.visible = props.showFrontImg == 1;\r\n\t\tthis.initChildrenPos()\r\n\t}\r\n\tinitChildrenPos() {\r\n\t\tfor (let i = 0; i < this.basketSvgaGroup.length; i++) {\r\n\t\t\tthis.basketSvgaGroup[i].visible = false\r\n\t\t\tthis.basketSvgaGroup[i].x = props.basketSvgaPos[0];\r\n\t\t\tthis.basketSvgaGroup[i].y = props.basketSvgaPos[1];;\r\n\t\t\t//this.basketSvgaGroup[i].addEventListener(engine.MouseEvent.CLICK, this.showVerse, this);\r\n\t\t}\r\n\t\tlet pickTeaSVGA = this.basketSvgaGroup[0];\r\n\r\n\t\t//console.log('总共有多少',pickTeaSVGA.children.length)\r\n\t\tthis.allFrames = pickTeaSVGA.children.length;\r\n\r\n\t\tthis.verseImg.x = props.versePos[0]\r\n\t\tthis.verseImg.y = props.versePos[1]\r\n\t\tthis.addOneSvga.x = props.addOneSvgaPos[0]\r\n\t\tthis.addOneSvga.y = props.addOneSvgaPos[1];\r\n\t\tthis.pickTeaSvga.x = props.pickTeaSvgaPos[0];\r\n\t\tthis.pickTeaSvga.y = props.pickTeaSvgaPos[1];\r\n\r\n\t\tthis.teaSkyUpSvga.x = props.teaSkyUpSvgaPos[0];\r\n\t\tthis.teaSkyUpSvga.y = props.teaSkyUpSvgaPos[1];\r\n\r\n\t\tthis.handGraspSvga.x = props.handGraspSvgaPos[0];\r\n\t\tthis.handGraspSvga.y = props.handGraspSvgaPos[1];\r\n\r\n\t\tthis.handGraspBgImg.x = props.handGraspBgImgPos[0];\r\n\t\tthis.handGraspBgImg.y = props.handGraspBgImgPos[1];\r\n\r\n\t\tthis.progressbarBgImg.x = props.progressbarBgImgPos[0]\r\n\r\n\t\tthis.progressbarBgImg.y = props.progressbarBgImgPos[1]\r\n\r\n\t\tthis.progressbarImg.x = props.progressbarImgPos[0]\r\n\t\tthis.progressbarImg.y = props.progressbarImgPos[1]\r\n\r\n\t\tthis.teaHalfFlagImg.x = props.teaHalfFlagImgPos[0]\r\n\t\tthis.teaHalfFlagImg.y = props.teaHalfFlagImgPos[1]\r\n\t\tthis.teaHalfFlagImg.anchorX = this.teaHalfFlagImg.width / 2\r\n\t\tthis.teaHalfFlagImg.anchorY = this.teaHalfFlagImg.height / 2\r\n\r\n\t\tthis.teaFullFlagImg.x = props.teaHalfFlagImgPos[0]\r\n\t\tthis.teaFullFlagImg.y = props.teaHalfFlagImgPos[1]\r\n\r\n\t\tthis.frontImg.x = props.FrontImgPos[0]\r\n\t\tthis.frontImg.y = props.FrontImgPos[1]\r\n\r\n\t\tthis.teaFullFlagImg.visible = false;\r\n\r\n\t\tthis.teaStarImg.x = props.teaStarImgPos[0]\r\n\t\tthis.teaStarImg.y = props.teaStarImgPos[1]\r\n\r\n\t\tthis.pickTeaCount.fillColor = 'white';\r\n\t\tthis.pickTeaCount.size = 30;\r\n\t\tthis.pickTeaCount.text = ''\r\n\r\n\t\tthis.pickTeaCount.x = props.pickTeaCountPos[0]\r\n\t\tthis.pickTeaCount.y = props.pickTeaCountPos[1]\r\n\r\n\t\tthis.pickTeaCount.height = 50;\r\n\t\tthis.pickTeaCount.width = 200;\r\n\r\n\t\tthis.verseLabel = new engine.TextField();\r\n\t\tthis.verseLabel.size = props.verseLabel[2];\r\n\t\tthis.verseLabel.text = ''\r\n\t\tthis.verseLabel.fillColor = props.verseColor[0]\r\n\t\tthis.verseLabel.height = props.verseLabel[1];\r\n\t\tthis.verseLabel.width = props.verseLabel[0];\r\n\t\tthis.verseLabel.strokeColor = props.verseColor[1]\r\n\t\tthis.verseLabel.stroke = 0.5;\r\n\r\n\t\tthis.verseLabel.y = 15;\r\n\t\tthis.verseLabel['textHeight'] = 14;\r\n\t\tthis.verseLabel.textAlign = engine.TEXT_ALIGN.CENTER;\r\n\t\tthis.verseImg.visible = false;\r\n\t\tthis.verseImg.addChild(this.verseLabel);\r\n\r\n\t\t// label.x = (width - label.width) / 2;\r\n\t\t// label.y = guideHole.y + guideHole.height + 50;\r\n\t}\r\n\tshowVerse() {\r\n\t\tshowLog('显示诗句')\r\n\t\t// if (!this._touchEnabled) {\r\n\t\t// \treturn;\r\n\t\t// }\r\n\t\t//this._touchEnabled = false;\r\n\t\tthis.verseImg.visible = true;\r\n\t\tlet len = props.verses.length;\r\n\t\tlet random = Math.floor(Math.random() * len);\r\n\t\tshowLog('random', random)\r\n\t\tshowLog('props.verses')\r\n\t\tshowLog(props.verses)\r\n\t\tlet verse = props.verses[random];\r\n\t\tshowLog('verse', verse)\r\n\t\tthis.verseLabel.text = verse;\r\n\t\tlet y = this.verseImg.y\r\n\t\tengine.Tween.get(this.verseImg)\r\n\t\t\t.to({ alpha: 0 }, 3000).call(() => {\r\n\t\t\t\tthis.verseImg.visible = false;\r\n\t\t\t\tthis.verseImg.alpha = 1\r\n\t\t\t})\r\n\t};\r\n\t/*采茶叶活动*/\r\n\t//总量除以当前 小于3分之1 没有树叶 ,3分之1到3分之2一点点树叶 ,大于3分之2满树叶\r\n\tsetTeaNum(TeaNums) {\r\n\t\tif (this.schedule) {\r\n\t\t\tshowLog('清理定时器,重新设置同步')\r\n\t\t\tclearInterval(this.schedule);\r\n\t\t}\r\n\t\tlet totalNum = TeaNums.totalNum;\r\n\t\tlet nowNum = TeaNums.nowNum\r\n\t\tshowLog('nowNum:', nowNum)\r\n\t\tthis.getTeaPercentage(nowNum, totalNum);\r\n\t\tlet surplus = nowNum - totalNum;\r\n\t\tif (surplus == 0) {\r\n\t\t\tthis.gotoMaxLength();\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tshowLog('surplus', surplus);\r\n\t\tlet width = this.progressbarImg.width;\r\n\t\tlet myDate = new Date();\r\n\t\tlet nowData = myDate.getTime();\r\n\t\tlet serverData = TeaNums.serverData;\r\n\t\t//前后端本身的差值\r\n\t\tlet fbdvalue = Math.abs((nowData - serverData))\r\n\t\tshowLog('fbdvalue', fbdvalue)\r\n\t\t/**/\r\n\t\t//设置数据校正\r\n\t\t// let serverData = 0;\r\n\t\tlet dataDiff = 0;\r\n\t\t/**/\r\n\t\t//let rate = (443 - width * (1 - nowNum / totalNum))\r\n\t\t//已经走得\r\n\t\tlet x = -width * (1 - (nowNum / totalNum))\r\n\r\n\t\tshowLog('原先的X:', this.progressbarImg.x)\r\n\t\tshowLog('比例后的X', x);\r\n\t\t//showLog('parseFloat(x.toFixed(3))', parseFloat(x.toFixed(5)))\r\n\r\n\t\tthis.progressbarImg.x = parseFloat(x.toFixed(5)) + this.teaFullFlagImg.width - Math.abs(this.teaFullFlagImg.x)\r\n\t\tshowLog('减去长款的x', this.progressbarImg.x)\r\n\t\tshowLog('this.teaFullFlagImg.width', this.teaFullFlagImg.width)\r\n\r\n\t\tif (this.progressbarImg.x > (this.teaFullFlagImg.width / 2)) {\r\n\t\t\tlet minus = this.teaFullFlagImg.width - Math.abs(this.teaFullFlagImg.x) - this.progressbarImg.x\r\n\t\t\tshowLog('minus', minus)\r\n\t\t\tthis.progressbarImg.x = this.progressbarImg.x - this.teaFullFlagImg.width / 2 + Math.abs(this.teaFullFlagImg.x)\r\n\t\t\tshowLog('负段x重组', this.progressbarImg.x)\r\n\t\t}\r\n\r\n\t\tshowLog('补宽的X', this.progressbarImg.x);\r\n\t\tshowLog('this.progressbarImg.x', this.progressbarImg.x)\r\n\t\tlet step = (this.teaFullFlagImg.width / 2 - this.progressbarImg.x) / surplus\r\n\t\tshowLog('step', step)\r\n\t\t//step = parseFloat(step.toFixed(6));\r\n\t\t//showLog('进图条每秒比例step', step)\r\n\t\tlet speed = props.pickTeaSpeed;\r\n\t\tif (!this.teaFullRotation) {\r\n\t\t\tthis.teaFullRotation = engine.Tween.get(this.teaHalfFlagImg, { loop: true })\r\n\t\t\t\t.to({ rotation: 360 }, speed).call(() => {\r\n\t\t\t\t\tthis.teaHalfFlagImg.rotation = 0;\r\n\t\t\t\t})\r\n\t\t}\r\n\t\tthis.teaHalfFlagImg.visible = true;\r\n\t\tthis.teaFullFlagImg.visible = !this.teaHalfFlagImg.visible\r\n\t\tthis.addOneSvga.visible = this.teaHalfFlagImg.visible\r\n\r\n\t\tengine.Tween.resumeTweens(this.teaFullRotation);\r\n\t\tthis.schedule = setInterval(() => {\r\n\t\t\t//showLog('nowNum', nowNum, 'totalNum', totalNum)\r\n\t\t\tnowNum++;\r\n\t\t\tthis.addOneSvga.play(1, true);\r\n\t\t\tif (nowNum == totalNum) {\r\n\t\t\t\tthis.gotoMaxLength();\r\n\t\t\t\tthis.getTeaPercentage(nowNum, totalNum);\r\n\t\t\t\tengine.Tween.pauseTweens(this.teaFullRotation);\r\n\t\t\t\t//this.setTeaNum({ totalNum: 100, nowNum: 0, serverData: 1585290768011 });\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\t\t\tif (this.progressbarImg.x < this.teaFullFlagImg.width / 2) {\r\n\t\t\t\tthis.progressbarImg.x -= step;\r\n\t\t\t}\r\n\t\t\tthis.getTeaPercentage(nowNum, totalNum);\r\n\t\t\tdataDiff += speed;\r\n\t\t\tmyDate = new Date();\r\n\t\t\tnowData = myDate.getTime();\r\n\t\t\tif (Math.abs((nowData - serverData)) - dataDiff > (fbdvalue + 3000)) {\r\n\t\t\t\tshowLog('校准数据前后数据偏差过大');\r\n\t\t\t\tshowLog(Math.abs((nowData - serverData)) - dataDiff - (fbdvalue + 3000))\r\n\t\t\t\tshowLog(this.schedule)\r\n\t\t\t\tclearInterval(this.schedule);\r\n\t\t\t\tengine.Tween.pauseTweens(this.teaFullRotation);\r\n\t\t\t\tengine.globalEvent.dispatchEvent('event-setchange-TeaNum');\r\n\t\t\t\tthis.addOneSvga.visible = false;\r\n\t\t\t\tthis.addOneSvga.stop();\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\t\t}, speed)\r\n\t}\r\n\tgetTeaPercentage(nowNum, totalNum) {\r\n\t\tif (nowNum > totalNum) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tthis.pickTeaCount.text = nowNum + '/' + totalNum;\r\n\t\tlet teaPercentage = 2;\r\n\t\tlet portion = totalNum / 3\r\n\t\tif (nowNum < portion) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tif (nowNum < (portion * 2)) {\r\n\t\t\tteaPercentage = 1;\r\n\t\t}\r\n\t\tshowLog('teaPercentage', teaPercentage)\r\n\t\tif (this.nowPercentage != teaPercentage) {\r\n\t\t\tshowLog('状态改变')\r\n\t\t\tthis.nowPercentage = teaPercentage;\r\n\t\t\tthis.updateTeaPercentage(teaPercentage);\r\n\t\t}\r\n\t}\r\n\t//进度条达到最大长度\r\n\tgotoMaxLength() {\r\n\t\tshowLog('达到最大长度');\r\n\t\tif (this.schedule) {\r\n\t\t\tclearInterval(this.schedule);\r\n\t\t}\r\n\t\tthis.progressbarImg.x = this.teaFullFlagImg.width / 2\r\n\t\tthis.teaHalfFlagImg.visible = false;\r\n\t\tthis.teaFullFlagImg.visible = !this.teaHalfFlagImg.visible\r\n\t\tthis.addOneSvga.visible = this.teaHalfFlagImg.visible\r\n\t\tthis.addOneSvga.stop();\r\n\t}\r\n\t//需要更换茶叶数量皮肤\r\n\tupdateTeaPercentage(teaPercentage = 0) {\r\n\t\t// console.log('需要更换茶叶数量皮肤')\r\n\t\t// console.log('this.basketLevel', this.basketLevel)\r\n\t\tif (!this.basketLevel)\r\n\t\t\tthis.basketLevel = 0;\r\n\t\tlet pickTeaSVGA = this.basketSvgaGroup[this.basketLevel];\r\n\t\tlet templength = pickTeaSVGA.children.length;\r\n\t\t//console.log('templength',templength)\r\n\t\tif (this.allFrames < templength) {\r\n\t\t\tpickTeaSVGA.removeChildAt(10);\r\n\t\t}\r\n\r\n\t\tlet originframes = pickTeaSVGA.children[7];\r\n\t\tif (!originframes) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\t//按照采茶叶的多少来 设置茶叶是不是满的图片\r\n\t\tlet teaBucketframes = JSON.parse(JSON.stringify(originframes.frames));\r\n\t\t//let teaNumImg = this.teaHalfImg;\r\n\r\n\t\tif (teaPercentage == 1) {\r\n\t\t\tthis.teaHalfImg = new engine.Image(getTextureByName('茶叶-少'));\r\n\t\t}\r\n\t\telse if (teaPercentage == 2) {\r\n\t\t\tthis.teaHalfImg = new engine.Image(getTextureByName('茶叶-满'));\r\n\t\t}\r\n\t\tthis.teaHalfImg.visible = false;\r\n\t\tthis.teaHalfImg['frames'] = teaBucketframes;\r\n\r\n\t\t//showLog('this.teaHalfImg');\r\n\t\t//showLog(this.teaHalfImg);\r\n\t\tpickTeaSVGA.addChildAt(this.teaHalfImg, 10)\r\n\t}\r\n\r\n\tsetPickTeaLevel(level) {\r\n\t\tshowLog('setPickTeaLevel', level);\r\n\t\tthis.basketLevel = level;\r\n\t\tlet pickTeaSVGA = this.basketSvgaGroup[level];\r\n\t\tpickTeaSVGA.visible = true;\r\n\t\t//console.log('总共有多少', pickTeaSVGA.children.length)\r\n\t\t//showLog('littleTea url')\r\n\t\t//showLog(this.teaHalfImg['_source'])\r\n\t\t//需要svga缓存结束\r\n\t\t//setTimeout(() => {\r\n\t\tshowLog('延迟500ms')\r\n\t\tlet originframes = pickTeaSVGA.children[7];\r\n\r\n\t\t//按照采茶叶的多少来 设置茶叶是不是满的图片\r\n\t\tthis.teaHalfImg.visible = true;\r\n\t\tlet teaBucketframes = JSON.parse(JSON.stringify(originframes.frames));\r\n\t\t//this.teaHalfImg = //new engine.Image(getTextureByName('茶叶-少'));\r\n\t\tif (this.teaHalfImg) {\r\n\t\t\t//this.teaHalfImg.source = ''\r\n\t\t\tthis.teaHalfImg['frames'] = teaBucketframes;\r\n\t\t}\r\n\t\tshowLog('this.teaHalfImg');\r\n\t\tshowLog(this.teaHalfImg);\r\n\t\tpickTeaSVGA.addChildAt(this.teaHalfImg, 10)\r\n\t\tpickTeaSVGA.gotoAndPlay(1, true);\r\n\t\t//}, 300)\r\n\t}\r\n\thandGrasp() {\r\n\t\tshowLog('handGrasp')\r\n\t\tlet that = this;\r\n\t\tthis.updateTeaPercentage(0);\r\n\t\tsetTimeout(() => {\r\n\t\t\t//that.handGraspSvga.play(1, true);\r\n\t\t\t// this.pickTeaSvga.play(1, false);\r\n\t\t\t// this.teaSkyUpSvga.play(1, false);\r\n\t\t\tengine.Tween.get(that.handGraspSvga)\r\n\t\t\t\t.to({ x: props.handGraspMovePos[0], y: props.handGraspMovePos[1] }, 400).call(() => {\r\n\t\t\t\t\tshowLog('this.pickTeaSvga.play')\r\n\t\t\t\t\tthat.handGraspSvga.play(1, true);\r\n\t\t\t\t\tsetTimeout(() => {\r\n\t\t\t\t\t\tthat.handGraspSvga.stop()\r\n\t\t\t\t\t\tthat.handGraspSvga.x = props.handGraspSvgaPos[0];\r\n\t\t\t\t\t\tthat.handGraspSvga.y = props.handGraspSvgaPos[1];\r\n\t\t\t\t\t}, 600)\r\n\t\t\t\t\tthat.pickTeaSvga.visible = true\r\n\t\t\t\t\tplaySound('采茶叶');\r\n\t\t\t\t\tthat.teaHalfImg.source = ''\r\n\t\t\t\t\tthat.pickTeaSvga.play(1, false);\r\n\t\t\t\t})\r\n\r\n\t\t\tthat.pickTeaSvga.addEventListener(engine.Event.END_FRAME, function () {\r\n\t\t\t\tshowLog('this.teaSkyUpSvga.play')\r\n\t\t\t\tthat.teaSkyUpSvga.visible = true\r\n\t\t\t\tplaySound('茶叶飞起');\r\n\t\t\t\tthat.teaSkyUpSvga.play(1, false);\r\n\r\n\t\t\t})\r\n\r\n\t\t\tthat.teaSkyUpSvga.addEventListener(engine.Event.END_FRAME, function () {\r\n\t\t\t\tthat.teaSkyUpSvga.visible = false;\r\n\t\t\t\t//that.updateTeaPercentage(0)\r\n\t\t\t\tconsole.log('茶叶初始化')\r\n\t\t\t})\r\n\t\t}, 500);\r\n\t}\r\n\r\n\t/*采茶叶活动*/\r\n}\r\n","/**\r\n * Created by rockyl on 2020-01-09.\r\n */\r\n\r\nimport GameView from \"./GameView\";\r\nimport { injectProps } from \"../props\";\r\n\r\n\r\nexport class GameWrapper extends engine.Container {\r\n\tprivate _status;\r\n\tprivate _gameView: GameView;\r\n\r\n\r\n\tconstructor() {\r\n\t\tsuper();\r\n\t\t/*\r\n\t\tevent-pickTeaGame-init //游戏初始化\r\n\t\t//event-wait-uplevel //待升级\r\n\t\tevent-add-oneScore //+1\r\n\t\tevent-pick-tea //采茶叶\r\n\t\tevent-tea-skyup //茶叶向上飞\r\n\t\tevent-hand-grasp //手抓去\r\n\t\tevent-change-TeaNum //茶叶数量 改变svga动画\r\n\t\tevent-getBasket-Type //获得篮子类型\r\n\t\tevent-setBasket-Type //设置篮子类型\r\n\t\t*/\r\n\t\t// event-getchange-TeaNum //茶叶数量{初始值totalNum,总量nowNum} 改变svga动画\r\n\t\t// event-getBasket-Type //获得篮子类型\r\n\t\t// event-hand-grasp //手抓去\r\n\r\n\t\t//event-pickTeaGame-init 游戏初始化\r\n\t\tengine.globalEvent.addEventListener('event-pickTeaGame-init', this.reset, this);\r\n\r\n\t\tengine.globalEvent.addEventListener('event-hand-grasp', this.handGrasp, this);\r\n\t\tengine.globalEvent.addEventListener('event-getClick-person', this.clickPerson, this);\r\n\t\tengine.globalEvent.addEventListener('event-getchange-TeaNum', this.setTeaNum, this);\r\n\t\tengine.globalEvent.addEventListener('event-getBasket-Type', this.setPickTeaLevel, this);\r\n\r\n\r\n\r\n\t\tlet gameView = this._gameView = new GameView();\r\n\t\tthis.addChild(gameView);\r\n\t}\r\n\r\n\t//设置茶叶数量\r\n\tsetTeaNum(event: engine.Event) {\r\n\t\tinjectProps(event.data);\r\n\t\tthis._gameView.setTeaNum(event.data);\r\n\t}\r\n\r\n\t//设置茶蓝等级\r\n\tsetPickTeaLevel(event: engine.Event) {\r\n\t\tinjectProps(event.data);\r\n\t\tthis._gameView.setPickTeaLevel(event.data);\r\n\t}\r\n\t\r\n\thandGrasp() {\r\n\t\tthis._gameView.handGrasp();\r\n\t}\r\n\t//点击人物\r\n\tclickPerson() {\r\n\t\tthis._gameView.showVerse();\r\n\t}\r\n\treset(event: engine.Event) {\r\n\t\tinjectProps(event.data);\r\n\t\tthis._gameView.visible = true;\r\n\t\tthis._gameView.reset();\r\n\t}\r\n\r\n\r\n\tstart(event: engine.Event) {\r\n\t\tinjectProps(event.data);\r\n\t\tthis._status = 1;\r\n\t\tthis._gameView.start();\r\n\t}\r\n\r\n\tpause() {\r\n\t\tthis._gameView.pause();\r\n\t}\r\n\r\n\tresume() {\r\n\t\tthis._gameView.resume();\r\n\t}\r\n\r\n\trevive() {\r\n\t\tthis._gameView.revive();\r\n\t}\r\n\r\n\tclear() {\r\n\t\tthis._gameView.visible = false;\r\n\t}\r\n\r\n\r\n\r\n\r\n\r\n\tprivate onTap(event) {\r\n\t\t//\tthis._gameView.tap(event);\r\n\t}\r\n}\r\n","/**\r\n * Created by rockyl on 2019-11-20.\r\n */\r\n\r\nimport {GameWrapper} from \"./game/GameWrapper\";\r\nimport {injectProps, prepareProps} from \"./props\";\r\n\r\nexport default function (props) {\r\n\tprepareProps();\r\n\tinjectProps(props);\r\n\r\n\tlet instance = new GameWrapper();\r\n\treturn instance;\r\n}\r\n"],"names":["__extends"],"mappings":";;;;;;CAIO,IAAI,KAAK,GAAQ,EAAE,C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KACjC,OAAO,QAAQ,CAAC;CACjB,CAAC;;;;;;;;;"} {"version":3,"file":"index.js","sources":["src/custom/pick-tea/src/props.ts","src/custom/pick-tea/src/game/utils.ts","src/custom/pick-tea/src/game/GameView.ts","src/custom/pick-tea/src/game/GameWrapper.ts","src/custom/pick-tea/src/index.ts"],"sourcesContent":["/**\r\n * Created by rockyl on 2020-01-21.\r\n */\r\n\r\nexport let props: any = {};\r\n\r\nexport function prepareProps() {\r\n\tlet metaProps = getProps();\r\n\r\n\tengine.injectProp(props, metaProps);\r\n}\r\n\r\nexport function injectProps(p) {\r\n\tengine.injectProp(props, p);\r\n}\r\n","/**\r\n * Created by rockyl on 2020-01-21.\r\n */\r\nconst showlog = false;\r\nexport function getTexture(uuid) {\r\n\treturn engine.Texture.from(getAssetByUUID(uuid).uuid);\r\n}\r\n\r\nexport function getTextureByName(name) {\r\n\treturn getTexture(engine.getAssetByName(name).uuid);\r\n}\r\n\r\nexport function playSound(name) {\r\n\t//console.log('playSound', name)\r\n\tengine.playSound(engine.getAssetByName(name).uuid, { keep: true });\r\n}\r\nexport function createSvga(name, anchorName?) {\r\n\tlet inst = new svga.Svga();\r\n\tinst.source = 'asset://' + engine.getAssetByName(name).uuid;\r\n\treturn inst;\r\n}\r\nexport function showLog(abjname, obj?) {\r\n\tif (showlog) {\r\n\t\tconsole.log(abjname)\r\n\t\tif (obj)\r\n\t\t\tconsole.log(obj)\r\n\t}\r\n\t// let inst = new svga.Svga();\r\n\t// inst.source = 'asset://' + engine.getAssetByName(name).uuid;\r\n\t// return inst;\r\n}","/**\r\n * Created by rockyl on 2018/8/16.\r\n */\r\n\r\nimport { props } from \"../props\";\r\nimport { playSound, createSvga } from \"./utils\";\r\nimport ObjectPool = engine.ObjectPool;\r\nimport { getTextureByName } from \"./utils\";\r\nimport { showLog } from \"./utils\";\r\nimport { Tealeaf } from \"./Tealeaf\";\r\n\r\n\r\nconst MAXX = -8;\r\nexport default class GameView extends engine.Container {\r\n\r\n\tprivate _hasSetup;\r\n\r\n\t/**采茶叶自定义模块*/\r\n\tprivate teaImgSource: any;\r\n\tprivate tealeaf: Tealeaf;\r\n\tprivate teaHalfImg: engine.Image;\r\n\tprivate nowPercentage: any = 0;\r\n\tprivate progressbarBgImg: engine.Image;\r\n\tprivate progressbarImg: engine.Image;\r\n\tprivate teaFullFlagImg: engine.Image;\r\n\tprivate teaHalfFlagImg: engine.Image;\r\n\tprivate teaStarImg: engine.Image;\r\n\tprivate frontImg: engine.Image;\r\n\tprivate verseImg: engine.Image;\r\n\tprivate handGraspBgImg: engine.Image;\r\n\t//采茶背景层\r\n\tprivate pickTeaBg: engine.Container;\r\n\t//采茶进度计时器\r\n\tprivate pickTeaTimer: any\r\n\t//茶叶的数量进度 100/240\r\n\tprivate pickTeaCount: engine.Label;\r\n\t//语句\r\n\tprivate verseLabel: engine.TextField;\r\n\t//篮子集合\r\n\tprivate basketSvgaGroup: any;\r\n\r\n\tprivate basketLevel: any;\r\n\t//纸篮子svga\r\n\tprivate paperBasketSvga\r\n\t//布篮子svga\r\n\tprivate clothBasketSvga\r\n\t//竹篮子svga\r\n\tprivate bambooBasketSvga\r\n\t//木篮子svga\r\n\tprivate woodBasketSvga\r\n\t//+1\r\n\tprivate addOneSvga\r\n\t//采茶叶\r\n\tprivate pickTeaSvga\r\n\t//茶叶向上飞\r\n\tprivate teaSkyUpSvga\r\n\t//手抓去\r\n\tprivate handGraspSvga\r\n\t//半缺旋转\r\n\tprivate teaFullRotation\r\n\r\n\tprivate allFrames;\r\n\t/**采茶叶自定义模块*/\r\n\r\n\t//玩家\r\n\tprivate player: engine.Container;\r\n\r\n\t//触摸层\r\n\tprivate rectBg: engine.Rect;\r\n\t//npc层\r\n\t//private NpcBg: engine.Container;\r\n\r\n\t//当前分数\r\n\tprivate score\r\n\t//游戏状态\r\n\tprivate gameIng;\r\n\t//npc出身计时器\r\n\tprivate timer\r\n\t//倒计时计时器\r\n\tprivate countdownTimer: any\r\n\t//倒计时\r\n\tprivate countdown: number\r\n\t//当前速度\r\n\tprivate speed: number\r\n\r\n\tprivate schedule: any\r\n\t// 当前场景上面的物品\r\n\tprivate goodsItems = []\r\n\r\n\r\n\tconstructor() {\r\n\t\tsuper();\r\n\t\tthis.once(engine.Event.ADDED_TO_STAGE, this.setup, this);\r\n\t}\r\n\r\n\tprivate waterSvga\r\n\tprivate boomSvga\r\n\tprivate playerSvga\r\n\tprivate _touchEnabled = true\r\n\tsetup() {\r\n\t\tif (this._hasSetup) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tthis._hasSetup = true;\r\n\t\tthis.pickTeaBg = new engine.Container();\r\n\t\tthis.basketLevel = null;\r\n\t\t// let bgGroud = new engine.Image()\r\n\t\t// bgGroud.source = '//yun.duiba.com.cn/aurora/assets/a988c47db8d3131faad175c7c2944773392be643.png'\r\n\t\t// this.addChild(bgGroud);\r\n\r\n\t\tthis.addChild(this.pickTeaBg);\r\n\t\tthis.teaHalfImg = new engine.Image();\r\n\r\n\t\tthis.paperBasketSvga = createSvga(\"采茶童-纸篮子\");\r\n\t\tthis.clothBasketSvga = createSvga(\"采茶童-布篮子\");\r\n\t\tthis.bambooBasketSvga = createSvga(\"采茶童-竹编篮\");\r\n\t\tthis.woodBasketSvga = createSvga(\"采茶童-木篮子\");\r\n\t\tthis.addOneSvga = createSvga(\"+1\");\r\n\t\tthis.pickTeaSvga = createSvga(\"采茶叶\");\r\n\r\n\t\tthis.teaSkyUpSvga = createSvga(\"茶叶向上飞\");\r\n\t\tthis.handGraspSvga = createSvga(\"手抓去\");\r\n\r\n\t\tthis.frontImg = new engine.Image(getTextureByName('前景'));\r\n\r\n\t\tthis.pickTeaBg.addChild(this.paperBasketSvga);\r\n\t\tthis.pickTeaBg.addChild(this.clothBasketSvga);\r\n\t\tthis.pickTeaBg.addChild(this.bambooBasketSvga);\r\n\t\tthis.pickTeaBg.addChild(this.woodBasketSvga);\r\n\t\t//this.pickTeaBg.addChild(this.addOneSvga);\r\n\t\tthis.pickTeaBg.addChild(this.pickTeaSvga);\r\n\t\tthis.pickTeaBg.addChild(this.teaSkyUpSvga);\r\n\t\t//this.pickTeaBg.addChild(this.handGraspSvga);\r\n\t\tthis.basketSvgaGroup = [this.paperBasketSvga, this.clothBasketSvga, this.bambooBasketSvga, this.woodBasketSvga]\r\n\r\n\t\tthis.progressbarBgImg = new engine.Image(getTextureByName('进度条底框'));\r\n\t\tthis.progressbarImg = new engine.Image(getTextureByName('进度'));\r\n\t\tthis.teaHalfFlagImg = new engine.Image(getTextureByName('茶叶进度缺'));\r\n\t\tthis.teaFullFlagImg = new engine.Image(getTextureByName('茶叶进度满'));\r\n\t\tthis.teaStarImg = new engine.Image(getTextureByName('小茶叶'));\r\n\r\n\t\tthis.handGraspBgImg = new engine.Image(getTextureByName('茶叶收取底图'));\r\n\t\tthis.verseImg = new engine.Image(getTextureByName('气泡框'));\r\n\t\tthis.pickTeaBg.addChild(this.verseImg);\r\n\r\n\r\n\t\tlet mask = new engine.Rect();\r\n\t\tmask.width = 600;\r\n\t\tmask.height = 50;\r\n\t\tmask.x = 10;\r\n\t\tmask.y = 0;\r\n\t\tmask.alpha = 1;\r\n\r\n\t\tthis.progressbarImg.mask = mask\r\n\t\tshowLog(this.progressbarImg.mask)\r\n\r\n\t\tthis.addChild(this.frontImg);\r\n\r\n\t\tthis.progressbarBgImg.addChild(this.progressbarImg);\r\n\r\n\t\tthis.progressbarBgImg.addChild(mask);\r\n\t\tshowLog('遮罩坐标')\r\n\t\tshowLog(mask.x, mask.y)\r\n\t\tthis.progressbarBgImg.addChild(this.addOneSvga);\r\n\r\n\t\tthis.progressbarBgImg.addChild(this.handGraspBgImg);\r\n\r\n\t\tthis.handGraspBgImg.addChild(this.handGraspSvga);\r\n\r\n\t\tthis.progressbarBgImg.addChild(this.teaHalfFlagImg);\r\n\t\tthis.progressbarBgImg.addChild(this.teaFullFlagImg);\r\n\t\tthis.progressbarBgImg.addChild(this.teaStarImg);\r\n\t\tthis.pickTeaCount = new engine.Label();\r\n\t\tthis.progressbarBgImg.addChild(this.pickTeaCount);\r\n\r\n\t\tthis.addChild(this.progressbarBgImg);\r\n\t\tthis.initView();\r\n\r\n\t\t// setTimeout(() => {\r\n\t\t// \tthis.setPickTeaLevel(1)\r\n\t\t// \tthis.setTeaNum({ totalNum: 150, nowNum: 60, serverData: 1585290768011 })\r\n\t\t// \t//this.setTeaNum({ totalNum: 100, nowNum: 0 })\r\n\t\t// }, 500)\r\n\t\t// setTimeout(() => {\r\n\t\t// \tthis.handGrasp();\r\n\r\n\t\t// \tthis.setTeaNum({ totalNum: 10, nowNum: 0, serverData: 1585290768011 })\r\n\r\n\t\t// }, 12000)\r\n\t\t//playSound('采茶叶');\r\n\r\n\t}\r\n\treset() {\r\n\t\tthis.initView()\r\n\t}\r\n\tstart() {\r\n\r\n\t}\r\n\tpause() {\r\n\t\tthis.gameIng = false;\r\n\t}\r\n\trevive() {\r\n\t\tthis.gameIng = true;\r\n\t}\r\n\r\n\tresume() {\r\n\t\tthis.reset();\r\n\t\tthis.start()\r\n\t}\r\n\r\n\tinitView() {\r\n\t\tthis.pickTeaBg.mouseEnabled = false;\r\n\t\tthis.teaHalfImg.visible = false;\r\n\t\t//this.teaHalfImg.source = '';\r\n\t\tthis.pickTeaSvga.visible = false;\r\n\t\tthis.teaSkyUpSvga.visible = false;\r\n\t\tthis.verseImg.visible = false;\r\n\t\tthis.frontImg.visible = props.showFrontImg == 1;\r\n\t\tthis.initChildrenPos()\r\n\t}\r\n\tinitChildrenPos() {\r\n\t\tfor (let i = 0; i < this.basketSvgaGroup.length; i++) {\r\n\t\t\tthis.basketSvgaGroup[i].visible = false\r\n\t\t\tthis.basketSvgaGroup[i].x = props.basketSvgaPos[0];\r\n\t\t\tthis.basketSvgaGroup[i].y = props.basketSvgaPos[1];;\r\n\t\t\t//this.basketSvgaGroup[i].addEventListener(engine.MouseEvent.CLICK, this.showVerse, this);\r\n\t\t}\r\n\t\tlet pickTeaSVGA = this.basketSvgaGroup[0];\r\n\r\n\t\t//console.log('总共有多少',pickTeaSVGA.children.length)\r\n\t\tthis.allFrames = pickTeaSVGA.children.length;\r\n\r\n\t\tthis.verseImg.x = props.versePos[0]\r\n\t\tthis.verseImg.y = props.versePos[1]\r\n\t\tthis.addOneSvga.x = props.addOneSvgaPos[0]\r\n\t\tthis.addOneSvga.y = props.addOneSvgaPos[1];\r\n\t\tthis.pickTeaSvga.x = props.pickTeaSvgaPos[0];\r\n\t\tthis.pickTeaSvga.y = props.pickTeaSvgaPos[1];\r\n\r\n\t\tthis.teaSkyUpSvga.x = props.teaSkyUpSvgaPos[0];\r\n\t\tthis.teaSkyUpSvga.y = props.teaSkyUpSvgaPos[1];\r\n\r\n\t\tthis.handGraspSvga.x = props.handGraspSvgaPos[0];\r\n\t\tthis.handGraspSvga.y = props.handGraspSvgaPos[1];\r\n\r\n\t\tthis.handGraspBgImg.x = props.handGraspBgImgPos[0];\r\n\t\tthis.handGraspBgImg.y = props.handGraspBgImgPos[1];\r\n\r\n\t\tthis.progressbarBgImg.x = props.progressbarBgImgPos[0]\r\n\r\n\t\tthis.progressbarBgImg.y = props.progressbarBgImgPos[1]\r\n\r\n\t\tthis.progressbarImg.x = props.progressbarImgPos[0]\r\n\t\tthis.progressbarImg.y = props.progressbarImgPos[1]\r\n\r\n\t\tthis.teaHalfFlagImg.x = props.teaHalfFlagImgPos[0]\r\n\t\tthis.teaHalfFlagImg.y = props.teaHalfFlagImgPos[1]\r\n\t\tthis.teaHalfFlagImg.anchorX = this.teaHalfFlagImg.width / 2\r\n\t\tthis.teaHalfFlagImg.anchorY = this.teaHalfFlagImg.height / 2\r\n\r\n\t\tthis.teaFullFlagImg.x = props.teaHalfFlagImgPos[0]\r\n\t\tthis.teaFullFlagImg.y = props.teaHalfFlagImgPos[1]\r\n\r\n\t\tthis.frontImg.x = props.FrontImgPos[0]\r\n\t\tthis.frontImg.y = props.FrontImgPos[1]\r\n\r\n\t\tthis.teaFullFlagImg.visible = false;\r\n\r\n\t\tthis.teaStarImg.x = props.teaStarImgPos[0]\r\n\t\tthis.teaStarImg.y = props.teaStarImgPos[1]\r\n\r\n\t\tthis.pickTeaCount.fillColor = 'white';\r\n\t\tthis.pickTeaCount.size = 30;\r\n\t\tthis.pickTeaCount.text = ''\r\n\r\n\t\tthis.pickTeaCount.x = props.pickTeaCountPos[0]\r\n\t\tthis.pickTeaCount.y = props.pickTeaCountPos[1]\r\n\r\n\t\tthis.pickTeaCount.height = 50;\r\n\t\tthis.pickTeaCount.width = 200;\r\n\r\n\t\tthis.verseLabel = new engine.TextField();\r\n\t\tthis.verseLabel.size = props.verseLabel[2];\r\n\t\tthis.verseLabel.text = ''\r\n\t\tthis.verseLabel.fillColor = props.verseColor[0]\r\n\t\tthis.verseLabel.height = props.verseLabel[1];\r\n\t\tthis.verseLabel.width = props.verseLabel[0];\r\n\t\tthis.verseLabel.strokeColor = props.verseColor[1]\r\n\t\tthis.verseLabel.stroke = 0.5;\r\n\r\n\t\tthis.verseLabel.y = 15;\r\n\t\tthis.verseLabel['textHeight'] = 14;\r\n\t\tthis.verseLabel.textAlign = engine.TEXT_ALIGN.CENTER;\r\n\t\tthis.verseImg.visible = false;\r\n\t\tthis.verseImg.addChild(this.verseLabel);\r\n\r\n\t\t// label.x = (width - label.width) / 2;\r\n\t\t// label.y = guideHole.y + guideHole.height + 50;\r\n\t}\r\n\tshowVerse() {\r\n\t\tshowLog('显示诗句')\r\n\t\t// if (!this._touchEnabled) {\r\n\t\t// \treturn;\r\n\t\t// }\r\n\t\t//this._touchEnabled = false;\r\n\t\tthis.verseImg.visible = true;\r\n\t\tlet len = props.verses.length;\r\n\t\tlet random = Math.floor(Math.random() * len);\r\n\t\tshowLog('random', random)\r\n\t\tshowLog('props.verses')\r\n\t\tshowLog(props.verses)\r\n\t\tlet verse = props.verses[random];\r\n\t\tshowLog('verse', verse)\r\n\t\tthis.verseLabel.text = verse;\r\n\t\tlet y = this.verseImg.y\r\n\t\tengine.Tween.get(this.verseImg)\r\n\t\t\t.to({ alpha: 0 }, 3000).call(() => {\r\n\t\t\t\tthis.verseImg.visible = false;\r\n\t\t\t\tthis.verseImg.alpha = 1\r\n\t\t\t})\r\n\t};\r\n\t/*采茶叶活动*/\r\n\t//总量除以当前 小于3分之1 没有树叶 ,3分之1到3分之2一点点树叶 ,大于3分之2满树叶\r\n\tsetTeaNum(TeaNums) {\r\n\t\tif (this.schedule) {\r\n\t\t\tshowLog('清理定时器,重新设置同步')\r\n\t\t\tclearInterval(this.schedule);\r\n\t\t}\r\n\t\tlet totalNum = TeaNums.totalNum;\r\n\t\tlet nowNum = TeaNums.nowNum\r\n\t\tshowLog('nowNum:', nowNum)\r\n\t\tthis.getTeaPercentage(nowNum, totalNum);\r\n\t\tlet surplus = nowNum - totalNum;\r\n\t\tif (surplus == 0) {\r\n\t\t\tthis.gotoMaxLength();\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tshowLog('surplus', surplus);\r\n\t\tlet width = this.progressbarImg.width;\r\n\t\tlet myDate = new Date();\r\n\t\tlet nowData = myDate.getTime();\r\n\t\tlet serverData = TeaNums.serverData;\r\n\t\t//前后端本身的差值\r\n\t\tlet fbdvalue = Math.abs((nowData - serverData))\r\n\t\tshowLog('fbdvalue', fbdvalue)\r\n\t\t/**/\r\n\t\t//设置数据校正\r\n\t\t// let serverData = 0;\r\n\t\tlet dataDiff = 0;\r\n\t\t/**/\r\n\t\t//let rate = (443 - width * (1 - nowNum / totalNum))\r\n\t\t//已经走得\r\n\t\tlet x = -width * (1 - (nowNum / totalNum))\r\n\r\n\t\tshowLog('原先的X:', this.progressbarImg.x)\r\n\t\tshowLog('比例后的X', x);\r\n\t\t//showLog('parseFloat(x.toFixed(3))', parseFloat(x.toFixed(5)))\r\n\r\n\t\tthis.progressbarImg.x = parseFloat(x.toFixed(5)) + this.teaFullFlagImg.width - Math.abs(this.teaFullFlagImg.x)\r\n\t\tshowLog('减去长款的x', this.progressbarImg.x)\r\n\t\tshowLog('this.teaFullFlagImg.width', this.teaFullFlagImg.width)\r\n\r\n\t\tif (this.progressbarImg.x > (this.teaFullFlagImg.width / 2)) {\r\n\t\t\tlet minus = this.teaFullFlagImg.width - Math.abs(this.teaFullFlagImg.x) - this.progressbarImg.x\r\n\t\t\tshowLog('minus', minus)\r\n\t\t\tthis.progressbarImg.x = this.progressbarImg.x - this.teaFullFlagImg.width / 2 + Math.abs(this.teaFullFlagImg.x)\r\n\t\t\tshowLog('负段x重组', this.progressbarImg.x)\r\n\t\t}\r\n\r\n\t\tshowLog('补宽的X', this.progressbarImg.x);\r\n\t\tshowLog('this.progressbarImg.x', this.progressbarImg.x)\r\n\t\tlet step = (this.teaFullFlagImg.width / 2 - this.progressbarImg.x) / surplus\r\n\t\tshowLog('step', step)\r\n\t\t//step = parseFloat(step.toFixed(6));\r\n\t\t//showLog('进图条每秒比例step', step)\r\n\t\tlet speed = props.pickTeaSpeed;\r\n\t\tif (!this.teaFullRotation) {\r\n\t\t\tthis.teaFullRotation = engine.Tween.get(this.teaHalfFlagImg, { loop: true })\r\n\t\t\t\t.to({ rotation: 360 }, speed).call(() => {\r\n\t\t\t\t\tthis.teaHalfFlagImg.rotation = 0;\r\n\t\t\t\t})\r\n\t\t}\r\n\t\tthis.teaHalfFlagImg.visible = true;\r\n\t\tthis.teaFullFlagImg.visible = !this.teaHalfFlagImg.visible\r\n\t\tthis.addOneSvga.visible = this.teaHalfFlagImg.visible\r\n\r\n\t\tengine.Tween.resumeTweens(this.teaFullRotation);\r\n\t\tthis.schedule = setInterval(() => {\r\n\t\t\t//showLog('nowNum', nowNum, 'totalNum', totalNum)\r\n\t\t\tnowNum++;\r\n\t\t\tthis.addOneSvga.play(1, true);\r\n\t\t\tif (nowNum == totalNum) {\r\n\t\t\t\tthis.gotoMaxLength();\r\n\t\t\t\tthis.getTeaPercentage(nowNum, totalNum);\r\n\t\t\t\tengine.Tween.pauseTweens(this.teaFullRotation);\r\n\t\t\t\t//this.setTeaNum({ totalNum: 100, nowNum: 0, serverData: 1585290768011 });\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\t\t\tif (this.progressbarImg.x < this.teaFullFlagImg.width / 2) {\r\n\t\t\t\tthis.progressbarImg.x -= step;\r\n\t\t\t}\r\n\t\t\tthis.getTeaPercentage(nowNum, totalNum);\r\n\t\t\tdataDiff += speed;\r\n\t\t\tmyDate = new Date();\r\n\t\t\tnowData = myDate.getTime();\r\n\t\t\tif (Math.abs((nowData - serverData)) - dataDiff > (fbdvalue + 3000)) {\r\n\t\t\t\tshowLog('校准数据前后数据偏差过大');\r\n\t\t\t\tshowLog(Math.abs((nowData - serverData)) - dataDiff - (fbdvalue + 3000))\r\n\t\t\t\tshowLog(this.schedule)\r\n\t\t\t\tclearInterval(this.schedule);\r\n\t\t\t\tengine.Tween.pauseTweens(this.teaFullRotation);\r\n\t\t\t\tengine.globalEvent.dispatchEvent('event-setchange-TeaNum');\r\n\t\t\t\tthis.addOneSvga.visible = false;\r\n\t\t\t\tthis.addOneSvga.stop();\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\t\t}, speed)\r\n\t}\r\n\tgetTeaPercentage(nowNum, totalNum) {\r\n\t\tif (nowNum > totalNum) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tthis.pickTeaCount.text = nowNum + '/' + totalNum;\r\n\t\tlet teaPercentage = 2;\r\n\t\tlet portion = totalNum / 3\r\n\t\tif (nowNum < portion) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tif (nowNum < (portion * 2)) {\r\n\t\t\tteaPercentage = 1;\r\n\t\t}\r\n\t\tshowLog('teaPercentage', teaPercentage)\r\n\t\tif (this.nowPercentage != teaPercentage) {\r\n\t\t\tshowLog('状态改变')\r\n\t\t\tthis.nowPercentage = teaPercentage;\r\n\t\t\tthis.updateTeaPercentage(teaPercentage);\r\n\t\t}\r\n\t}\r\n\t//进度条达到最大长度\r\n\tgotoMaxLength() {\r\n\t\tshowLog('达到最大长度');\r\n\t\tif (this.schedule) {\r\n\t\t\tclearInterval(this.schedule);\r\n\t\t}\r\n\t\tthis.progressbarImg.x = this.teaFullFlagImg.width / 2\r\n\t\tthis.teaHalfFlagImg.visible = false;\r\n\t\tthis.teaFullFlagImg.visible = !this.teaHalfFlagImg.visible\r\n\t\tthis.addOneSvga.visible = this.teaHalfFlagImg.visible\r\n\t\tthis.addOneSvga.stop();\r\n\t}\r\n\t//需要更换茶叶数量皮肤\r\n\tupdateTeaPercentage(teaPercentage = 0) {\r\n\t\t// console.log('需要更换茶叶数量皮肤')\r\n\t\t// console.log('this.basketLevel', this.basketLevel)\r\n\t\tif (!this.basketLevel)\r\n\t\t\tthis.basketLevel = 0;\r\n\t\tlet pickTeaSVGA = this.basketSvgaGroup[this.basketLevel];\r\n\t\tlet templength = pickTeaSVGA.children.length;\r\n\t\t//console.log('templength',templength)\r\n\t\tif (this.allFrames < templength) {\r\n\t\t\tpickTeaSVGA.removeChildAt(10);\r\n\t\t}\r\n\r\n\t\tlet originframes = pickTeaSVGA.children[7];\r\n\t\tif (!originframes) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\t//按照采茶叶的多少来 设置茶叶是不是满的图片\r\n\t\tlet teaBucketframes = JSON.parse(JSON.stringify(originframes.frames));\r\n\t\t//let teaNumImg = this.teaHalfImg;\r\n\r\n\t\tif (teaPercentage == 1) {\r\n\t\t\tthis.teaHalfImg = new engine.Image(getTextureByName('茶叶-少'));\r\n\t\t}\r\n\t\telse if (teaPercentage == 2) {\r\n\t\t\tthis.teaHalfImg = new engine.Image(getTextureByName('茶叶-满'));\r\n\t\t}\r\n\t\tthis.teaHalfImg.visible = false;\r\n\t\tthis.teaHalfImg['frames'] = teaBucketframes;\r\n\r\n\t\t//showLog('this.teaHalfImg');\r\n\t\t//showLog(this.teaHalfImg);\r\n\t\tpickTeaSVGA.addChildAt(this.teaHalfImg, 10)\r\n\t}\r\n\r\n\tsetPickTeaLevel(level) {\r\n\t\tshowLog('setPickTeaLevel', level);\r\n\t\tthis.basketLevel = level;\r\n\t\tlet pickTeaSVGA = this.basketSvgaGroup[level];\r\n\t\tpickTeaSVGA.visible = true;\r\n\t\t//console.log('总共有多少', pickTeaSVGA.children.length)\r\n\t\t//showLog('littleTea url')\r\n\t\t//showLog(this.teaHalfImg['_source'])\r\n\t\t//需要svga缓存结束\r\n\t\t//setTimeout(() => {\r\n\t\tshowLog('延迟500ms')\r\n\t\tlet originframes = pickTeaSVGA.children[7];\r\n\r\n\t\t//按照采茶叶的多少来 设置茶叶是不是满的图片\r\n\t\tthis.teaHalfImg.visible = true;\r\n\t\tlet teaBucketframes = JSON.parse(JSON.stringify(originframes.frames));\r\n\t\t//this.teaHalfImg = //new engine.Image(getTextureByName('茶叶-少'));\r\n\t\tif (this.teaHalfImg) {\r\n\t\t\t//this.teaHalfImg.source = ''\r\n\t\t\tthis.teaHalfImg['frames'] = teaBucketframes;\r\n\t\t}\r\n\t\tshowLog('this.teaHalfImg');\r\n\t\tshowLog(this.teaHalfImg);\r\n\t\tpickTeaSVGA.addChildAt(this.teaHalfImg, 10)\r\n\t\tpickTeaSVGA.gotoAndPlay(1, true);\r\n\t\t//}, 300)\r\n\t}\r\n\thandGrasp() {\r\n\t\tshowLog('handGrasp')\r\n\t\tlet that = this;\r\n\t\tthis.updateTeaPercentage(0);\r\n\t\tsetTimeout(() => {\r\n\t\t\t//that.handGraspSvga.play(1, true);\r\n\t\t\t// this.pickTeaSvga.play(1, false);\r\n\t\t\t// this.teaSkyUpSvga.play(1, false);\r\n\t\t\tengine.Tween.get(that.handGraspSvga)\r\n\t\t\t\t.to({ x: props.handGraspMovePos[0], y: props.handGraspMovePos[1] }, 400).call(() => {\r\n\t\t\t\t\tshowLog('this.pickTeaSvga.play')\r\n\t\t\t\t\tthat.handGraspSvga.play(1, true);\r\n\t\t\t\t\tsetTimeout(() => {\r\n\t\t\t\t\t\tthat.handGraspSvga.stop()\r\n\t\t\t\t\t\tthat.handGraspSvga.x = props.handGraspSvgaPos[0];\r\n\t\t\t\t\t\tthat.handGraspSvga.y = props.handGraspSvgaPos[1];\r\n\t\t\t\t\t}, 600)\r\n\t\t\t\t\tthat.pickTeaSvga.visible = true\r\n\t\t\t\t\tplaySound('采茶叶');\r\n\t\t\t\t\tthat.teaHalfImg.source = ''\r\n\t\t\t\t\tthat.pickTeaSvga.play(1, false);\r\n\t\t\t\t})\r\n\r\n\t\t\tthat.pickTeaSvga.addEventListener(engine.Event.END_FRAME, function () {\r\n\t\t\t\tshowLog('this.teaSkyUpSvga.play')\r\n\t\t\t\tthat.teaSkyUpSvga.visible = true\r\n\t\t\t\tplaySound('茶叶飞起');\r\n\t\t\t\tthat.teaSkyUpSvga.play(1, false);\r\n\r\n\t\t\t})\r\n\r\n\t\t\tthat.teaSkyUpSvga.addEventListener(engine.Event.END_FRAME, function () {\r\n\t\t\t\tthat.teaSkyUpSvga.visible = false;\r\n\t\t\t\t//that.updateTeaPercentage(0)\r\n\t\t\t\tconsole.log('茶叶初始化')\r\n\t\t\t})\r\n\t\t}, 500);\r\n\t}\r\n\r\n\t/*采茶叶活动*/\r\n}\r\n","/**\r\n * Created by rockyl on 2020-01-09.\r\n */\r\n\r\nimport GameView from \"./GameView\";\r\nimport { injectProps } from \"../props\";\r\n\r\n\r\nexport class GameWrapper extends engine.Container {\r\n\tprivate _status;\r\n\tprivate _gameView: GameView;\r\n\r\n\r\n\tconstructor() {\r\n\t\tsuper();\r\n\t\t/*\r\n\t\tevent-pickTeaGame-init //游戏初始化\r\n\t\t//event-wait-uplevel //待升级\r\n\t\tevent-add-oneScore //+1\r\n\t\tevent-pick-tea //采茶叶\r\n\t\tevent-tea-skyup //茶叶向上飞\r\n\t\tevent-hand-grasp //手抓去\r\n\t\tevent-change-TeaNum //茶叶数量 改变svga动画\r\n\t\tevent-getBasket-Type //获得篮子类型\r\n\t\tevent-setBasket-Type //设置篮子类型\r\n\t\t*/\r\n\t\t// event-getchange-TeaNum //茶叶数量{初始值totalNum,总量nowNum} 改变svga动画\r\n\t\t// event-getBasket-Type //获得篮子类型\r\n\t\t// event-hand-grasp //手抓去\r\n\r\n\t\t//event-pickTeaGame-init 游戏初始化\r\n\t\tengine.globalEvent.addEventListener('event-pickTeaGame-init', this.reset, this);\r\n\r\n\t\tengine.globalEvent.addEventListener('event-hand-grasp', this.handGrasp, this);\r\n\t\tengine.globalEvent.addEventListener('event-getClick-person', this.clickPerson, this);\r\n\t\tengine.globalEvent.addEventListener('event-getchange-TeaNum', this.setTeaNum, this);\r\n\t\tengine.globalEvent.addEventListener('event-getBasket-Type', this.setPickTeaLevel, this);\r\n\r\n\r\n\r\n\t\tlet gameView = this._gameView = new GameView();\r\n\t\tthis.addChild(gameView);\r\n\t}\r\n\r\n\t//设置茶叶数量\r\n\tsetTeaNum(event: engine.Event) {\r\n\t\tinjectProps(event.data);\r\n\t\tthis._gameView.setTeaNum(event.data);\r\n\t}\r\n\r\n\t//设置茶蓝等级\r\n\tsetPickTeaLevel(event: engine.Event) {\r\n\t\tinjectProps(event.data);\r\n\t\tthis._gameView.setPickTeaLevel(event.data);\r\n\t}\r\n\t\r\n\thandGrasp() {\r\n\t\tthis._gameView.handGrasp();\r\n\t}\r\n\t//点击人物\r\n\tclickPerson() {\r\n\t\tthis._gameView.showVerse();\r\n\t}\r\n\treset(event: engine.Event) {\r\n\t\tinjectProps(event.data);\r\n\t\tthis._gameView.visible = true;\r\n\t\tthis._gameView.reset();\r\n\t}\r\n\r\n\r\n\tstart(event: engine.Event) {\r\n\t\tinjectProps(event.data);\r\n\t\tthis._status = 1;\r\n\t\tthis._gameView.start();\r\n\t}\r\n\r\n\tpause() {\r\n\t\tthis._gameView.pause();\r\n\t}\r\n\r\n\tresume() {\r\n\t\tthis._gameView.resume();\r\n\t}\r\n\r\n\trevive() {\r\n\t\tthis._gameView.revive();\r\n\t}\r\n\r\n\tclear() {\r\n\t\tthis._gameView.visible = false;\r\n\t}\r\n\r\n\r\n\r\n\r\n\r\n\tprivate onTap(event) {\r\n\t\t//\tthis._gameView.tap(event);\r\n\t}\r\n}\r\n","/**\r\n * Created by rockyl on 2019-11-20.\r\n */\r\n\r\nimport {GameWrapper} from \"./game/GameWrapper\";\r\nimport {injectProps, prepareProps} from \"./props\";\r\n\r\nexport default function (props) {\r\n\tprepareProps();\r\n\tinjectProps(props);\r\n\r\n\tlet instance = new GameWrapper();\r\n\treturn instance;\r\n}\r\n"],"names":["__extends"],"mappings":";;;;;;CAIO,IAAI,KAAK,GAAQ,EAAE,CAAC;AAE3B,UAAgB,YAAY;KAC3B,IAAI,SAAS,GAAG,QAAQ,EAAE,CAAC;KAE3B,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;CACrC,CAAC;AAED,UAAgB,WAAW,CAAC,CAAC;KAC5B,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;CAC7B,CAAC;;;UCVe,UAAU,CAAC,IAAI;KAC9B,OAAO,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;CACvD,CAAC;AAED,UAAgB,gBAAgB,CAAC,IAAI;KACpC,OAAO,UAAU,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;CACrD,CAAC;AAED,UAAgB,SAAS,CAAC,IAAI;KAE7B,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;CACpE,CAAC;AACD,UAAgB,UAAU,CAAC,IAAI,EAAE,UAAW;KAC3C,IAAI,IAAI,GAAG,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;KAC3B,IAAI,CAAC,MAAM,GAAG,UAAU,GAAG,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC;KAC5D,OAAO,IAAI,CAAC;CACb,CAAC;AACD,UAAgB,OAAO,CAAC,OAAO,EAAE,GAAI;CASrC,CAA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AAC,OAAO,GAAG,KAAK,CAAC;MAC/B;KAMO,2BAAK,GAAb,UAAc,KAAK;MAElB;KACF,kBAAC;CAAD,CAAC,CA3FgC,MAAM,CAAC,SAAS,GA2FhD;;;iBC5FwB,KAAK;KAC7B,YAAY,EAAE,CAAC;KACf,WAAW,CAAC,KAAK,CAAC,CAAC;KAEnB,IAAI,QAAQ,GAAG,IAAI,WAAW,EAAE,CAAC;KACjC,OAAO,QAAQ,CAAC;CACjB,CAAC;;;;;;;;;"}
\ No newline at end of file
...@@ -468,7 +468,6 @@ export default class GameView extends engine.Container { ...@@ -468,7 +468,6 @@ export default class GameView extends engine.Container {
//按照采茶叶的多少来 设置茶叶是不是满的图片 //按照采茶叶的多少来 设置茶叶是不是满的图片
let teaBucketframes = JSON.parse(JSON.stringify(originframes.frames)); let teaBucketframes = JSON.parse(JSON.stringify(originframes.frames));
//let teaNumImg = this.teaHalfImg; //let teaNumImg = this.teaHalfImg;
if (teaPercentage == 1) { if (teaPercentage == 1) {
this.teaHalfImg = new engine.Image(getTextureByName('茶叶-少')); this.teaHalfImg = new engine.Image(getTextureByName('茶叶-少'));
} }
......
/**
* Created by rockyl on 2020-02-02.
*
* 掉落物品
*/
import {getTextureByName} from "./utils";
import {props} from "../props";
export class Goods extends engine.Container {
private _body:engine.Rect
private _toY;
constructor() {
super();
let body
body = this._body =new engine.Rect()
let rain = new engine.Sprite(getTextureByName('雨滴'));
rain["npcType"]="rain"
let stone = new engine.Sprite(getTextureByName('石块'));
stone["npcType"]="stone"
let boom = new engine.Sprite(getTextureByName('炸弹'));
boom["npcType"]="boom"
rain.visible=false;
stone.visible=false;
boom.visible=false;
body.addChild(rain)
body.addChild(stone)
body.addChild(boom)
this.addChild(body);
body.width=.0001;
body.height=.0001;
body.mouseEnabled=false;
}
getRandomNumberByRange(start, end) {
return Math.floor(Math.random() * (end - start) + start)
}
reset() {
this.visible = true;
this.rotation = 0;
this.anchorOffsetY = 0;
this.y = 0;
this.x = (750-120)*Math.random()+30;
this.rotation = 0;
let random=Math.random()
if(random<props.goodsProbability[0]){
this.showNpc("rain")
}else if(random>=props.goodsProbability[0]&&random<=(props.goodsProbability[0]+props.goodsProbability[1])){
this.showNpc("stone")
}else if(random>(props.goodsProbability[0]+props.goodsProbability[1])){
this.showNpc("boom")
}
}
showNpc(type){
for(let i=0;i<this._body.children.length;i++){
this._body.children[i].visible=false;
this._body.children[i].mouseEnabled=false;
}
for(let i=0;i<this._body.children.length;i++){
if(this._body.children[i]["npcType"]==type){
this["npcType"]=type
this._body.children[i].visible=true;
this._body.children[i].mouseEnabled=false;
}
}
}
set anchorOffsetY(v) {
this._body.y = v;
}
}
/**
* Created by rockyl on 2020-02-03.
*/
import {Goods} from "./Goods";
import ObjectPool = engine.ObjectPool;
export const PoolName: string = 'goods';
ObjectPool.registerPool(PoolName, function () {
return new Goods();
}, function (item: Goods, data) {
item.reset();
});
...@@ -49,6 +49,9 @@ function launchWithCustomModule(customModule) { ...@@ -49,6 +49,9 @@ function launchWithCustomModule(customModule) {
engine.globalEvent.dispatchEvent('pictures-start', { engine.globalEvent.dispatchEvent('pictures-start', {
picUrl: "http://yun.duiba.com.cn/aurora/assets/e1593b97c27077b85b92f7eaaeae1ed64a1eb79a.png", picUrl: "http://yun.duiba.com.cn/aurora/assets/e1593b97c27077b85b92f7eaaeae1ed64a1eb79a.png",
blockUrl: "888", blockUrl: "888",
column:"2",
row:"2",
gameTime:"50"
}); });
const d = engine.gameStage.sceneContainer.getChildAt(0); const d = engine.gameStage.sceneContainer.getChildAt(0);
......
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
function injectProps(p) { function injectProps(p) {
engine.injectProp(props, p); engine.injectProp(props, p);
} }
//# sourceMappingURL=props.js.map
var picMap = {}; var picMap = {};
var posMap = {}; var posMap = {};
...@@ -65,7 +64,6 @@ ...@@ -65,7 +64,6 @@
posMap[url] = pos.concat([]); posMap[url] = pos.concat([]);
return [spr, pos]; return [spr, pos];
}); });
//# sourceMappingURL=qietu.js.map
function getIndexFromRC(row, col, maxCol) { function getIndexFromRC(row, col, maxCol) {
var index; var index;
...@@ -77,7 +75,6 @@ ...@@ -77,7 +75,6 @@
return .5 - Math.random(); return .5 - Math.random();
}); });
} }
//# sourceMappingURL=utils.js.map
var MAX_COL; var MAX_COL;
var MAX_ROW; var MAX_ROW;
...@@ -98,20 +95,24 @@ ...@@ -98,20 +95,24 @@
} }
GameView.prototype.start = function () { GameView.prototype.start = function () {
var _this = this; var _this = this;
MAX_COL = props.column || props.MAX_COL;
MAX_ROW = props.row || props.MAX_ROW;
GAME_TIME = props.gameTime || props.GAME_TIME;
console.log('start', props.column, props.row, props.gameTime);
if (!this.guideHole) { if (!this.guideHole) {
this.guideHole = new engine.Image(); this.guideHole = new engine.Image();
this.guideHole.source = "asset://" + props.blockUrl; this.guideHole.source = 'asset://' + props.blockUrl;
this.guideHole.mouseChildren = this.guideHole.mouseEnabled = false; this.guideHole.mouseChildren = this.guideHole.mouseEnabled = false;
} }
if (this.pictures) { if (this.pictures) {
for (var _i = 0, _a = this.pictures; _i < _a.length; _i++) { for (var _i = 0, _a = this.pictures; _i < _a.length; _i++) {
var pic = _a[_i]; var pic = _a[_i];
if (pic && pic.parent) if (pic && pic.wrapper)
pic.parent.removeChild(pic); pic.wrapper.removeChild(pic);
} }
} }
console.log("on start"); console.log('on start');
engine.globalEvent.dispatchEvent("pictures-time-update", { engine.globalEvent.dispatchEvent('pictures-time-update', {
second: this.getSecond(), second: this.getSecond(),
}); });
var result = qietu(this.picturesWrapper, props.picUrl, MAX_COL, MAX_ROW); var result = qietu(this.picturesWrapper, props.picUrl, MAX_COL, MAX_ROW);
...@@ -134,23 +135,30 @@ ...@@ -134,23 +135,30 @@
this._timer = setInterval(function () { this._timer = setInterval(function () {
_this.onTimer(); _this.onTimer();
}, 10); }, 10);
this.date = new Date().getTime();
}; };
GameView.prototype.onTimer = function () { GameView.prototype.onTimer = function () {
GAME_TIME -= 0.01; var date = new Date().getTime();
var gap = ((date - this.date) / 1000);
this.date = date;
console.log(gap, "gap");
GAME_TIME -= gap;
if (GAME_TIME < 0) {
GAME_TIME = 0;
}
GAME_TIME = this.afterPointTwo(GAME_TIME); GAME_TIME = this.afterPointTwo(GAME_TIME);
GAME_TIME = GAME_TIME.toFixed(2); GAME_TIME = GAME_TIME.toFixed(2);
if (GAME_TIME < 10) { if (GAME_TIME < 10) {
GAME_TIME = "0" + GAME_TIME; GAME_TIME = '0' + GAME_TIME;
} }
console.log(GAME_TIME); console.log(GAME_TIME);
engine.globalEvent.dispatchEvent("pictures-time-update", { engine.globalEvent.dispatchEvent('pictures-time-update', {
second: this.getSecond(), second: this.getSecond(),
}); });
if (this.getSecond() == 0) { if (this.getSecond() == 0) {
GAME_TIME = props.GAME_TIME;
this.stop(); this.stop();
engine.globalEvent.dispatchEvent("pictures-game-fail", { engine.globalEvent.dispatchEvent('pictures-game-fail', {
reason: 1, reason: 1
}); });
} }
}; };
...@@ -166,12 +174,13 @@ ...@@ -166,12 +174,13 @@
return GAME_TIME; return GAME_TIME;
}; };
GameView.prototype.stop = function () { GameView.prototype.stop = function () {
GAME_TIME = props.GAME_TIME;
clearInterval(this._timer); clearInterval(this._timer);
this.stage.removeEventListener(engine.MouseEvent.MOUSE_UP, this.stageOnUp, this);
var len = this.pictures.length; var len = this.pictures.length;
for (var i = 0; i < len; i++) { for (var i = 0; i < len; i++) {
this.pictures[i].removeAllEventListener(); this.pictures[i].removeAllEventListener();
} }
this.stage.removeEventListener(engine.MouseEvent.MOUSE_UP, this.stageOnUp, this);
}; };
GameView.prototype.createRects = function () { }; GameView.prototype.createRects = function () { };
GameView.prototype.setup = function () { GameView.prototype.setup = function () {
...@@ -183,7 +192,7 @@ ...@@ -183,7 +192,7 @@
GAP = props.GAP; GAP = props.GAP;
w = W / MAX_COL; w = W / MAX_COL;
h = H / MAX_ROW; h = H / MAX_ROW;
console.log("onSteup", props); console.log('onSteup', props);
var parent = new engine.Sprite(); var parent = new engine.Sprite();
this.picturesWrapper = parent; this.picturesWrapper = parent;
this.addChild(parent); this.addChild(parent);
...@@ -197,72 +206,67 @@ ...@@ -197,72 +206,67 @@
this.localPicY = e.localY / MAX_ROW; this.localPicY = e.localY / MAX_ROW;
this.distanceX = this.dragPic.x; this.distanceX = this.dragPic.x;
this.distanceY = this.dragPic.y; this.distanceY = this.dragPic.y;
this.indexJ = Math.floor(this.distanceX / (w + GAP)); this.indexJ = Math.floor((this.distanceX) / (w + GAP));
this.indexI = Math.floor(this.distanceY / (h + GAP)); this.indexI = Math.floor((this.distanceY) / (h + GAP));
this.index = this.indexI * MAX_COL + this.indexJ; this.index = (this.indexI) * MAX_COL + this.indexJ;
this.centerX = Math.floor((e.clientX - stageLeft) / w) * w + w / 2; this.centerX = Math.floor((e.clientX - stageLeft) / w) * w + w / 2;
this.centerY = Math.floor((e.clientY - stageTop) / h) * h + h / 2; this.centerY = Math.floor((e.clientY - stageTop) / h) * h + h / 2;
this.stage.addEventListener(engine.MouseEvent.MOUSE_MOVE, this.onMove, this); this.stage.addEventListener(engine.MouseEvent.MOUSE_MOVE, this.onMove, this);
this.stage.addEventListener(engine.MouseEvent.MOUSE_UP, this.stageOnUp, this); this.stage.addEventListener(engine.MouseEvent.MOUSE_UP, this.stageOnUp, this);
}; };
GameView.prototype.stageOnUp = function () { GameView.prototype.stageOnUp = function (e) {
if (GAME_TIME > 0) { var stageLeft = (750 - props.W) / 2;
var stageLeft = (750 - props.W) / 2; var stageTop = (this.stage.height - props.H) / 2;
var stageTop = (this.stage.height - props.H) / 2; this.stage.removeEventListener(engine.MouseEvent.MOUSE_MOVE, this.onMove, this);
this.stage.removeEventListener(engine.MouseEvent.MOUSE_MOVE, this.onMove, this); this.stage.removeEventListener(engine.MouseEvent.MOUSE_UP, this.stageOnUp, this);
this.stage.removeEventListener(engine.MouseEvent.MOUSE_UP, this.stageOnUp, this); if (this.centerY < stageTop || this.centerX < stageLeft) {
if (this.centerY < stageTop || this.centerX < stageLeft) { this.dragPic.x = this.distanceX;
this.dragPic.y = this.distanceY;
}
var curJ = Math.floor(this.centerX / (w + GAP));
var curI = Math.floor(this.centerY / (h + GAP));
this.picturesWrapper.addChild(this.guideHole);
if (0 <= curJ && curJ < (MAX_COL) && 0 <= curI && curI < (MAX_ROW)) {
var index = getIndexFromRC(curI, curJ, MAX_COL);
var dropPic = this.pictures[index];
var dropPicX = dropPic.x + stageLeft;
var dropPicy = dropPic.y + stageTop;
dropPic.x = this.distanceX;
dropPic.y = this.distanceY;
this.dragPic.x = dropPicX - stageLeft;
this.dragPic.y = dropPicy - stageTop;
var dropPicIndex = this.pictures.indexOf(dropPic);
var dragPicIndex = this.pictures.indexOf(this.dragPic);
this.pictures[dropPicIndex] = this.dragPic;
this.pictures[dragPicIndex] = dropPic;
if (dragPicIndex === dropPicIndex) {
this.dragPic.x = this.distanceX; this.dragPic.x = this.distanceX;
this.dragPic.y = this.distanceY; this.dragPic.y = this.distanceY;
} }
var curJ = Math.floor(this.centerX / (w + GAP)); var result = true;
var curI = Math.floor(this.centerY / (h + GAP)); for (var j = 0; j < this.rightList.length; j++) {
this.picturesWrapper.addChild(this.guideHole); if (this.rightList[j] != this.pictures[j]) {
if (0 <= curJ && curJ < MAX_COL && 0 <= curI && curI < MAX_ROW) { result = false;
var index = getIndexFromRC(curI, curJ, MAX_COL); break;
var dropPic = this.pictures[index];
var dropPicX = dropPic.x + stageLeft;
var dropPicy = dropPic.y + stageTop;
dropPic.x = this.distanceX;
dropPic.y = this.distanceY;
this.dragPic.x = dropPicX - stageLeft;
this.dragPic.y = dropPicy - stageTop;
var dropPicIndex = this.pictures.indexOf(dropPic);
var dragPicIndex = this.pictures.indexOf(this.dragPic);
this.pictures[dropPicIndex] = this.dragPic;
this.pictures[dragPicIndex] = dropPic;
if (dragPicIndex === dropPicIndex) {
this.dragPic.x = this.distanceX;
this.dragPic.y = this.distanceY;
}
var result = true;
for (var j = 0; j < this.rightList.length; j++) {
if (this.rightList[j] != this.pictures[j]) {
result = false;
break;
}
}
if (result) {
this.onSuccess();
} }
} }
else { if (result) {
this.dragPic.x = this.distanceX; this.onSuccess();
this.dragPic.y = this.distanceY;
} }
} }
else {
this.dragPic.x = this.distanceX;
this.dragPic.y = this.distanceY;
}
}; };
GameView.prototype.onSuccess = function () { GameView.prototype.onSuccess = function () {
console.log("拼图成功!"); console.log('拼图成功!');
engine.globalEvent.dispatchEvent("pictures-game-success", { engine.globalEvent.dispatchEvent('pictures-game-success', { time: GAME_TIME });
time: GAME_TIME,
});
this.stop(); this.stop();
}; };
GameView.prototype.onMove = function (e) { GameView.prototype.onMove = function (e) {
this.dragPic.x = e.stageX - this.localPicX - (750 - props.W) / 2; this.dragPic.x = e.stageX - this.localPicX - (750 - props.W) / 2;
this.dragPic.y = this.dragPic.y = e.stageY - this.localPicY - (this.stage.height - props.H) / 2;
e.stageY - this.localPicY - (this.stage.height - props.H) / 2;
this.centerX = this.dragPic.x + w / 2; this.centerX = this.dragPic.x + w / 2;
this.centerY = this.dragPic.y + h / 2; this.centerY = this.dragPic.y + h / 2;
}; };
...@@ -288,7 +292,6 @@ ...@@ -288,7 +292,6 @@
}; };
return GameWrapper; return GameWrapper;
}(engine.Container)); }(engine.Container));
//# sourceMappingURL=GameWrapper.js.map
function index (props) { function index (props) {
prepareProps(); prepareProps();
...@@ -296,7 +299,6 @@ ...@@ -296,7 +299,6 @@
var instance = new GameWrapper(); var instance = new GameWrapper();
return instance; return instance;
} }
//# sourceMappingURL=index.js.map
return index; return index;
......
{"version":3,"file":"index.js","sources":["src/custom/pictures/src/props.ts","src/custom/pictures/src/game/qietu.ts","src/custom/pictures/src/game/utils.ts","src/custom/pictures/src/game/GameView.ts","src/custom/pictures/src/game/GameWrapper.ts","src/custom/pictures/src/index.ts"],"sourcesContent":["/**\r\n * Created by rockyl on 2020-01-21.\r\n */\r\n\r\nexport let props: any = {};\r\n\r\nexport function prepareProps() {\r\n\tlet metaProps = getProps();\r\n\r\n\tengine.injectProp(props, metaProps);\r\n}\r\n\r\nexport function injectProps(p) {\r\n\tengine.injectProp(props, p);\r\n}\r\n","import { props } from \"../props\";\r\nconst urls = [];\r\nconst picMap = {};\r\nconst posMap = {};\r\nexport default (parent, url, MAX_COL, MAX_ROW) => {\r\n if (picMap[url]) {\r\n const pics:any[] = picMap[url];\r\n for (const pic of pics) {\r\n parent.addChild(pic);\r\n }\r\n return [picMap[url], posMap[url]]\r\n }\r\n\r\n const W = props.W;\r\n const H = props.H;\r\n const GAP = props.GAP;\r\n\r\n const spr = [];\r\n const pos = []\r\n\r\n for (let row = 0; row < MAX_ROW; row++) {\r\n for (let col = 0; col < MAX_COL; col++) {\r\n\r\n const child = engine.Sprite.fromImage(url);\r\n spr.push(child);\r\n\r\n child.scaleX = 1 / MAX_COL;\r\n child.scaleY = 1 / MAX_ROW;\r\n parent.addChild(child);\r\n child.x = col * (W / MAX_COL + GAP);\r\n child.y = row * (H / MAX_ROW + GAP);\r\n pos.push([child.x, child.y]);\r\n // child.texture.addEventListener('update', () => {\r\n child.addEventListener(engine.Event.COMPLETE, () => {\r\n const uvs = new Float32Array([\r\n col / MAX_COL,\r\n row / MAX_ROW,\r\n (col + 1) / MAX_COL,\r\n row / MAX_ROW,\r\n (col + 1) / MAX_COL,\r\n (row + 1) / MAX_ROW,\r\n col / MAX_COL,\r\n (row + 1) / MAX_ROW,\r\n ]);\r\n\r\n child.uvs = uvs;\r\n // spr.push(child);\r\n });\r\n }\r\n }\r\n picMap[url] = spr.concat([]);\r\n posMap[url] = pos.concat([]);;\r\n // console.log(spr);\r\n return [spr, pos];\r\n};\r\n","/**\r\n * Created by rockyl on 2020-01-21.\r\n */\r\n\r\nexport function getTexture(uuid) {\r\n\treturn engine.Texture.from(getAssetByUUID(uuid).uuid);\r\n}\r\n\r\nexport function getTextureByName(name) {\r\n\treturn getTexture(engine.getAssetByName(name).uuid);\r\n}\r\n\r\nexport function playSound(name) {\r\n\tengine.playSound(engine.getAssetByName(name).uuid, {keep: true});\r\n}\r\nexport function createSvga(name, anchorName?) {\r\n\tlet inst = new svga.Svga();\r\n\tinst.source = 'asset://' + engine.getAssetByName(name).uuid;\r\n\treturn inst;\r\n}\r\n\r\nexport function getIndexFromRC(row,col,maxCol){\r\n\tlet index;\r\n\tindex = row * maxCol + col ;\r\n\treturn index\r\n}\r\n\r\n\r\n\r\n\r\nexport function getRandomArray(array){\r\n\tarray.sort(function() {\r\n\t\treturn .5 - Math.random();\r\n\t});\r\n}","/**\r\n * Created by rockyl on 2018/8/16.\r\n */\r\n\r\nimport { props } from \"../props\";\r\nimport qietu from \"./qietu\";\r\nimport { getIndexFromRC, getRandomArray, getTexture } from \"./utils\";\r\nimport ObjectPool = engine.ObjectPool;\r\n\r\n// let OFFSET_X;\r\n// let OFFSET_Y;\r\nlet MAX_COL;\r\nlet MAX_ROW;\r\nlet W;\r\nlet H;\r\nlet GAP;\r\nlet GAME_TIME;\r\n// 每张图片宽\r\nlet w;\r\n// 每张图片高\r\nlet h;\r\n\r\nexport default class GameView extends engine.Container {\r\n private _timer;\r\n private _timeCounter = 0;\r\n\r\n start() {\r\n if (!this.guideHole) {\r\n this.guideHole = new engine.Image();\r\n this.guideHole.source = \"asset://\" + props.blockUrl;\r\n this.guideHole.mouseChildren = this.guideHole.mouseEnabled = false;\r\n }\r\n\r\n if (this.pictures) {\r\n for (const pic of this.pictures) {\r\n if (pic && pic.parent) pic.parent.removeChild(pic);\r\n }\r\n }\r\n\r\n console.log(\"on start\");\r\n engine.globalEvent.dispatchEvent(\"pictures-time-update\", {\r\n second: this.getSecond(),\r\n });\r\n\r\n // 图片一维数组\r\n const result = qietu(this.picturesWrapper, props.picUrl, MAX_COL, MAX_ROW);\r\n this.picturesWrapper.addChild(this.guideHole);\r\n\r\n console.log(this.picturesWrapper);\r\n\r\n this.pictures = result[0];\r\n this.rightList = this.pictures.concat([]);\r\n const posList = result[1];\r\n getRandomArray(this.pictures);\r\n\r\n let i = 0;\r\n let len;\r\n len = this.pictures.length;\r\n\r\n for (; i < len; i++) {\r\n this.dragPic = this.pictures[i];\r\n this.pictures[i].addEventListener(\r\n engine.MouseEvent.MOUSE_DOWN,\r\n this.onDown,\r\n this\r\n );\r\n const [x, y] = posList[i];\r\n this.dragPic.x = x;\r\n this.dragPic.y = y;\r\n }\r\n\r\n this._timer = setInterval(() => {\r\n this.onTimer();\r\n }, 10);\r\n }\r\n\r\n onTimer() {\r\n // 以GAME_TIME为标准\r\n GAME_TIME -= 0.01;\r\n GAME_TIME = this.afterPointTwo(GAME_TIME);\r\n GAME_TIME = GAME_TIME.toFixed(2);\r\n if (GAME_TIME < 10) {\r\n GAME_TIME = \"0\" + GAME_TIME;\r\n }\r\n console.log(GAME_TIME);\r\n\r\n engine.globalEvent.dispatchEvent(\"pictures-time-update\", {\r\n second: this.getSecond(),\r\n });\r\n\r\n if (this.getSecond() == 0) {\r\n \r\n GAME_TIME = props.GAME_TIME;\r\n this.stop();\r\n \r\n engine.globalEvent.dispatchEvent(\"pictures-game-fail\", {\r\n reason: 1,\r\n });\r\n }\r\n }\r\n\r\n afterPointTwo(n) {\r\n var floatN = parseFloat(n);\r\n if (isNaN(floatN)) {\r\n return;\r\n }\r\n\r\n floatN = Math.round(floatN * 100) / 100;\r\n\r\n return floatN;\r\n }\r\n\r\n getSecond() {\r\n return GAME_TIME;\r\n }\r\n\r\n stop() {\r\n // GAME_TIME = props.GAME_TIME\r\n clearInterval(this._timer);\r\n this.stage.removeEventListener(\r\n engine.MouseEvent.MOUSE_UP,\r\n this.stageOnUp,\r\n this\r\n );\r\n let len = this.pictures.length;\r\n for (let i = 0; i < len; i++) {\r\n this.pictures[i].removeAllEventListener();\r\n }\r\n // this.dragPic.removeAllEventListener();\r\n \r\n }\r\n\r\n constructor() {\r\n super();\r\n this.once(engine.Event.ADDED_TO_STAGE, this.setup, this);\r\n }\r\n\r\n //当前图片对象\r\n dragPic;\r\n // 鼠标在当前图片上的位置\r\n localPicX;\r\n localPicY;\r\n // 拖动的图片最开始的位置(左上角为准)\r\n distanceX;\r\n distanceY;\r\n // 图片中心的位置\r\n centerX: number;\r\n centerY: number;\r\n\r\n pictures: engine.Sprite[];\r\n\r\n // 点击图片时的一维数组索引\r\n index;\r\n // 计算目标图片行和列的位置\r\n indexI: number;\r\n indexJ: number;\r\n rightList: engine.Sprite[];\r\n\r\n private picturesWrapper: engine.Sprite;\r\n private guideHole: engine.Image;\r\n\r\n createRects() {}\r\n setup() {\r\n MAX_COL = props.MAX_COL;\r\n MAX_ROW = props.MAX_ROW;\r\n GAME_TIME = props.GAME_TIME;\r\n // OFFSET_X = props.OFFSET_X;\r\n // OFFSET_Y = props.OFFSET_Y;\r\n W = props.W;\r\n H = props.H;\r\n GAP = props.GAP;\r\n // 每张图片宽\r\n w = W / MAX_COL;\r\n // 每张图片高\r\n h = H / MAX_ROW;\r\n\r\n console.log(\"onSteup\", props);\r\n\r\n const parent = new engine.Sprite();\r\n this.picturesWrapper = parent;\r\n this.addChild(parent);\r\n\r\n // this.picturesWrapper.x = OFFSET_X;\r\n // this.picturesWrapper.y = OFFSET_Y;\r\n\r\n // 添加按钮\r\n // const btn = new engine.Rect();\r\n // btn.width = 200;\r\n // btn.height = 100;\r\n // btn.stage.top = 1000;\r\n // btn.stage.left = 350;\r\n // btn.fillColor = 'cyan';\r\n // this.addChild(btn)\r\n\r\n // btn.addEventListener(engine.MouseEvent.CLICK,this.onClk,this)\r\n }\r\n\r\n onDown(e: engine.MouseEvent) {\r\n // console.log(e);\r\n\r\n let stageLeft = (750 - props.W) / 2;\r\n let stageTop = (this.stage.height - props.H) / 2;\r\n\r\n // 创建一个图片对象接收当前位置信息\r\n this.dragPic = e.target;\r\n this.picturesWrapper.addChild(this.dragPic);\r\n\r\n // 鼠标的偏移量\r\n this.localPicX = e.localX / MAX_COL;\r\n this.localPicY = e.localY / MAX_ROW;\r\n\r\n // 最开始图片的位置\r\n this.distanceX = this.dragPic.x;\r\n this.distanceY = this.dragPic.y;\r\n\r\n // 最开始点击的图片的索引值\r\n\r\n this.indexJ = Math.floor(this.distanceX / (w + GAP));\r\n this.indexI = Math.floor(this.distanceY / (h + GAP));\r\n this.index = this.indexI * MAX_COL + this.indexJ;\r\n\r\n // this.centerX = Math.floor(e.clientX / w) * w + w / 2;\r\n // this.centerY = Math.floor(e.clientY / h) * h + h / 2;\r\n\r\n this.centerX = Math.floor((e.clientX - stageLeft) / w) * w + w / 2;\r\n this.centerY = Math.floor((e.clientY - stageTop) / h) * h + h / 2;\r\n\r\n this.stage.addEventListener(\r\n engine.MouseEvent.MOUSE_MOVE,\r\n this.onMove,\r\n this\r\n );\r\n this.stage.addEventListener(\r\n engine.MouseEvent.MOUSE_UP,\r\n this.stageOnUp,\r\n this\r\n );\r\n }\r\n\r\n listenStageOn = 1;\r\n /*\r\n stageOnUp(e) {\r\n\r\n let stageLeft = (750 - props.W) / 2\r\n let stageTop = (this.stage.height - props.H) / 2;\r\n\r\n this.stage.removeEventListener(\r\n engine.MouseEvent.MOUSE_MOVE,\r\n this.onMove,\r\n this\r\n );\r\n\r\n this.stage.removeEventListener(\r\n engine.MouseEvent.MOUSE_UP,\r\n this.stageOnUp,\r\n this\r\n );\r\n\r\n // 拖动的图片的中心位置在图片之外,回到原来的位置\r\n if (this.centerY < stageTop || this.centerX < stageLeft) {\r\n this.dragPic.x = this.distanceX ;\r\n this.dragPic.y = this.distanceY ;\r\n }\r\n\r\n // 判断图片是否进入另一张图片的范围内\r\n // 要交换的图片第几行第几列\r\n let curJ = Math.floor(this.centerX / (w + GAP));\r\n let curI = Math.floor(this.centerY / (h + GAP));\r\n\r\n this.picturesWrapper.addChild(this.guideHole);\r\n\r\n\r\n // 点击图片的位置\r\n\r\n if ( 0 <= curJ && curJ < (MAX_COL) && 0 <= curI && curI < (MAX_ROW)) {\r\n\r\n // 获取交互图片的索引值\r\n let index = getIndexFromRC(curI, curJ, MAX_COL);\r\n // console.log(index);\r\n\r\n //要交换的图片\r\n let dropPic = this.pictures[index];\r\n\r\n let dropPicX = dropPic.x + stageLeft;\r\n let dropPicy = dropPic.y + stageTop;\r\n\r\n dropPic.x = this.distanceX;\r\n dropPic.y = this.distanceY;\r\n\r\n this.dragPic.x = dropPicX - stageLeft;\r\n this.dragPic.y = dropPicy - stageTop;\r\n\r\n // 交换之后索引也需要交换\r\n\r\n const dropPicIndex = this.pictures.indexOf(dropPic);\r\n const dragPicIndex = this.pictures.indexOf(this.dragPic);\r\n\r\n this.pictures[dropPicIndex] = this.dragPic;\r\n this.pictures[dragPicIndex] = dropPic;\r\n\r\n // 图片中心还是在原来的位置\r\n if (dragPicIndex === dropPicIndex) {\r\n this.dragPic.x = this.distanceX\r\n this.dragPic.y = this.distanceY\r\n }\r\n\r\n let result = true;\r\n for (let j = 0; j < this.rightList.length; j++) {\r\n if (this.rightList[j] != this.pictures[j]) {\r\n result = false;\r\n break;\r\n }\r\n }\r\n\r\n if (result) {\r\n this.onSuccess();\r\n\r\n }\r\n } else {\r\n this.dragPic.x = this.distanceX\r\n this.dragPic.y = this.distanceY\r\n }\r\n\r\n\r\n }\r\n\r\n */\r\n\r\n stageOnUp() {\r\n if (GAME_TIME > 0) {\r\n let stageLeft = (750 - props.W) / 2;\r\n let stageTop = (this.stage.height - props.H) / 2;\r\n\r\n this.stage.removeEventListener(\r\n engine.MouseEvent.MOUSE_MOVE,\r\n this.onMove,\r\n this\r\n );\r\n\r\n this.stage.removeEventListener(\r\n engine.MouseEvent.MOUSE_UP,\r\n this.stageOnUp,\r\n this\r\n );\r\n\r\n // 拖动的图片的中心位置在图片之外,回到原来的位置\r\n if (this.centerY < stageTop || this.centerX < stageLeft) {\r\n this.dragPic.x = this.distanceX;\r\n this.dragPic.y = this.distanceY;\r\n }\r\n\r\n // 判断图片是否进入另一张图片的范围内\r\n // 要交换的图片第几行第几列\r\n let curJ = Math.floor(this.centerX / (w + GAP));\r\n let curI = Math.floor(this.centerY / (h + GAP));\r\n\r\n this.picturesWrapper.addChild(this.guideHole);\r\n\r\n // 点击图片的位置\r\n\r\n if (0 <= curJ && curJ < MAX_COL && 0 <= curI && curI < MAX_ROW) {\r\n // 获取交互图片的索引值\r\n let index = getIndexFromRC(curI, curJ, MAX_COL);\r\n // console.log(index);\r\n\r\n //要交换的图片\r\n let dropPic = this.pictures[index];\r\n\r\n let dropPicX = dropPic.x + stageLeft;\r\n let dropPicy = dropPic.y + stageTop;\r\n\r\n dropPic.x = this.distanceX;\r\n dropPic.y = this.distanceY;\r\n\r\n this.dragPic.x = dropPicX - stageLeft;\r\n this.dragPic.y = dropPicy - stageTop;\r\n\r\n // 交换之后索引也需要交换\r\n\r\n const dropPicIndex = this.pictures.indexOf(dropPic);\r\n const dragPicIndex = this.pictures.indexOf(this.dragPic);\r\n\r\n this.pictures[dropPicIndex] = this.dragPic;\r\n this.pictures[dragPicIndex] = dropPic;\r\n\r\n // 图片中心还是在原来的位置\r\n if (dragPicIndex === dropPicIndex) {\r\n this.dragPic.x = this.distanceX;\r\n this.dragPic.y = this.distanceY;\r\n }\r\n\r\n let result = true;\r\n for (let j = 0; j < this.rightList.length; j++) {\r\n if (this.rightList[j] != this.pictures[j]) {\r\n result = false;\r\n break;\r\n }\r\n }\r\n\r\n if (result) {\r\n this.onSuccess();\r\n }\r\n } else {\r\n this.dragPic.x = this.distanceX;\r\n this.dragPic.y = this.distanceY;\r\n }\r\n }\r\n }\r\n\r\n private onSuccess() {\r\n console.log(\"拼图成功!\");\r\n engine.globalEvent.dispatchEvent(\"pictures-game-success\", {\r\n time: GAME_TIME,\r\n });\r\n this.stop();\r\n }\r\n\r\n onMove(e: engine.MouseEvent) {\r\n // 当前图片的位置\r\n this.dragPic.x = e.stageX - this.localPicX - (750 - props.W) / 2;\r\n this.dragPic.y =\r\n e.stageY - this.localPicY - (this.stage.height - props.H) / 2;\r\n\r\n // 当前图片的中心位置\r\n this.centerX = this.dragPic.x + w / 2;\r\n this.centerY = this.dragPic.y + h / 2;\r\n }\r\n\r\n // onClk(e){\r\n // // 重置时间\r\n // this._timeCounter = 0;\r\n // //重置图片顺序\r\n\r\n // }\r\n}\r\n","/**\r\n * Created by rockyl on 2020-01-09.\r\n */\r\n\r\nimport GameView from \"./GameView\";\r\nimport { injectProps } from \"../props\";\r\n\r\n\r\nexport class GameWrapper extends engine.Container {\r\n\t// private _status;\r\n\tprivate _gameView: GameView;\r\n\r\n\r\n\r\n\r\n\r\n\tconstructor() {\r\n\t\tsuper();\r\n\r\n\t\tengine.globalEvent.addEventListener('pictures-start', this.start, this);\r\n\t\tengine.globalEvent.addEventListener('pictures-stop', this.stop, this);\r\n\r\n\t\t//创建实例\r\n\t\tlet gameView = this._gameView = new GameView();\r\n\t\tthis.addChild(gameView);\r\n\r\n\t}\r\n\r\n\tstart(event: engine.Event) {\r\n\t\tinjectProps(event.data);\r\n\r\n\t\t// this._status = 1;\r\n\r\n\t\tthis._gameView.start();\r\n\t}\r\n\tstop(event: engine.Event) {\r\n\t\t\r\n\t\tthis._gameView.stop();\r\n\t}\r\n}\r\n","/**\r\n * Created by rockyl on 2019-11-20.\r\n */\r\n\r\nimport {GameWrapper} from \"./game/GameWrapper\";\r\nimport {injectProps, prepareProps} from \"./props\";\r\n\r\nexport default function (props) {\r\n\tprepareProps();\r\n\tinjectProps(props);\r\n\r\n\tlet instance = new GameWrapper();\r\n\t\r\n\treturn instance;\r\n}\r\n"],"names":["__extends"],"mappings":";;;;;;CAIO,IAAI,KAAK,GAAQ,EAAE,CAAC;UAEX,YAAY;KAC3B,IAAI,SAAS,GAAG,QAAQ,EAAE,CAAC;KAE3B,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;CACrC,CAAC;UAEe,WAAW,CAAC,CAAC;KAC5B,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;CAC7B,CAAC;;;CCZD,IAAM,MAAM,GAAG,EAAE,CAAC;CAClB,IAAM,MAAM,GAAG,EAAE,CAAC;AAClB,cAAe,UAAC,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO;KAC3C,IAAI,MAAM,C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;KAC7B,YAAY,EAAE,CAAC;KACf,WAAW,CAAC,KAAK,CAAC,CAAC;KAEnB,IAAI,QAAQ,GAAG,IAAI,WAAW,EAAE,CAAC;KAEjC,OAAO,QAAQ,CAAC;CACjB,CAAC;;;;;;;;;"} {"version":3,"file":"index.js","sources":["src/custom/pictures/src/props.ts","src/custom/pictures/src/game/qietu.ts","src/custom/pictures/src/game/utils.ts","src/custom/pictures/src/game/GameView.ts","src/custom/pictures/src/game/GameWrapper.ts","src/custom/pictures/src/index.ts"],"sourcesContent":["/**\r\n * Created by rockyl on 2020-01-21.\r\n */\r\n\r\nexport let props: any = {};\r\n\r\nexport function prepareProps() {\r\n\tlet metaProps = getProps();\r\n\r\n\tengine.injectProp(props, metaProps);\r\n}\r\n\r\nexport function injectProps(p) {\r\n\tengine.injectProp(props, p);\r\n}\r\n","import { props } from \"../props\";\r\nconst urls = [];\r\nconst picMap = {};\r\nconst posMap = {};\r\nexport default (parent, url, MAX_COL, MAX_ROW) => {\r\n if (picMap[url]) {\r\n const pics:any[] = picMap[url];\r\n for (const pic of pics) {\r\n parent.addChild(pic);\r\n }\r\n return [picMap[url], posMap[url]]\r\n }\r\n\r\n const W = props.W;\r\n const H = props.H;\r\n const GAP = props.GAP;\r\n\r\n const spr = [];\r\n const pos = []\r\n\r\n for (let row = 0; row < MAX_ROW; row++) {\r\n for (let col = 0; col < MAX_COL; col++) {\r\n\r\n const child = engine.Sprite.fromImage(url);\r\n spr.push(child);\r\n\r\n child.scaleX = 1 / MAX_COL;\r\n child.scaleY = 1 / MAX_ROW;\r\n parent.addChild(child);\r\n child.x = col * (W / MAX_COL + GAP);\r\n child.y = row * (H / MAX_ROW + GAP);\r\n pos.push([child.x, child.y]);\r\n // child.texture.addEventListener('update', () => {\r\n child.addEventListener(engine.Event.COMPLETE, () => {\r\n const uvs = new Float32Array([\r\n col / MAX_COL,\r\n row / MAX_ROW,\r\n (col + 1) / MAX_COL,\r\n row / MAX_ROW,\r\n (col + 1) / MAX_COL,\r\n (row + 1) / MAX_ROW,\r\n col / MAX_COL,\r\n (row + 1) / MAX_ROW,\r\n ]);\r\n\r\n child.uvs = uvs;\r\n // spr.push(child);\r\n });\r\n }\r\n }\r\n picMap[url] = spr.concat([]);\r\n posMap[url] = pos.concat([]);;\r\n // console.log(spr);\r\n return [spr, pos];\r\n};\r\n","/**\r\n * Created by rockyl on 2020-01-21.\r\n */\r\n\r\nexport function getTexture(uuid) {\r\n\treturn engine.Texture.from(getAssetByUUID(uuid).uuid);\r\n}\r\n\r\nexport function getTextureByName(name) {\r\n\treturn getTexture(engine.getAssetByName(name).uuid);\r\n}\r\n\r\nexport function playSound(name) {\r\n\tengine.playSound(engine.getAssetByName(name).uuid, {keep: true});\r\n}\r\nexport function createSvga(name, anchorName?) {\r\n\tlet inst = new svga.Svga();\r\n\tinst.source = 'asset://' + engine.getAssetByName(name).uuid;\r\n\treturn inst;\r\n}\r\n\r\nexport function getIndexFromRC(row,col,maxCol){\r\n\tlet index;\r\n\tindex = row * maxCol + col ;\r\n\treturn index\r\n}\r\n\r\n\r\n\r\n\r\nexport function getRandomArray(array){\r\n\tarray.sort(function() {\r\n\t\treturn .5 - Math.random();\r\n\t});\r\n}","/**\r\n * Created by rockyl on 2018/8/16.\r\n */\r\n\r\nimport { props } from \"../props\";\r\nimport qietu from \"./qietu\";\r\nimport { getIndexFromRC, getRandomArray, getTexture } from \"./utils\";\r\nimport ObjectPool = engine.ObjectPool;\r\n\r\n// let OFFSET_X;\r\n// let OFFSET_Y;\r\nlet MAX_COL;\r\nlet MAX_ROW;\r\nlet W;\r\nlet H;\r\nlet GAP;\r\nlet GAME_TIME;\r\n// 每张图片宽\r\nlet w;\r\n// 每张图片高\r\nlet h;\r\n\r\nexport default class GameView extends engine.Container {\r\n private _timer;\r\n private _timeCounter = 0;\r\n\r\n private date\r\n\r\n start() {\r\n //优先获取start事件接收到的参数\r\n MAX_COL = props.column || props.MAX_COL;\r\n MAX_ROW = props.row || props.MAX_ROW;\r\n GAME_TIME = props.gameTime || props.GAME_TIME;\r\n console.log('start',props.column,props.row,props.gameTime)\r\n\r\n if (!this.guideHole) {\r\n this.guideHole = new engine.Image();\r\n this.guideHole.source = 'asset://' + props.blockUrl;\r\n this.guideHole.mouseChildren = this.guideHole.mouseEnabled = false;\r\n }\r\n\r\n if (this.pictures) {\r\n for (const pic of this.pictures) {\r\n if (pic && pic.wrapper)\r\n pic.wrapper.removeChild(pic);\r\n }\r\n }\r\n\r\n console.log('on start')\r\n engine.globalEvent.dispatchEvent('pictures-time-update', {\r\n second: this.getSecond(),\r\n });\r\n\r\n // 图片一维数组\r\n const result = qietu(this.picturesWrapper, props.picUrl, MAX_COL, MAX_ROW);\r\n this.picturesWrapper.addChild(this.guideHole);\r\n\r\n console.log(this.picturesWrapper)\r\n\r\n this.pictures = result[0];\r\n this.rightList = this.pictures.concat([]);\r\n const posList = result[1];\r\n getRandomArray(this.pictures);\r\n\r\n let i = 0;\r\n let len;\r\n len = this.pictures.length;\r\n\r\n\r\n for (; i < len; i++) {\r\n this.dragPic = this.pictures[i];\r\n this.pictures[i].addEventListener(\r\n engine.MouseEvent.MOUSE_DOWN,\r\n this.onDown,\r\n this\r\n );\r\n const [x, y] = posList[i];\r\n this.dragPic.x = x;\r\n this.dragPic.y = y;\r\n\r\n }\r\n\r\n this._timer = setInterval(() => {\r\n this.onTimer();\r\n }, 10)\r\n\r\n this.date = new Date().getTime();\r\n\r\n }\r\n\r\n onTimer() {\r\n\r\n let date = new Date().getTime();\r\n\r\n let gap = ((date - this.date) / 1000);\r\n this.date = date;\r\n console.log(gap,\"gap\");\r\n\r\n // 以GAME_TIME为标准\r\n GAME_TIME -= gap;\r\n if(GAME_TIME < 0){\r\n GAME_TIME = 0;\r\n }\r\n GAME_TIME = this.afterPointTwo(GAME_TIME);\r\n GAME_TIME = GAME_TIME.toFixed(2)\r\n if (GAME_TIME < 10) {\r\n GAME_TIME = '0' + GAME_TIME\r\n }\r\n console.log(GAME_TIME);\r\n\r\n\r\n engine.globalEvent.dispatchEvent('pictures-time-update', {\r\n second: this.getSecond(),\r\n });\r\n\r\n if (this.getSecond() == 0) {\r\n this.stop();\r\n engine.globalEvent.dispatchEvent('pictures-game-fail', {\r\n reason: 1\r\n });\r\n }\r\n }\r\n\r\n afterPointTwo(n) {\r\n\r\n var floatN = parseFloat(n);\r\n if (isNaN(floatN)) {\r\n return;\r\n }\r\n floatN = Math.round(floatN * 100) / 100;\r\n return floatN;\r\n\r\n }\r\n\r\n getSecond() {\r\n return GAME_TIME\r\n }\r\n\r\n stop() {\r\n \r\n GAME_TIME = props.GAME_TIME\r\n clearInterval(this._timer);\r\n let len = this.pictures.length;\r\n for(let i=0;i<len;i++){\r\n this.pictures[i].removeAllEventListener();\r\n }\r\n\r\n this.stage.removeEventListener(\r\n engine.MouseEvent.MOUSE_UP,\r\n this.stageOnUp,\r\n this\r\n );\r\n \r\n }\r\n\r\n constructor() {\r\n super();\r\n this.once(engine.Event.ADDED_TO_STAGE, this.setup, this);\r\n }\r\n\r\n //当前图片对象\r\n dragPic;\r\n // 鼠标在当前图片上的位置\r\n localPicX;\r\n localPicY;\r\n // 拖动的图片最开始的位置(左上角为准)\r\n distanceX;\r\n distanceY;\r\n // 图片中心的位置\r\n centerX: number;\r\n centerY: number;\r\n\r\n pictures: engine.Sprite[];\r\n\r\n // 点击图片时的一维数组索引\r\n index;\r\n // 计算目标图片行和列的位置\r\n indexI: number;\r\n indexJ: number;\r\n rightList: engine.Sprite[];\r\n\r\n private picturesWrapper: engine.Sprite;\r\n private guideHole: engine.Image;\r\n\r\n createRects() { }\r\n setup() {\r\n\r\n MAX_COL = props.MAX_COL;\r\n MAX_ROW = props.MAX_ROW;\r\n GAME_TIME = props.GAME_TIME;\r\n // OFFSET_X = props.OFFSET_X;\r\n // OFFSET_Y = props.OFFSET_Y;\r\n W = props.W;\r\n H = props.H;\r\n GAP = props.GAP;\r\n // 每张图片宽\r\n w = W / MAX_COL;\r\n // 每张图片高\r\n h = H / MAX_ROW;\r\n\r\n console.log('onSteup', props);\r\n\r\n const parent = new engine.Sprite();\r\n this.picturesWrapper = parent;\r\n this.addChild(parent);\r\n\r\n // this.picturesWrapper.x = OFFSET_X;\r\n // this.picturesWrapper.y = OFFSET_Y;\r\n\r\n // 添加按钮\r\n // const btn = new engine.Rect();\r\n // btn.width = 200;\r\n // btn.height = 100;\r\n // btn.stage.top = 1000;\r\n // btn.stage.left = 350;\r\n // btn.fillColor = 'cyan';\r\n // this.addChild(btn)\r\n\r\n // btn.addEventListener(engine.MouseEvent.CLICK,this.onClk,this)\r\n\r\n }\r\n\r\n onDown(e: engine.MouseEvent) {\r\n // console.log(e);\r\n\r\n let stageLeft = (750 - props.W) / 2\r\n let stageTop = (this.stage.height - props.H) / 2;\r\n\r\n // 创建一个图片对象接收当前位置信息\r\n this.dragPic = e.target;\r\n this.picturesWrapper.addChild(this.dragPic);\r\n\r\n\r\n // 鼠标的偏移量\r\n this.localPicX = e.localX / MAX_COL;\r\n this.localPicY = e.localY / MAX_ROW;\r\n\r\n // 最开始图片的位置\r\n this.distanceX = this.dragPic.x ;\r\n this.distanceY = this.dragPic.y;\r\n\r\n // 最开始点击的图片的索引值\r\n\r\n this.indexJ = Math.floor((this.distanceX) / (w + GAP));\r\n this.indexI = Math.floor((this.distanceY) / (h + GAP));\r\n this.index = (this.indexI) * MAX_COL + this.indexJ;\r\n\r\n\r\n // this.centerX = Math.floor(e.clientX / w) * w + w / 2;\r\n // this.centerY = Math.floor(e.clientY / h) * h + h / 2;\r\n\r\n this.centerX = Math.floor((e.clientX - stageLeft) / w) * w + w / 2;\r\n this.centerY = Math.floor((e.clientY - stageTop) / h) * h + h / 2;\r\n\r\n this.stage.addEventListener(\r\n engine.MouseEvent.MOUSE_MOVE,\r\n this.onMove,\r\n this\r\n );\r\n this.stage.addEventListener(\r\n engine.MouseEvent.MOUSE_UP,\r\n this.stageOnUp,\r\n this\r\n );\r\n\r\n }\r\n\r\n listenStageOn = 1;\r\n\r\n stageOnUp(e) {\r\n\r\n let stageLeft = (750 - props.W) / 2\r\n let stageTop = (this.stage.height - props.H) / 2;\r\n\r\n this.stage.removeEventListener(\r\n engine.MouseEvent.MOUSE_MOVE,\r\n this.onMove,\r\n this\r\n );\r\n\r\n this.stage.removeEventListener(\r\n engine.MouseEvent.MOUSE_UP,\r\n this.stageOnUp,\r\n this\r\n );\r\n\r\n // 拖动的图片的中心位置在图片之外,回到原来的位置\r\n if (this.centerY < stageTop || this.centerX < stageLeft) {\r\n this.dragPic.x = this.distanceX ;\r\n this.dragPic.y = this.distanceY ;\r\n }\r\n\r\n // 判断图片是否进入另一张图片的范围内\r\n // 要交换的图片第几行第几列\r\n let curJ = Math.floor(this.centerX / (w + GAP));\r\n let curI = Math.floor(this.centerY / (h + GAP));\r\n\r\n this.picturesWrapper.addChild(this.guideHole);\r\n\r\n\r\n // 点击图片的位置\r\n\r\n if ( 0 <= curJ && curJ < (MAX_COL) && 0 <= curI && curI < (MAX_ROW)) {\r\n\r\n // 获取交互图片的索引值\r\n let index = getIndexFromRC(curI, curJ, MAX_COL);\r\n // console.log(index);\r\n\r\n //要交换的图片\r\n let dropPic = this.pictures[index];\r\n\r\n let dropPicX = dropPic.x + stageLeft;\r\n let dropPicy = dropPic.y + stageTop;\r\n\r\n dropPic.x = this.distanceX;\r\n dropPic.y = this.distanceY;\r\n\r\n this.dragPic.x = dropPicX - stageLeft;\r\n this.dragPic.y = dropPicy - stageTop;\r\n\r\n // 交换之后索引也需要交换\r\n\r\n const dropPicIndex = this.pictures.indexOf(dropPic);\r\n const dragPicIndex = this.pictures.indexOf(this.dragPic);\r\n\r\n this.pictures[dropPicIndex] = this.dragPic;\r\n this.pictures[dragPicIndex] = dropPic;\r\n\r\n // 图片中心还是在原来的位置\r\n if (dragPicIndex === dropPicIndex) {\r\n this.dragPic.x = this.distanceX\r\n this.dragPic.y = this.distanceY\r\n }\r\n\r\n let result = true;\r\n for (let j = 0; j < this.rightList.length; j++) {\r\n if (this.rightList[j] != this.pictures[j]) {\r\n result = false;\r\n break;\r\n }\r\n }\r\n\r\n if (result) {\r\n this.onSuccess();\r\n\r\n }\r\n } else {\r\n this.dragPic.x = this.distanceX\r\n this.dragPic.y = this.distanceY\r\n }\r\n\r\n\r\n }\r\n\r\n private onSuccess() {\r\n console.log('拼图成功!');\r\n engine.globalEvent.dispatchEvent('pictures-game-success', { time: GAME_TIME });\r\n this.stop();\r\n\r\n }\r\n\r\n onMove(e: engine.MouseEvent) {\r\n // 当前图片的位置\r\n this.dragPic.x = e.stageX - this.localPicX - (750 - props.W) / 2;\r\n this.dragPic.y = e.stageY - this.localPicY - (this.stage.height - props.H) / 2;\r\n\r\n // 当前图片的中心位置\r\n this.centerX = this.dragPic.x + w / 2;\r\n this.centerY = this.dragPic.y + h / 2;\r\n }\r\n\r\n // onClk(e){\r\n // // 重置时间\r\n // this._timeCounter = 0;\r\n // //重置图片顺序\r\n\r\n\r\n // }\r\n\r\n\r\n}\r\n","/**\r\n * Created by rockyl on 2020-01-09.\r\n */\r\n\r\nimport GameView from \"./GameView\";\r\nimport { injectProps } from \"../props\";\r\n\r\n\r\nexport class GameWrapper extends engine.Container {\r\n\t// private _status;\r\n\tprivate _gameView: GameView;\r\n\r\n\r\n\r\n\r\n\r\n\tconstructor() {\r\n\t\tsuper();\r\n\r\n\t\tengine.globalEvent.addEventListener('pictures-start', this.start, this);\r\n\t\tengine.globalEvent.addEventListener('pictures-stop', this.stop, this);\r\n\r\n\t\t//创建实例\r\n\t\tlet gameView = this._gameView = new GameView();\r\n\t\tthis.addChild(gameView);\r\n\r\n\t}\r\n\r\n\tstart(event: engine.Event) {\r\n\t\tinjectProps(event.data);\r\n\r\n\t\t// this._status = 1;\r\n\r\n\t\tthis._gameView.start();\r\n\t}\r\n\tstop(event: engine.Event) {\r\n\t\t\r\n\t\tthis._gameView.stop();\r\n\t}\r\n}\r\n","/**\r\n * Created by rockyl on 2019-11-20.\r\n */\r\n\r\nimport {GameWrapper} from \"./game/GameWrapper\";\r\nimport {injectProps, prepareProps} from \"./props\";\r\n\r\nexport default function (props) {\r\n\tprepareProps();\r\n\tinjectProps(props);\r\n\r\n\tlet instance = new GameWrapper();\r\n\t\r\n\treturn instance;\r\n}\r\n"],"names":["__extends"],"mappings":";;;;;;CAIO,IAAI,KAAK,GAAQ,EAAE,CAAC;UAEX,YAAY;KAC3B,IAAI,SAAS,GAAG,QAAQ,EAAE,CAAC;KAE3B,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;CACrC,CAAC;UAEe,WAAW,CAAC,CAAC;KAC5B,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;CAC7B;;CCZA,IAAM,MAAM,GAAG,EAAE,CAAC;CAClB,IAAM,MAAM,GAAG,EAAE,CAAC;AAClB,cAAe,UAAC,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO;KAC3C,IAAI,MAAM,CAAC,GAAG,CAAC,EAAE;SACf,IAAM,IAAI,GAAS,MAAM,CAAC,GAAG,CAAC,CAAC;SAC/B,KAAkB,UAAI,EAAJ,aAAI,EAAJ,kBAAI,EAAJ,IAAI,EAAE;aAAnB,IAAM,GAAG,aAAA;aACZ,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;UACtB;SACD,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAA;MAClC;KAED,IAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC;KAClB,IAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC;KAClB,IAAM,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC;KAEtB,IAAM,GAAG,GAAG,EAAE,CAAC;KACf,IAAM,GAAG,GAAG,EAAE,CAAA;6BAEL,GAAG;iCACD,GAAG;aAEV,IAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;aAC3C,GAAG,CAA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A/BgC,MAAM,CAAC,SAAS,GA+BhD;;iBChCwB,KAAK;KAC7B,YAAY,EAAE,CAAC;KACf,WAAW,CAAC,KAAK,CAAC,CAAC;KAEnB,IAAI,QAAQ,GAAG,IAAI,WAAW,EAAE,CAAC;KAEjC,OAAO,QAAQ,CAAC;CACjB,CAAC;;;;;;;;"}
\ No newline at end of file \ No newline at end of file
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
"GAME_TIME": { "GAME_TIME": {
"alias": "游戏时间", "alias": "游戏时间",
"type": "number", "type": "number",
"default": 5 "default": 10
} }
}, },
...@@ -59,7 +59,10 @@ ...@@ -59,7 +59,10 @@
"alias": "开始", "alias": "开始",
"data": { "data": {
"picUrl":"图片路径", "picUrl":"图片路径",
"blockUrl":"blockUrl" "blockUrl":"blockUrl",
"row":"行",
"column":"列",
"gameTime":"游戏时间"
} }
}, },
"pictures-stop": { "pictures-stop": {
......
...@@ -24,8 +24,15 @@ export default class GameView extends engine.Container { ...@@ -24,8 +24,15 @@ export default class GameView extends engine.Container {
private _timer; private _timer;
private _timeCounter = 0; private _timeCounter = 0;
private date
start() { start() {
//优先获取start事件接收到的参数
MAX_COL = props.column || props.MAX_COL;
MAX_ROW = props.row || props.MAX_ROW;
GAME_TIME = props.gameTime || props.GAME_TIME;
console.log('start',props.column,props.row,props.gameTime)
if (!this.guideHole) { if (!this.guideHole) {
this.guideHole = new engine.Image(); this.guideHole = new engine.Image();
this.guideHole.source = 'asset://' + props.blockUrl; this.guideHole.source = 'asset://' + props.blockUrl;
...@@ -76,19 +83,30 @@ export default class GameView extends engine.Container { ...@@ -76,19 +83,30 @@ export default class GameView extends engine.Container {
this._timer = setInterval(() => { this._timer = setInterval(() => {
this.onTimer(); this.onTimer();
}, 10) }, 10)
this.date = new Date().getTime();
} }
onTimer() { onTimer() {
let date = new Date().getTime();
let gap = ((date - this.date) / 1000);
this.date = date;
console.log(gap,"gap");
// 以GAME_TIME为标准 // 以GAME_TIME为标准
GAME_TIME -= 0.01 GAME_TIME -= gap;
if(GAME_TIME < 0){
GAME_TIME = 0;
}
GAME_TIME = this.afterPointTwo(GAME_TIME); GAME_TIME = this.afterPointTwo(GAME_TIME);
GAME_TIME = GAME_TIME.toFixed(2) GAME_TIME = GAME_TIME.toFixed(2)
if (GAME_TIME < 10) { if (GAME_TIME < 10) {
GAME_TIME = '0' + GAME_TIME GAME_TIME = '0' + GAME_TIME
} }
// console.log(GAME_TIME); console.log(GAME_TIME);
engine.globalEvent.dispatchEvent('pictures-time-update', { engine.globalEvent.dispatchEvent('pictures-time-update', {
...@@ -96,7 +114,6 @@ export default class GameView extends engine.Container { ...@@ -96,7 +114,6 @@ export default class GameView extends engine.Container {
}); });
if (this.getSecond() == 0) { if (this.getSecond() == 0) {
GAME_TIME = props.GAME_TIME
this.stop(); this.stop();
engine.globalEvent.dispatchEvent('pictures-game-fail', { engine.globalEvent.dispatchEvent('pictures-game-fail', {
reason: 1 reason: 1
...@@ -110,11 +127,7 @@ export default class GameView extends engine.Container { ...@@ -110,11 +127,7 @@ export default class GameView extends engine.Container {
if (isNaN(floatN)) { if (isNaN(floatN)) {
return; return;
} }
floatN = Math.round(floatN * 100) / 100; floatN = Math.round(floatN * 100) / 100;
return floatN; return floatN;
} }
...@@ -125,7 +138,7 @@ export default class GameView extends engine.Container { ...@@ -125,7 +138,7 @@ export default class GameView extends engine.Container {
stop() { stop() {
// GAME_TIME = props.GAME_TIME GAME_TIME = props.GAME_TIME
clearInterval(this._timer); clearInterval(this._timer);
let len = this.pictures.length; let len = this.pictures.length;
for(let i=0;i<len;i++){ for(let i=0;i<len;i++){
......
/**
* Created by renjianfeng on 2020-03-13.
*/
const customId = 'playWithPlane';
(async function () {
let customModule = await fetch(`../meta.json`);
customModule = await customModule.json();
console.log(customModule);
await loadAssets(customModule.assets);
launchWithCustomModule(customModule);
})();
function launchWithCustomModule(customModule) {
//engine.registerCustomCodeModule(customModule);
engine.registerCustomModule(customId, window[customId]);
const { props: propsOption, assets } = customModule;
let props = engine.computeProps(customModuleProps, propsOption);
const customModuleIns = {
id: customId,
props,
assets,
};
engine.registerCustomModules([customModuleIns]);
engine.launchWithConfig({
options: {
entrySceneView: 'entry',
},
assets: [],
views: [{
name: 'entry',
type: 'node',
properties: {
x: 0,
y: 0,
}
}],
customs: [],
}, null, function () {
setTimeout(() => {
engine.addCustomModule(customId, engine.gameStage.sceneContainer.getChildAt(0));
}, 100);
setTimeout(() => {
engine.globalEvent.dispatchEvent('pictures-start', {
picUrl: "//yun.duiba.com.cn/aurora/assets/57725dcf8cb23905afb87f42d7aba2ffa4c8d2d1.png",
blockUrl: "308742a0-0ea2-4610-b34a-a230add82021",
});
// const d = engine.gameStage.sceneContainer.getChildAt(0);
// engine.gameStage.sceneContainer.getChildAt(0).x = (d.stage.width-props.W)/2;
// engine.gameStage.sceneContainer.getChildAt(0).y = (d.stage.height-props.H)/2;
}, 1000);
// setTimeout(() => {
// engine.globalEvent.dispatchEvent('pictures-start', {
// picUrl: "http://yun.duiba.com.cn/aurora/assets/e1593b97c27077b85b92f7eaaeae1ed64a1eb79a.png",
// // picUrl: "http://yun.duiba.com.cn/aurora/assets/d23e73d37ec01931e48cbd0a4095367044c5675c.png"
// blockUrl: "888"
// });
// }, 30*1000);
});
engine.globalEvent.addEventListener('pictures-time-update', (e) => {
// console.log(e.type, e.data);
});
engine.globalEvent.addEventListener('pictures-game-fail', (e) => {
console.log(e.type, e.data);
});
engine.globalEvent.addEventListener('pictures-game-success', (e) => {
console.log(e.type, e.data);
});
}
function getAssetByUUID(uuid) {
return engine.resolveCustomAsset(customId, uuid);
}
function getProps() {
return engine.getProps(customId);
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>美食从天而降</title>
<meta name="viewport"
content="width=device-width,initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no"/>
<meta name="apple-mobile-web-app-capable" content="yes"/>
<meta name="full-screen" content="true"/>
<meta name="screen-orientation" content="portrait"/>
<meta name="x5-fullscreen" content="true"/>
<meta name="360-fullscreen" content="true"/>
<style>
html,
body {
padding: 0;
margin: 0;
border: 0;
width: 100%;
height: 100%;
overflow: hidden;
position: absolute;
background-color: gray;
}
.game-container{
width: 100%;
height: 100%;
line-height:0;
font-size:0;
}
</style>
</head>
<body>
<div id="game-container" class="game-container"></div>
<script crossorigin="anonymous" src="//yun.duiba.com.cn/editor/zeroing/libs/engine.1de84ff79dba19e949088de63aa75af51a515e5c.js"></script>
<script crossorigin="anonymous" src="//yun.duiba.com.cn/editor/zeroing/libs/svga.fd3923ae6e664251ca7981801a65809cc5f36bc3.js"></script>
<!-- <script src="//yun.duiba.com.cn/editor/zeroing/libs/engine.ebc906f6b50b8da0a669f77027981d5f3cb560ce.js"></script> -->
<!-- <script src="http://localhost:4002/debug/engine.js"></script>
<script src="http://localhost:4003/debug/engine-svga.js"></script> -->
<!--<script src="//yun.duiba.com.cn/editor/zeroing/libs/engine.9a9dbfda4cb2dd5508ecddfe3d95dfd88063f7b5.js"></script>-->
<script src="app.js"></script>
<script src="props.js"></script>
<script src="load-assets.js"></script>
<script src="main.js"></script>
<script>
</script>
</body>
\ No newline at end of file
/**
* Created by rockyl on 2020-01-21.
*/
const assets = [
{
"name": "玩家icon",
"url": "//yun.duiba.com.cn/aurora/assets/5b3e30496b2d9fdafb0cf3835fd6704ce10e45b4.png",
"uuid": "888",
"ext": ".png"
},
{
"name": "雨滴",
"url": "//yun.duiba.com.cn/aurora/assets/8564c8c9be3aead71b05a0bab8d7d07ac3f778a1.png",
"uuid": "264a6192-d7bf-45e8-8f15-6ba2c439a532",
"ext": ".png"
},
{
"name": "炸弹",
"url": "//yun.duiba.com.cn/aurora/assets/171e92283cd13c013ee1b76d28d252ff08815d47.png",
"uuid": "eb88b42d-e151-4c1b-94b9-7c16f7bfac29",
"ext": ".png"
},
{
"name": "石块",
"url": "//yun.duiba.com.cn/aurora/assets/99b0af0c59fe79a415a3f032149cfacc27e3ac2c.png",
"uuid": "ab1bdabc-21ba-46bf-9299-6c638f766c88",
"ext": ".png"
},
{
"name": "水花",
"url": "//yun.duiba.com.cn/aurora/assets/93d37b4a0e367e80e375308a6b4414d72d7666fc.svga",
"uuid": "b521bf94-20e1-44dd-8eca-d24996cbaeae",
"ext": ".svga"
},
{
"name": "炸弹",
"url": "//yun.duiba.com.cn/aurora/assets/4dd18f0689c663bbcf710a7afc4d929084d97d36.svga",
"uuid": "322edf39-805b-4e84-9d07-5573dfeebc0e",
"ext": ".svga"
},
{
"name": "玩家",
"url": "//yun.duiba.com.cn/aurora/assets/b66300c5d4f27134b0aac3dc90a3220e8ae572eb.svga",
"uuid": "71d8dcbc-3931-471a-b585-b3ae01b25aa6",
"ext": ".svga"
}
];
function loadAssets(customModuleAssets, onProgress, onComplete){
return engine.loadAssets(assets.concat(...customModuleAssets), onProgress, onComplete);
}
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('tslib')) :
typeof define === 'function' && define.amd ? define(['tslib'], factory) :
(global = global || self, global.playWithPlane = factory(global.tslib));
}(this, (function (tslib) { 'use strict';
var props = {};
function prepareProps() {
var metaProps = getProps();
engine.injectProp(props, metaProps);
}
function injectProps(p) {
engine.injectProp(props, p);
}
//# sourceMappingURL=props.js.map
function getTexture(uuid) {
return engine.Texture.from(getAssetByUUID(uuid).uuid);
}
//# sourceMappingURL=utils.js.map
var Ball = (function (_super) {
tslib.__extends(Ball, _super);
function Ball() {
var _this = _super.call(this) || this;
_this.plane = new engine.Sprite();
_this.addChild(_this.plane);
return _this;
}
Ball.prototype.setPosition = function () { };
Ball.prototype.died = function () { };
return Ball;
}(engine.Container));
//# sourceMappingURL=Ball.js.map
var SmallPlane = (function (_super) {
tslib.__extends(SmallPlane, _super);
function SmallPlane() {
var _this = _super.call(this) || this;
_this._life = 3;
_this.smallPlane = new engine.Sprite(getTexture('57d4067e-c32f-4b12-a8fc-185753726fc6'));
_this.life = 3;
_this.name = "smallBall";
_this.addChild(_this.smallPlane);
return _this;
}
SmallPlane.prototype.setPosition = function () {
this.x = Math.random() * (750 - this.width);
this.y = Math.random() * (this.height);
};
SmallPlane.prototype.died = function () {
};
return SmallPlane;
}(Ball));
//# sourceMappingURL=SmallBall.js.map
var Bullets = (function (_super) {
tslib.__extends(Bullets, _super);
function Bullets(_harm) {
if (_harm === void 0) { _harm = 1; }
var _this = _super.call(this) || this;
_this.bulletPic = new engine.Sprite(getTexture('18852543-1f1d-498b-af64-88cd3b343758'));
_this.bullets = [];
_this.harm = _harm;
_this.addChild(_this.bulletPic);
return _this;
}
Bullets.prototype.addBullet = function (planeModel) {
var bullet = new engine.Sprite(getTexture('18852543-1f1d-498b-af64-88cd3b343758'));
bullet.x = planeModel ? planeModel.x + planeModel.width / 2 - bullet.width / 2 : 375 - bullet.width / 2;
bullet.y = 1150;
return bullet;
};
Bullets.prototype.createBullet = function (planeModel) {
this.x = planeModel.x + planeModel.width / 2 - this.bulletPic.width / 2;
this.y = 1150;
};
Bullets.prototype.addBulletNum = function (w) {
};
return Bullets;
}(engine.Container));
//# sourceMappingURL=Bullets.js.map
var TestView = (function (_super) {
tslib.__extends(TestView, _super);
function TestView() {
var _this = _super.call(this) || this;
_this.planeArray = [
{
type: 'smallBall',
enemyPlane: []
},
{
type: 'middleBall',
enemyPlane: []
},
{
type: 'largeBall',
enemyPlane: []
}
];
_this.bulletArray = [];
_this.score = 0;
_this.once(engine.Event.ADDED_TO_STAGE, _this.setup, _this);
return _this;
}
TestView.prototype.setup = function () {
this.stageBg = new engine.Sprite(getTexture('308742a0-0ea2-4610-b34a-a230add82021'));
this.addChild(this.stageBg);
this.gameBg = new engine.Sprite(getTexture('76820072-df5a-4ab7-8cb7-10c8cd8605c8'));
this.startBtn = new engine.Sprite(getTexture('855e3d77-ffff-443d-b884-4f67a2ebe458'));
this.startBtn.x = (750 - this.startBtn.width) / 2;
this.startBtn.y = (this.stage.height - this.startBtn.height) / 2 + 300;
this.stageBg.addChild(this.startBtn);
this.startBtn.addEventListener(engine.MouseEvent.CLICK, this.onClick, this);
};
TestView.prototype.start = function () {
var _this = this;
this.planeModel = new engine.Sprite(getTexture('32ec481a-3f75-4c36-95ed-ee97aa936517'));
this.planeModel.x = (750 - this.planeModel.width) / 2;
this.planeModel.y = (this.stage.height - this.planeModel.height);
this.planeModel.addEventListener(engine.MouseEvent.MOUSE_DOWN, this.onDown, this);
this.gameBg.addChild(this.planeModel);
var boom = new engine.Sprite(getTexture('38ec6627-efa8-4f7a-9bdc-3c73cea717f1'));
setInterval(function () {
var smallBall = new SmallPlane();
smallBall.setPosition();
console.log(_this.planeArray);
for (var _i = 0, _a = _this.planeArray; _i < _a.length; _i++) {
var planearray = _a[_i];
if (planearray.type == smallBall.name) {
console.log(planearray.enemyPlane);
planearray.enemyPlane.push(smallBall);
}
}
_this.gameBg.addChild(smallBall);
}, 500);
setInterval(function () {
for (var _i = 0, _a = _this.planeArray; _i < _a.length; _i++) {
var planearray = _a[_i];
if (planearray.type === 'smallBall') {
var _loop_1 = function (sball) {
console.log(sball);
sball.y += 1;
if (sball.y > _this.stage.height) {
_this.gameBg.removeChild(sball);
var index_1 = planearray.enemyPlane.indexOf(sball);
planearray.enemyPlane = planearray.enemyPlane.filter(function (ele, i) { return i != index_1; });
}
};
for (var _b = 0, _c = planearray.enemyPlane; _b < _c.length; _b++) {
var sball = _c[_b];
_loop_1(sball);
}
}
}
}, 16);
setInterval(function () {
var bullet = new Bullets();
bullet.createBullet(_this.planeModel);
_this.bulletArray.push(bullet);
_this.gameBg.addChild(bullet);
}, 40);
setInterval(function () {
console.log(_this.score);
var _loop_2 = function (bullet) {
bullet.y -= 35;
if (bullet.y < -40) {
_this.gameBg.removeChild(bullet);
var index_2 = _this.bulletArray.indexOf(bullet);
_this.bulletArray = _this.bulletArray.filter(function (ele, i) { return i != index_2; });
}
for (var _i = 0, _a = _this.planeArray; _i < _a.length; _i++) {
var planearray = _a[_i];
if (planearray.type === 'smallBall') {
var _loop_3 = function (splane) {
var y = bullet.y - splane.y;
var bulletRight = bullet.x + bullet.width;
var planeRange = splane.x + splane.width;
if (bulletRight > splane.x && bulletRight < planeRange || bullet.x > splane.x && bullet.x < planeRange) {
if (y <= 0) {
splane.life -= bullet.harm;
_this.score += bullet.harm;
_this.gameBg.removeChild(bullet);
var index_3 = _this.bulletArray.indexOf(bullet);
_this.bulletArray = _this.bulletArray.filter(function (ele, i) { return i != index_3; });
if (splane.life === 0) {
_this.gameBg.removeChild(splane);
var ind_1 = planearray.enemyPlane.indexOf(splane);
planearray.enemyPlane = planearray.enemyPlane.filter(function (ele, i) { return i != ind_1; });
boom.x = splane.x;
boom.y = splane.y;
_this.gameBg.addChild(boom);
setTimeout(function () {
_this.gameBg.removeChild(boom);
}, 1500);
}
}
}
};
for (var _b = 0, _c = planearray.enemyPlane; _b < _c.length; _b++) {
var splane = _c[_b];
_loop_3(splane);
}
}
}
};
for (var _i = 0, _a = _this.bulletArray; _i < _a.length; _i++) {
var bullet = _a[_i];
_loop_2(bullet);
}
}, 16);
};
TestView.prototype.onClick = function () {
this.addChild(this.gameBg);
this.gameBg.addChild(this.planeModel);
};
TestView.prototype.onDown = function (e) {
this.mouseX = e.localX;
this.mouseY = e.localY;
this.stage.addEventListener(engine.MouseEvent.MOUSE_MOVE, this.onMove, this);
this.planeModel.x = e.stageX - this.mouseX;
this.planeCenterX = this.planeModel.x + this.planeModel.width / 2;
};
TestView.prototype.onMove = function (e) {
this.centerX = this.planeModel.width / 2;
var movedCenter = this.centerX + e.stageX - this.mouseX;
if (movedCenter < 0) {
this.planeModel.x = -this.centerX;
}
else if (movedCenter > 750) {
this.planeModel.x = 750 - this.centerX;
}
else {
this.planeModel.x = e.stageX - this.mouseX;
this.planeCenterX = this.planeModel.x + this.planeModel.width / 2;
}
};
TestView.prototype.stop = function () {
};
return TestView;
}(engine.Container));
var GameWrapper = (function (_super) {
tslib.__extends(GameWrapper, _super);
function GameWrapper() {
var _this = _super.call(this) || this;
engine.globalEvent.addEventListener('pictures-start', _this.start, _this);
engine.globalEvent.addEventListener('pictures-stop', _this.stop, _this);
var testView = _this._testView = new TestView();
_this.addChild(testView);
return _this;
}
GameWrapper.prototype.start = function (event) {
injectProps(event.data);
this._testView.start();
};
GameWrapper.prototype.stop = function (event) {
this._testView.stop();
};
return GameWrapper;
}(engine.Container));
//# sourceMappingURL=GameWrapper.js.map
function index (props) {
prepareProps();
injectProps(props);
var instance = new GameWrapper();
return instance;
}
//# sourceMappingURL=index.js.map
return index;
})));
//# sourceMappingURL=main.js.map
\ No newline at end of file
{"version":3,"file":"index.js","sources":["src/custom/playWithPlane/src/props.ts","src/custom/playWithPlane/src/game/utils.ts","src/custom/playWithPlane/src/game/Ball.ts","src/custom/playWithPlane/src/game/SmallBall.ts","src/custom/playWithPlane/src/game/Bullets.ts","src/custom/playWithPlane/src/game/TestView.ts","src/custom/playWithPlane/src/game/GameWrapper.ts","src/custom/playWithPlane/src/index.ts"],"sourcesContent":["/**\r\n * Created by rockyl on 2020-01-21.\r\n */\r\n\r\nexport let props: any = {};\r\n\r\nexport function prepareProps() {\r\n\tlet metaProps = getProps();\r\n\r\n\tengine.injectProp(props, metaProps);\r\n}\r\n\r\nexport function injectProps(p) {\r\n\tengine.injectProp(props, p);\r\n}\r\n","/**\r\n * Created by rockyl on 2020-01-21.\r\n */\r\n\r\nexport function getTexture(uuid) {\r\n\treturn engine.Texture.from(getAssetByUUID(uuid).uuid);\r\n}\r\n\r\nexport function getTextureByName(name) {\r\n\treturn getTexture(engine.getAssetByName(name).uuid);\r\n}\r\n\r\nexport function playSound(name) {\r\n\tengine.playSound(engine.getAssetByName(name).uuid, {keep: true});\r\n}\r\nexport function createSvga(name, anchorName?) {\r\n\tlet inst = new svga.Svga();\r\n\tinst.source = 'asset://' + engine.getAssetByName(name).uuid;\r\n\treturn inst;\r\n}\r\n\r\nexport function getIndexFromRC(row,col,maxCol){\r\n\tlet index;\r\n\tindex = row * maxCol + col ;\r\n\treturn index\r\n}\r\n\r\n\r\n\r\n\r\nexport function getRandomArray(array){\r\n\tarray.sort(function() {\r\n\t\treturn .5 - Math.random();\r\n\t});\r\n}","import {getTexture} from './utils'\r\n\r\n\r\nexport default class Ball extends engine.Container{\r\n name:string\r\n // 生命值\r\n life:number;\r\n plane:engine.Sprite = new engine.Sprite()\r\n constructor(){\r\n super();\r\n this.addChild(this.plane)\r\n }\r\n\r\n setPosition(){};\r\n\r\n died(){}\r\n\r\n\r\n}","import Ball from \"./Ball\";\r\nimport { getTexture } from \"./utils\";\r\n\r\n\r\nexport class SmallPlane extends Ball{\r\n _life:number = 3;\r\n smallPlane = new engine.Sprite(getTexture('57d4067e-c32f-4b12-a8fc-185753726fc6'))\r\n constructor(){\r\n super()\r\n this.life = 3;\r\n this.name = \"smallBall\"\r\n this.addChild(this.smallPlane)\r\n\r\n }\r\n\r\n setPosition(){\r\n this.x = Math.random() * (750 - this.width)\r\n this.y = Math.random() * (this.height)\r\n }\r\n\r\n died(){\r\n \r\n }\r\n\r\n\r\n\r\n}","import { getTexture } from \"./utils\"\r\n\r\n\r\nexport class Bullets extends engine.Container{\r\n\r\n harm:number\r\n bulletPic = new engine.Sprite(getTexture('18852543-1f1d-498b-af64-88cd3b343758'))\r\n constructor(_harm = 1){\r\n super()\r\n this.harm = _harm\r\n this.addChild(this.bulletPic)\r\n }\r\n\r\n bullet:engine.Sprite \r\n public bullets:engine.Sprite[] = []\r\n \r\n \r\n addBullet(planeModel?){\r\n let bullet = new engine.Sprite(getTexture('18852543-1f1d-498b-af64-88cd3b343758'))\r\n\r\n bullet.x = planeModel ? planeModel.x + planeModel.width / 2 - bullet.width / 2 : 375 - bullet.width / 2 ;\r\n bullet.y = 1150\r\n\r\n // this.bullets.push(bullet)\r\n return bullet\r\n }\r\n\r\n\r\n // 创建子弹\r\n createBullet(planeModel){\r\n this.x = planeModel.x + planeModel.width / 2 - this.bulletPic.width / 2;\r\n this.y = 1150;\r\n }\r\n\r\n // 达到一定分数增加火力\r\n addBulletNum(w){\r\n\r\n }\r\n \r\n\r\n} ","import {getTexture} from './utils'\r\n\r\nimport { SmallPlane } from './SmallBall'\r\nimport {Bullets} from './Bullets'\r\n\r\nexport default class TestView extends engine.Container{\r\n startBtn:engine.Sprite\r\n stageBg: engine.Sprite;\r\n gameBg: engine.Sprite;\r\n planeModel:engine.Sprite;\r\n\r\n constructor(){\r\n super()\r\n this.once(engine.Event.ADDED_TO_STAGE, this.setup, this);\r\n }\r\n\r\n\r\n setup(){\r\n this.stageBg = new engine.Sprite(getTexture('308742a0-0ea2-4610-b34a-a230add82021'))\r\n this.addChild(this.stageBg)\r\n\r\n this.gameBg = new engine.Sprite(getTexture('76820072-df5a-4ab7-8cb7-10c8cd8605c8'))\r\n\r\n // 开始按钮\r\n this.startBtn = new engine.Sprite(getTexture('855e3d77-ffff-443d-b884-4f67a2ebe458'))\r\n this.startBtn.x = (750 - this.startBtn.width) / 2;\r\n this.startBtn.y = (this.stage.height - this.startBtn.height) / 2 + 300;\r\n this.stageBg.addChild(this.startBtn)\r\n this.startBtn.addEventListener(engine.MouseEvent.CLICK,this.onClick,this)\r\n }\r\n\r\n smallBall:SmallPlane\r\n\r\n planeArray:[\r\n {\r\n type:string,\r\n enemyPlane:Array<any>\r\n },\r\n {\r\n type:string,\r\n enemyPlane:Array<any>\r\n },\r\n {\r\n type:string,\r\n enemyPlane:Array<any>\r\n }\r\n ] = [\r\n {\r\n type:'smallBall',\r\n enemyPlane:[]\r\n },\r\n {\r\n type:'middleBall',\r\n enemyPlane:[]\r\n },\r\n {\r\n type:'largeBall',\r\n enemyPlane:[]\r\n }\r\n ]\r\n\r\n bulletArray:any[] = []\r\n score:number = 0;\r\n start(){\r\n // 炮车\r\n this.planeModel = new engine.Sprite(getTexture('32ec481a-3f75-4c36-95ed-ee97aa936517'))\r\n this.planeModel.x = (750 - this.planeModel.width) / 2;\r\n this.planeModel.y = (this.stage.height - this.planeModel.height)\r\n this.planeModel.addEventListener(engine.MouseEvent.MOUSE_DOWN,this.onDown,this)\r\n\r\n this.gameBg.addChild(this.planeModel)\r\n\r\n let boom = new engine.Sprite(getTexture('38ec6627-efa8-4f7a-9bdc-3c73cea717f1'))\r\n\r\n\r\n //敌机\r\n setInterval(()=>{\r\n let smallBall = new SmallPlane();\r\n smallBall.setPosition();\r\n\r\n console.log(this.planeArray);\r\n for(let planearray of this.planeArray){\r\n if(planearray.type == smallBall.name){\r\n console.log(planearray.enemyPlane)\r\n planearray.enemyPlane.push(smallBall)\r\n }\r\n }\r\n \r\n \r\n this.gameBg.addChild(smallBall)\r\n },500)\r\n\r\n // 敌机移动\r\n setInterval(()=>{\r\n for(let planearray of this.planeArray){\r\n if(planearray.type === 'smallBall'){\r\n for(let sball of planearray.enemyPlane){\r\n console.log(sball)\r\n sball.y += 1;\r\n if(sball.y > this.stage.height){\r\n this.gameBg.removeChild(sball)\r\n let index = planearray.enemyPlane.indexOf(sball)\r\n planearray.enemyPlane = planearray.enemyPlane.filter((ele,i)=>i != index)\r\n }\r\n }\r\n }\r\n }\r\n },16)\r\n\r\n\r\n // my plane\r\n setInterval(()=>{\r\n let bullet = new Bullets();\r\n bullet.createBullet(this.planeModel);\r\n\r\n this.bulletArray.push(bullet)\r\n\r\n this.gameBg.addChild(bullet)\r\n\r\n },40)\r\n\r\n setInterval(()=>{\r\n console.log(this.score);\r\n for(let bullet of this.bulletArray){\r\n\r\n // console.log(bullet,123)\r\n\r\n bullet.y -= 35;\r\n if(bullet.y < -40){\r\n this.gameBg.removeChild(bullet)\r\n let index = this.bulletArray.indexOf(bullet)\r\n this.bulletArray = this.bulletArray.filter((ele,i)=>i != index)\r\n }\r\n\r\n // 击中\r\n for(let planearray of this.planeArray){\r\n if(planearray.type === 'smallBall'){\r\n for(let splane of planearray.enemyPlane){\r\n let y = bullet.y - splane.y;\r\n\r\n let bulletRight = bullet.x + bullet.width;\r\n let planeRange = splane.x + splane.width\r\n if(bulletRight > splane.x && bulletRight < planeRange || bullet.x > splane.x && bullet.x < planeRange){\r\n if(y <= 0){\r\n // 击中敌机\r\n splane.life -= bullet.harm;\r\n this.score += bullet.harm;\r\n \r\n // 子弹移除\r\n this.gameBg.removeChild(bullet);\r\n let index = this.bulletArray.indexOf(bullet);\r\n this.bulletArray = this.bulletArray.filter((ele,i)=>i != index)\r\n\r\n if(splane.life === 0){\r\n this.gameBg.removeChild(splane);\r\n let ind = planearray.enemyPlane.indexOf(splane);\r\n planearray.enemyPlane = planearray.enemyPlane.filter((ele,i)=>i!=ind)\r\n\r\n boom.x = splane.x;\r\n boom.y = splane.y;\r\n this.gameBg.addChild(boom);\r\n setTimeout(() => {\r\n this.gameBg.removeChild(boom);\r\n }, 1500);\r\n }\r\n\r\n }\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n\r\n },16)\r\n\r\n\r\n\r\n }\r\n\r\n\r\n onClick(){\r\n this.addChild(this.gameBg);\r\n this.gameBg.addChild(this.planeModel)\r\n }\r\n mouseX:number;\r\n mouseY:number;\r\n // 炮车宽度\r\n centerX:number;\r\n planeCenterX:number\r\n\r\n onDown(e:engine.MouseEvent){\r\n this.mouseX = e.localX\r\n this.mouseY = e.localY\r\n this.stage.addEventListener(engine.MouseEvent.MOUSE_MOVE,this.onMove,this)\r\n\r\n this.planeModel.x = e.stageX - this.mouseX;\r\n this.planeCenterX = this.planeModel.x + this.planeModel.width / 2;\r\n }\r\n\r\n onMove(e:engine.MouseEvent){\r\n // 炮车移动范围\r\n this.centerX = this.planeModel.width / 2;\r\n let movedCenter = this.centerX + e.stageX - this.mouseX;\r\n if(movedCenter < 0){\r\n this.planeModel.x = -this.centerX;\r\n } else if(movedCenter >750){\r\n this.planeModel.x = 750 - this.centerX;\r\n } else {\r\n this.planeModel.x = e.stageX - this.mouseX;\r\n this.planeCenterX = this.planeModel.x + this.planeModel.width / 2;\r\n\r\n }\r\n }\r\n\r\n stop(){\r\n\r\n }\r\n\r\n}","import GameView from \"./GameView\";\r\nimport { injectProps } from \"../props\";\r\n\r\nimport TestView from './TestView'\r\n\r\n\r\nexport class GameWrapper extends engine.Container{\r\n\tprivate _gameView:GameView\r\n\t\r\n\tprivate _testView:TestView\r\n\r\n constructor(){\r\n super();\r\n engine.globalEvent.addEventListener('pictures-start', this.start, this);\r\n\t\tengine.globalEvent.addEventListener('pictures-stop', this.stop, this);\r\n\r\n\t\t//创建实例\r\n\t\t// let gameView = this._gameView = new GameView();\r\n\t\t// this.addChild(gameView);\r\n\r\n\t\tlet testView = this._testView = new TestView();\r\n\t\tthis.addChild(testView);\r\n }\r\n\r\n // start(event: engine.Event) {\r\n\t// \tinjectProps(event.data);\r\n\r\n\t// \t// this._status = 1;\r\n\r\n\t// \tthis._gameView.start();\r\n\t// }\r\n\t// stop(event: engine.Event) {\r\n\t\t\r\n\t// \tthis._gameView.stop();\r\n\t// }\r\n\r\n\r\n\tstart(event: engine.Event) {\r\n\t\tinjectProps(event.data);\r\n\r\n\t\t// this._status = 1;\r\n\r\n\t\tthis._testView.start();\r\n\t}\r\n\tstop(event: engine.Event) {\r\n\t\t\r\n\t\tthis._testView.stop();\r\n\t}\r\n}","\r\n\r\nimport {GameWrapper} from \"./game/GameWrapper\";\r\nimport {injectProps, prepareProps} from \"./props\";\r\n\r\nexport default function (props) {\r\n\tprepareProps();\r\n\tinjectProps(props);\r\n\r\n\tlet instance = new GameWrapper();\r\n\t\r\n\treturn instance;\r\n}\r\n"],"names":["__extends"],"mappings":";;;;;;CAIO,IAAI,KAAK,GAAQ,EAAE,CAAC;UAEX,YAAY;KAC3B,IAAI,SAAS,GAAG,QAAQ,EAAE,CAAC;KAE3B,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;CACrC,CAAC;UAEe,WAAW,CAAC,CAAC;KAC5B,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;CAC7B,CAAC;;;UCVe,UAAU,CAAC,IAAI;KAC9B,OAAO,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;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KACD,0BAAI,GAAJ,UAAK,KAAmB;SAEvB,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;MACtB;KACF,kBAAC;CAAD,CAAC,CA1CgC,MAAM,CAAC,SAAS,GA0ChD;;;iBC3CwB,KAAK;KAC7B,YAAY,EAAE,CAAC;KACf,WAAW,CAAC,KAAK,CAAC,CAAC;KAEnB,IAAI,QAAQ,GAAG,IAAI,WAAW,EAAE,CAAC;KAEjC,OAAO,QAAQ,CAAC;CACjB,CAAC;;;;;;;;;"}
\ No newline at end of file
/**
* Created by rockyl on 2020-01-21.
*/
let customModuleProps = {
};
{
"name": "拼图",
"desc": "拼图模块1.0",
"props": {
"MAX_COL": {
"alias": "图片分成几列",
"type": "number",
"default": 3
},
"MAX_ROW": {
"alias": "图片分成几行",
"type": "number",
"default": 4
},
"W": {
"alias": "图片的宽度",
"type": "number",
"default": 618
},
"H": {
"alias": "图片的高度",
"type": "number",
"default": 827
},
"OFFSET_X": {
"alias": "OFFSET_X",
"type": "number",
"default": 0
},
"OFFSET_Y": {
"alias": "OFFSET_Y",
"type": "number",
"default": 0
},
"GAME_TIME": {
"alias": "游戏时间",
"type": "number",
"default": 30
},
"GAP": {
"alias": "图片间隙",
"type": "number",
"default": 0
}
},
"assets": [
{
"name": "遮罩",
"url": "//yun.duiba.com.cn/aurora/assets/5b3e30496b2d9fdafb0cf3835fd6704ce10e45b4.png",
"uuid": "888",
"ext": ".png"
},
{
"name":"背景",
"url":" //yun.duiba.com.cn/aurora/assets/57725dcf8cb23905afb87f42d7aba2ffa4c8d2d1.png",
"uuid":"308742a0-0ea2-4610-b34a-a230add82021",
"ext":".png"
},
{
"name":"飞机",
"url":"//yun.duiba.com.cn/aurora/assets/1d2ba15cb8baf3e5783a9f865673dcf9a2421f19.png",
"uuid":"32ec481a-3f75-4c36-95ed-ee97aa936517",
"ext":".png"
},
{
"name":"开始按钮",
"url":"//yun.duiba.com.cn/aurora/assets/2bed3a9e3cae15a6332397ca675c5d44849eaac2.png",
"uuid":"855e3d77-ffff-443d-b884-4f67a2ebe458",
"ext":".png"
},
{
"name":"游戏背景",
"url":"//yun.duiba.com.cn/aurora/assets/5f56d60285f0e3b253716bc938a3c28cbb288cdf.png",
"uuid":"76820072-df5a-4ab7-8cb7-10c8cd8605c8",
"ext":".png"
},
{
"name":"子弹",
"url":"//yun.duiba.com.cn/aurora/assets/06b3baba53973c01be8943b7a002e58de3bea7cf.png",
"uuid":"18852543-1f1d-498b-af64-88cd3b343758",
"ext":".png"
},
{
"name":"敌机",
"url":"//yun.duiba.com.cn/aurora/assets/fc3b2a4349b098183b2b20c8a754b8b182d73806.png",
"uuid":"780b6b63-3abd-4246-94ba-2a3fbdb3c5af",
"ext":".png"
},
{
"name":"small敌机",
"url":"//yun.duiba.com.cn/aurora/assets/1cded0d917c44d22ddce058f239e1cfac1b506c2.png",
"uuid":"57d4067e-c32f-4b12-a8fc-185753726fc6",
"ext":".png"
},
{
"name":"击中",
"url":"//yun.duiba.com.cn/aurora/assets/251402a1991ef00a124ddd91f519a30147285e00.png",
"uuid":"38ec6627-efa8-4f7a-9bdc-3c73cea717f1",
"ext":".png"
}
],
"events": {
"in": {
"pictures-start": {
"alias": "开始",
"data": {
"picUrl":"图片路径",
"blockUrl":"blockUrl",
"GAME_TIME":"每局的游戏时间",
"MAX_ROW":"行",
"MAX_COL":"列",
"W":"宽",
"H":"高",
"GAP":"图片间隙",
"OFFSET_X":"OFFSET_X",
"OFFSET_Y":"OFFSET_Y"
}
},
"pictures-stop": {
"alias": "停止"
}
},
"out": {
"pictures-time-update": {
"alias": "倒计时更新",
"data": {
"time":"剩余时间"
}
},
"pictures-game-fail": {
"alias": "游戏结束",
"data": {
"reason": "结束原因(1:时间到了)"
}
},
"pictures-game-success": {
"alias": "游戏成功",
"data": {
"time": "游戏消耗时间"
}
}
}
}
}
\ No newline at end of file
import {getTexture} from './utils'
export default class Ball extends engine.Container{
name:string
// 生命值
life:number;
plane:engine.Sprite = new engine.Sprite()
constructor(){
super();
this.addChild(this.plane)
}
setPosition(){};
died(){}
}
\ No newline at end of file
import { getTexture } from "./utils"
export class Bullets extends engine.Container{
harm:number
bulletPic = new engine.Sprite(getTexture('18852543-1f1d-498b-af64-88cd3b343758'))
constructor(_harm = 1){
super()
this.harm = _harm
this.addChild(this.bulletPic)
}
bullet:engine.Sprite
public bullets:engine.Sprite[] = []
addBullet(planeModel?){
let bullet = new engine.Sprite(getTexture('18852543-1f1d-498b-af64-88cd3b343758'))
bullet.x = planeModel ? planeModel.x + planeModel.width / 2 - bullet.width / 2 : 375 - bullet.width / 2 ;
bullet.y = 1150
// this.bullets.push(bullet)
return bullet
}
// 创建子弹
createBullet(planeModel){
this.x = planeModel.x + planeModel.width / 2 - this.bulletPic.width / 2;
this.y = 1150;
}
// 达到一定分数增加火力
addBulletNum(w){
}
}
\ No newline at end of file
import GameObject from "./GameObject";
export default abstract class GameComponent {
public get enabled(): boolean {
return this._enabled;
}
public set enabled(v: boolean) {
if (v == true && this._enabled == false) {
this.onEnabled();
this._enabled = v;
} else if (v == false && this._enabled == true) {
this.onDisabled();
this._enabled = v;
}
}
private _enabled: boolean = false;
public get owner(): GameObject {
return this._owner;
}
private _owner: GameObject = null;
constructor(owner: GameObject) {
this._owner = owner;
}
protected abstract onEnabled(): void;
protected abstract onDisabled(): void;
}
\ No newline at end of file
import GameComponent from "./GameComponent";
export default class GameObject extends engine.Container {
public name: string = "";
public addComponent<T extends GameComponent>(cls: any): T {
if (this.getComponent(cls) != null) {
console.error("component is existent");
return;
}
let ins = new cls(this);
ins.enabled = true;
this.componentList.push(ins);
return ins;
}
public getComponent<T extends GameComponent>(cls: any): T {
for (let i of this.componentList) {
if (i instanceof cls) {
return i as T;
}
}
return null;
}
public removeComponent(cls: any) {
for (let i of this.componentList) {
if (i instanceof cls) {
i.enabled = false;
this.componentList = this.componentList.filter(e => e != i);
return;
}
}
}
private _anchorOffsetX: number = 0;
public get anchorOffsetX(): number {
return this._anchorOffsetX;
}
public set anchorOffsetX(v: number) {
this._anchorOffsetX = v;
}
private _anchorOffsetY: number = 0;
public get anchorOffsetY(): number {
return this._anchorOffsetY;
}
public set anchorOffsetY(v: number) {
this._anchorOffsetY = v;
}
private componentList: GameComponent[] = [];
constructor() {
super();
// this.addEventListener(engine.Event.REMOVED_FROM_STAGE, this.disableAllComponents, this);
this.mouseEnabled = false;
this.mouseChildren = false;
}
/**销毁时禁用所有组件 */
dispose() {
this.destroy();
this.disableAllComponents();
}
protected disableAllComponents() {
Object.keys(this.componentList).forEach(e => this.componentList[e].enabled = false);
}
protected enableAllComponents() {
Object.keys(this.componentList).forEach(e => this.componentList[e].enabled = true);
}
}
\ No newline at end of file
import {props} from '../props'
import {getTexture,getTextureByName} from './utils'
import {Ball} from './Ball';
import {Bullets} from './Bullets';
export default class GameView extends engine.Container{
startBtn:engine.Sprite
stageBg: engine.Sprite;
planeModel:engine.Sprite;
pictureWrapper: engine.Sprite;
gameBg: engine.Sprite;
bullet: engine.Sprite;
ball:engine.Sprite;
constructor(){
super()
this.once(engine.Event.ADDED_TO_STAGE, this.setup, this);
}
setup(){
this.stageBg = new engine.Sprite(getTexture('308742a0-0ea2-4610-b34a-a230add82021'))
this.addChild(this.stageBg)
this.gameBg = new engine.Sprite(getTexture('76820072-df5a-4ab7-8cb7-10c8cd8605c8'))
this.bullet = new engine.Sprite(getTexture('18852543-1f1d-498b-af64-88cd3b343758'))
// 开始按钮
this.startBtn = new engine.Sprite(getTexture('855e3d77-ffff-443d-b884-4f67a2ebe458'))
this.startBtn.x = (750 - this.startBtn.width) / 2;
this.startBtn.y = (this.stage.height - this.startBtn.height) / 2 + 300;
this.stageBg.addChild(this.startBtn)
this.startBtn.addEventListener(engine.MouseEvent.CLICK,this.onClick,this)
}
mouseX;
mouseY;
planeCenterX;
centerX
ballArray:engine.Sprite[] = []
bulletArray:engine.Sprite[] = []
baller:Ball
bulleter:Bullets
ballerArray:any[] = []
bulletsArray:any[] = []
score:number = 0
start(){
// 炮车
this.planeModel = new engine.Sprite(getTexture('32ec481a-3f75-4c36-95ed-ee97aa936517'))
this.planeModel.x = (750 - this.planeModel.width) / 2;
this.planeModel.y = (this.stage.height - this.planeModel.height)
this.planeModel.addEventListener(engine.MouseEvent.MOUSE_DOWN,this.onDown,this)
// 子弹
// this.bullet.x = 375;
// this.bullet.y = 1150
this.gameBg.addChild(this.planeModel)
let boom = new engine.Sprite(getTexture('38ec6627-efa8-4f7a-9bdc-3c73cea717f1'))
// 计分
// 敌机
setInterval(()=>{
let ball = new engine.Sprite(getTexture('780b6b63-3abd-4246-94ba-2a3fbdb3c5af'));
ball.x = Math.random() * (750 - ball.width ) ;
ball.y = Math.random() * (ball.height);
let life = 5
this.ballerArray.push({ball,life})
this.gameBg.addChild(ball)
},500)
// 敌机移动
// setInterval(()=>{
// let index
// for(let ball of this.ballerArray){
// // ball.x += Math.random() * (40) + (-20);
// ball.y += 1;
// if(ball.y > this.stage.height){
// this.gameBg.removeChild(ball)
// index = this.ballerArray.indexOf(ball)
// this.ballerArray = this.ballerArray.filter((ele,i)=>i != index)
// }
// }
// },16)
// 添加生命值
setInterval(()=>{
let index
for(let ballObj of this.ballerArray){
// ball.x += Math.random() * (40) + (-20);
ballObj.ball.y += 1;
if(ballObj.ball.y > this.stage.height){
this.gameBg.removeChild(ballObj.ball)
index = this.ballerArray.indexOf(ballObj)
this.ballerArray = this.ballerArray.filter((ele,i)=>i != index)
}
}
},16)
// 子弹
setInterval(()=>{
let bullet = new engine.Sprite(getTexture('18852543-1f1d-498b-af64-88cd3b343758'))
bullet.x = this.planeModel ? this.planeModel.x + this.planeModel.width / 2 - bullet.width / 2 : 375 - bullet.width / 2 ;
bullet.y = 1150
let harm = 1;
this.bulletsArray.push({bullet,harm});
this.gameBg.addChild(bullet)
},100)
// 子弹移动
// 计算伤害
// 碰撞
// setInterval(()=>{
// for(let bullet of this.bulletsArray){
// console.log(this.ballerArray)
// console.log(this.bulletsArray)
// console.log("===================");
// bullet.y -= 40;
// if(bullet.y < -40){
// this.gameBg.removeChild(bullet)
// let index = this.bulletsArray.indexOf(bullet)
// this.bulletsArray = this.bulletsArray.filter((ele,i)=>i != index)
// }
// for(let baller of this.ballerArray){
// let y = bullet.y - baller.y;
// let bulletRight = bullet.x + bullet.width;
// if(bulletRight > baller.x && bulletRight < (baller.x + baller.width) || bullet.x > baller.x && bullet.x < (baller.x + baller.width)){
// if(y <= 0){
// // 击中 移除敌机
// this.gameBg.removeChild(bullet)
// let index = this.bulletsArray.indexOf(bullet)
// this.bulletsArray = this.bulletsArray.filter((ele,i)=>i != index)
// boom.x = baller.x;
// boom.y = baller.y;
// this.gameBg.addChild(boom)
// this.gameBg.removeChild(baller)
// let ind = this.ballerArray.indexOf(baller)
// this.ballerArray = this.ballerArray.filter((ele,i)=>i != ind)
// setTimeout(() => {
// this.gameBg.removeChild(boom);
// }, 1500);
// }
// }
// }
// }
// },20)
setInterval(()=>{
for(let bulletObj of this.bulletsArray){
console.log(this.ballerArray)
console.log(this.bulletsArray)
console.log("得分:"+this.score)
console.log("===================");
bulletObj.bullet.y -= 40;
if(bulletObj.bullet.y < -40){
this.gameBg.removeChild(bulletObj.bullet)
let index = this.bulletsArray.indexOf(bulletObj)
this.bulletsArray = this.bulletsArray.filter((ele,i)=>i != index)
}
for(let ballObj of this.ballerArray){
let y = bulletObj.bullet.y - ballObj.ball.y;
let bulletRight = bulletObj.bullet.x + bulletObj.bullet.width;
if(bulletRight > ballObj.ball.x && bulletRight < (ballObj.ball.x + ballObj.ball.width) || bulletObj.bullet.x > ballObj.ball.x && bulletObj.bullet.x < (ballObj.ball.x + ballObj.ball.width)){
if(y <= 0){
// 击中 移除敌机
ballObj.life -= bulletObj.harm;
// 加分
this.score += bulletObj.harm;
// console.log("得分:"+this.score)
//子弹移除
this.gameBg.removeChild(bulletObj.bullet)
let index = this.bulletsArray.indexOf(bulletObj)
this.bulletsArray = this.bulletsArray.filter((ele,i)=>i != index)
if(ballObj.life === 0){
this.gameBg.removeChild(ballObj.ball)
let ind = this.ballerArray.indexOf(ballObj)
this.ballerArray = this.ballerArray.filter((ele,i)=>i != ind)
boom.x = ballObj.ball.x;
boom.y = ballObj.ball.y;
this.gameBg.addChild(boom)
setTimeout(() => {
this.gameBg.removeChild(boom);
}, 1500);
}
}
}
}
}
},20)
}
stop(){}
onDown(e){
this.mouseX = e.localX
this.mouseY = e.localY
this.stage.addEventListener(engine.MouseEvent.MOUSE_MOVE,this.onMove,this)
this.planeModel.x = e.stageX - this.mouseX;
this.planeCenterX = this.planeModel.x + this.planeModel.width / 2;
}
onMove(e:engine.MouseEvent){
// 以图片中心为准
this.centerX = this.planeModel.width / 2;
let movedCenter = this.centerX + e.stageX - this.mouseX;
if(movedCenter < 0){
this.planeModel.x = -this.centerX;
} else if(movedCenter >750){
this.planeModel.x = 750 - this.centerX;
} else {
this.planeModel.x = e.stageX - this.mouseX;
this.planeCenterX = this.planeModel.x + this.planeModel.width / 2;
// console.log(e.stageX,e.stageY)
}
}
onClick(){
this.addChild(this.gameBg);
this.gameBg.addChild(this.planeModel)
}
shoot(w){
setInterval(()=>{
let bullet = new engine.Sprite(getTexture('18852543-1f1d-498b-af64-88cd3b343758'));
bullet.x = this.planeModel.x && this.planeModel.x + this.centerX - this.bullet.width / 2 + w || 375 - this.bullet.width / 2 + w;
bullet.y = 1150
this.gameBg.addChild(bullet)
this.bullet.y = this.bullet.y - 40;
let timeid = setInterval(()=>{
bullet.y = bullet.y - 40;
if(bullet.y < -40){
this.gameBg.removeChild(bullet)
clearInterval(timeid)
}
},1000/60)
},1000/60)
}
// ball:engine.Sprite;
drop(){
let ball = new engine.Sprite(getTexture('780b6b63-3abd-4246-94ba-2a3fbdb3c5af'));
ball.x = Math.random() * (750 - ball.width ) + ball.width;
ball.y = Math.random() * (ball.height)
this.gameBg.addChild(ball)
setInterval(()=>{
ball.y += 1;
if(ball.y > this.stage.height){
this.gameBg.removeChild(ball)
}
},50)
}
}
\ No newline at end of file
import GameView from "./GameView";
import { injectProps } from "../props";
import TestView from './TestView'
export class GameWrapper extends engine.Container{
private _gameView:GameView
private _testView:TestView
constructor(){
super();
engine.globalEvent.addEventListener('pictures-start', this.start, this);
engine.globalEvent.addEventListener('pictures-stop', this.stop, this);
//创建实例
// let gameView = this._gameView = new GameView();
// this.addChild(gameView);
let testView = this._testView = new TestView();
this.addChild(testView);
}
// start(event: engine.Event) {
// injectProps(event.data);
// // this._status = 1;
// this._gameView.start();
// }
// stop(event: engine.Event) {
// this._gameView.stop();
// }
start(event: engine.Event) {
injectProps(event.data);
// this._status = 1;
this._testView.start();
}
stop(event: engine.Event) {
this._testView.stop();
}
}
\ No newline at end of file
import Ball from "./Ball";
import { getTexture } from "./utils";
export class SmallPlane extends Ball{
_life:number = 3;
smallPlane = new engine.Sprite(getTexture('57d4067e-c32f-4b12-a8fc-185753726fc6'))
constructor(){
super()
this.life = 3;
this.name = "smallBall"
this.addChild(this.smallPlane)
}
setPosition(){
this.x = Math.random() * (750 - this.width)
this.y = Math.random() * (this.height)
}
died(){
}
}
\ No newline at end of file
import {getTexture} from './utils'
import { SmallPlane } from './SmallBall'
import {Bullets} from './Bullets'
export default class TestView extends engine.Container{
startBtn:engine.Sprite
stageBg: engine.Sprite;
gameBg: engine.Sprite;
planeModel:engine.Sprite;
constructor(){
super()
this.once(engine.Event.ADDED_TO_STAGE, this.setup, this);
}
setup(){
this.stageBg = new engine.Sprite(getTexture('308742a0-0ea2-4610-b34a-a230add82021'))
this.addChild(this.stageBg)
this.gameBg = new engine.Sprite(getTexture('76820072-df5a-4ab7-8cb7-10c8cd8605c8'))
// 开始按钮
this.startBtn = new engine.Sprite(getTexture('855e3d77-ffff-443d-b884-4f67a2ebe458'))
this.startBtn.x = (750 - this.startBtn.width) / 2;
this.startBtn.y = (this.stage.height - this.startBtn.height) / 2 + 300;
this.stageBg.addChild(this.startBtn)
this.startBtn.addEventListener(engine.MouseEvent.CLICK,this.onClick,this)
}
smallBall:SmallPlane
planeArray:[
{
type:string,
enemyPlane:Array<any>
},
{
type:string,
enemyPlane:Array<any>
},
{
type:string,
enemyPlane:Array<any>
}
] = [
{
type:'smallBall',
enemyPlane:[]
},
{
type:'middleBall',
enemyPlane:[]
},
{
type:'largeBall',
enemyPlane:[]
}
]
bulletArray:any[] = []
score:number = 0;
start(){
// 炮车
this.planeModel = new engine.Sprite(getTexture('32ec481a-3f75-4c36-95ed-ee97aa936517'))
this.planeModel.x = (750 - this.planeModel.width) / 2;
this.planeModel.y = (this.stage.height - this.planeModel.height)
this.planeModel.addEventListener(engine.MouseEvent.MOUSE_DOWN,this.onDown,this)
this.gameBg.addChild(this.planeModel)
let boom = new engine.Sprite(getTexture('38ec6627-efa8-4f7a-9bdc-3c73cea717f1'))
//敌机
setInterval(()=>{
let smallBall = new SmallPlane();
smallBall.setPosition();
console.log(this.planeArray);
for(let planearray of this.planeArray){
if(planearray.type == smallBall.name){
console.log(planearray.enemyPlane)
planearray.enemyPlane.push(smallBall)
}
}
this.gameBg.addChild(smallBall)
},500)
// 敌机移动
setInterval(()=>{
for(let planearray of this.planeArray){
if(planearray.type === 'smallBall'){
for(let sball of planearray.enemyPlane){
console.log(sball)
sball.y += 1;
if(sball.y > this.stage.height){
this.gameBg.removeChild(sball)
let index = planearray.enemyPlane.indexOf(sball)
planearray.enemyPlane = planearray.enemyPlane.filter((ele,i)=>i != index)
}
}
}
}
},16)
// my plane
setInterval(()=>{
let bullet = new Bullets();
bullet.createBullet(this.planeModel);
this.bulletArray.push(bullet)
this.gameBg.addChild(bullet)
},40)
setInterval(()=>{
console.log(this.score);
for(let bullet of this.bulletArray){
// console.log(bullet,123)
bullet.y -= 35;
if(bullet.y < -40){
this.gameBg.removeChild(bullet)
let index = this.bulletArray.indexOf(bullet)
this.bulletArray = this.bulletArray.filter((ele,i)=>i != index)
}
// 击中
for(let planearray of this.planeArray){
if(planearray.type === 'smallBall'){
for(let splane of planearray.enemyPlane){
let y = bullet.y - splane.y;
let bulletRight = bullet.x + bullet.width;
let planeRange = splane.x + splane.width
if(bulletRight > splane.x && bulletRight < planeRange || bullet.x > splane.x && bullet.x < planeRange){
if(y <= 0){
// 击中敌机
splane.life -= bullet.harm;
this.score += bullet.harm;
// 子弹移除
this.gameBg.removeChild(bullet);
let index = this.bulletArray.indexOf(bullet);
this.bulletArray = this.bulletArray.filter((ele,i)=>i != index)
if(splane.life === 0){
this.gameBg.removeChild(splane);
let ind = planearray.enemyPlane.indexOf(splane);
planearray.enemyPlane = planearray.enemyPlane.filter((ele,i)=>i!=ind)
boom.x = splane.x;
boom.y = splane.y;
this.gameBg.addChild(boom);
setTimeout(() => {
this.gameBg.removeChild(boom);
}, 1500);
}
}
}
}
}
}
}
},16)
}
onClick(){
this.addChild(this.gameBg);
this.gameBg.addChild(this.planeModel)
}
mouseX:number;
mouseY:number;
// 炮车宽度
centerX:number;
planeCenterX:number
onDown(e:engine.MouseEvent){
this.mouseX = e.localX
this.mouseY = e.localY
this.stage.addEventListener(engine.MouseEvent.MOUSE_MOVE,this.onMove,this)
this.planeModel.x = e.stageX - this.mouseX;
this.planeCenterX = this.planeModel.x + this.planeModel.width / 2;
}
onMove(e:engine.MouseEvent){
// 炮车移动范围
this.centerX = this.planeModel.width / 2;
let movedCenter = this.centerX + e.stageX - this.mouseX;
if(movedCenter < 0){
this.planeModel.x = -this.centerX;
} else if(movedCenter >750){
this.planeModel.x = 750 - this.centerX;
} else {
this.planeModel.x = e.stageX - this.mouseX;
this.planeCenterX = this.planeModel.x + this.planeModel.width / 2;
}
}
stop(){
}
}
\ No newline at end of file
/**
* Created by rockyl on 2020-01-21.
*/
export function getTexture(uuid) {
return engine.Texture.from(getAssetByUUID(uuid).uuid);
}
export function getTextureByName(name) {
return getTexture(engine.getAssetByName(name).uuid);
}
export function playSound(name) {
engine.playSound(engine.getAssetByName(name).uuid, {keep: true});
}
export function createSvga(name, anchorName?) {
let inst = new svga.Svga();
inst.source = 'asset://' + engine.getAssetByName(name).uuid;
return inst;
}
export function getIndexFromRC(row,col,maxCol){
let index;
index = row * maxCol + col ;
return index
}
export function getRandomArray(array){
array.sort(function() {
return .5 - Math.random();
});
}
\ No newline at end of file
import {GameWrapper} from "./game/GameWrapper";
import {injectProps, prepareProps} from "./props";
export default function (props) {
prepareProps();
injectProps(props);
let instance = new GameWrapper();
return instance;
}
/**
* Created by rockyl on 2020-01-21.
*/
export let props: any = {};
export function prepareProps() {
let metaProps = getProps();
engine.injectProp(props, metaProps);
}
export function injectProps(p) {
engine.injectProp(props, p);
}
/**
* Created by renjianfeng on 2020-03-13.
*/
const customId = 'rounds-pic';
(async function () {
let customModule = await fetch(`../meta.json`);
customModule = await customModule.json();
console.log(customModule);
await loadAssets(customModule.assets);
launchWithCustomModule(customModule);
})();
function launchWithCustomModule(customModule) {
//engine.registerCustomCodeModule(customModule);
engine.registerCustomModule(customId, window[customId]);
const { props: propsOption, assets } = customModule;
let props = engine.computeProps(customModuleProps, propsOption);
const customModuleIns = {
id: customId,
props,
assets,
};
engine.registerCustomModules([customModuleIns]);
engine.launchWithConfig({
options: {
entrySceneView: 'entry',
},
assets: [],
views: [{
name: 'entry',
type: 'node',
properties: {
x: 0,
y: 0,
}
}],
customs: [],
}, null, function () {
setTimeout(() => {
engine.addCustomModule(customId, engine.gameStage.sceneContainer.getChildAt(0));
}, 100);
setTimeout(() => {
engine.globalEvent.dispatchEvent('pictures-start', {
picUrl: "http://yun.duiba.com.cn/aurora/assets/e1593b97c27077b85b92f7eaaeae1ed64a1eb79a.png",
blockUrl: "888",
GAME_TIME:30,
MAX_ROW:4,
MAX_COL:3,
W:618,
H:827,
GAP:0,
OFFSET_X:0,
OFFSET_Y:0
});
const d = engine.gameStage.sceneContainer.getChildAt(0);
engine.gameStage.sceneContainer.getChildAt(0).x = (d.stage.width-props.W)/2;
engine.gameStage.sceneContainer.getChildAt(0).y = (d.stage.height-props.H)/2;
}, 1000);
setTimeout(() => {
engine.globalEvent.dispatchEvent('pictures-start', {
picUrl: "http://yun.duiba.com.cn/aurora/assets/e1593b97c27077b85b92f7eaaeae1ed64a1eb79a.png",
// picUrl: "http://yun.duiba.com.cn/aurora/assets/d23e73d37ec01931e48cbd0a4095367044c5675c.png",
blockUrl: "888"
});
}, 30*1000);
});
engine.globalEvent.addEventListener('pictures-time-update', (e) => {
// console.log(e.type, e.data);
});
engine.globalEvent.addEventListener('pictures-game-fail', (e) => {
console.log(e.type, e.data);
});
engine.globalEvent.addEventListener('pictures-game-success', (e) => {
console.log(e.type, e.data);
});
}
function getAssetByUUID(uuid) {
return engine.resolveCustomAsset(customId, uuid);
}
function getProps() {
return engine.getProps(customId);
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>美食从天而降</title>
<meta name="viewport"
content="width=device-width,initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no"/>
<meta name="apple-mobile-web-app-capable" content="yes"/>
<meta name="full-screen" content="true"/>
<meta name="screen-orientation" content="portrait"/>
<meta name="x5-fullscreen" content="true"/>
<meta name="360-fullscreen" content="true"/>
<style>
html,
body {
padding: 0;
margin: 0;
border: 0;
width: 100%;
height: 100%;
overflow: hidden;
position: absolute;
background-color: gray;
}
.game-container{
width: 100%;
height: 100%;
line-height:0;
font-size:0;
}
</style>
</head>
<body>
<div id="game-container" class="game-container"></div>
<script crossorigin="anonymous" src="//yun.duiba.com.cn/editor/zeroing/libs/engine.1de84ff79dba19e949088de63aa75af51a515e5c.js"></script>
<script crossorigin="anonymous" src="//yun.duiba.com.cn/editor/zeroing/libs/svga.fd3923ae6e664251ca7981801a65809cc5f36bc3.js"></script>
<!-- <script src="//yun.duiba.com.cn/editor/zeroing/libs/engine.ebc906f6b50b8da0a669f77027981d5f3cb560ce.js"></script> -->
<!-- <script src="http://localhost:4002/debug/engine.js"></script>
<script src="http://localhost:4003/debug/engine-svga.js"></script> -->
<!--<script src="//yun.duiba.com.cn/editor/zeroing/libs/engine.9a9dbfda4cb2dd5508ecddfe3d95dfd88063f7b5.js"></script>-->
<script src="app.js"></script>
<script src="props.js"></script>
<script src="load-assets.js"></script>
<script src="main.js"></script>
<script>
</script>
</body>
\ No newline at end of file
/**
* Created by rockyl on 2020-01-21.
*/
const assets = [
{
"name": "玩家icon",
"url": "//yun.duiba.com.cn/aurora/assets/5b3e30496b2d9fdafb0cf3835fd6704ce10e45b4.png",
"uuid": "888",
"ext": ".png"
},
{
"name": "雨滴",
"url": "//yun.duiba.com.cn/aurora/assets/8564c8c9be3aead71b05a0bab8d7d07ac3f778a1.png",
"uuid": "264a6192-d7bf-45e8-8f15-6ba2c439a532",
"ext": ".png"
},
{
"name": "炸弹",
"url": "//yun.duiba.com.cn/aurora/assets/171e92283cd13c013ee1b76d28d252ff08815d47.png",
"uuid": "eb88b42d-e151-4c1b-94b9-7c16f7bfac29",
"ext": ".png"
},
{
"name": "石块",
"url": "//yun.duiba.com.cn/aurora/assets/99b0af0c59fe79a415a3f032149cfacc27e3ac2c.png",
"uuid": "ab1bdabc-21ba-46bf-9299-6c638f766c88",
"ext": ".png"
},
{
"name": "水花",
"url": "//yun.duiba.com.cn/aurora/assets/93d37b4a0e367e80e375308a6b4414d72d7666fc.svga",
"uuid": "b521bf94-20e1-44dd-8eca-d24996cbaeae",
"ext": ".svga"
},
{
"name": "炸弹",
"url": "//yun.duiba.com.cn/aurora/assets/4dd18f0689c663bbcf710a7afc4d929084d97d36.svga",
"uuid": "322edf39-805b-4e84-9d07-5573dfeebc0e",
"ext": ".svga"
},
{
"name": "玩家",
"url": "//yun.duiba.com.cn/aurora/assets/b66300c5d4f27134b0aac3dc90a3220e8ae572eb.svga",
"uuid": "71d8dcbc-3931-471a-b585-b3ae01b25aa6",
"ext": ".svga"
}
];
function loadAssets(customModuleAssets, onProgress, onComplete){
return engine.loadAssets(assets.concat(...customModuleAssets), onProgress, onComplete);
}
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('tslib')) :
typeof define === 'function' && define.amd ? define(['tslib'], factory) :
(global = global || self, global['rounds-pic'] = factory(global.tslib));
}(this, (function (tslib) { 'use strict';
var props = {};
function prepareProps() {
var metaProps = getProps();
engine.injectProp(props, metaProps);
}
function injectProps(p) {
engine.injectProp(props, p);
}
//# sourceMappingURL=props.js.map
var qietu = (function (parent, url, MAX_COL, MAX_ROW) {
var W = props.W;
var H = props.H;
var GAP = props.GAP;
var spr = [];
var pos = [];
var _loop_1 = function (row) {
var _loop_2 = function (col) {
var child = new engine.Sprite();
child.scaleX = 1 / MAX_COL;
child.scaleY = 1 / MAX_ROW;
parent.addChild(child);
child.x = col * (W / MAX_COL + GAP);
child.y = row * (H / MAX_ROW + GAP);
pos.push([child.x, child.y]);
spr.push(child);
child.addEventListener(engine.Event.COMPLETE, function () {
var uvs = new Float32Array([
col / MAX_COL,
row / MAX_ROW,
(col + 1) / MAX_COL,
row / MAX_ROW,
(col + 1) / MAX_COL,
(row + 1) / MAX_ROW,
col / MAX_COL,
(row + 1) / MAX_ROW,
]);
child.uvs = uvs;
});
child.texture = engine.Texture.fromImage(url);
};
for (var col = 0; col < MAX_COL; col++) {
_loop_2(col);
}
};
for (var row = 0; row < MAX_ROW; row++) {
_loop_1(row);
}
console.log(spr);
return [spr, pos];
});
//# sourceMappingURL=qietu.js.map
function getIndexFromRC(row, col, maxCol) {
var index;
index = row * maxCol + col;
return index;
}
function getRandomArray(array) {
array.sort(function () {
return 0.5 - Math.random();
});
}
var MAX_COL;
var MAX_ROW;
var W;
var H;
var GAP;
var GAME_TIME;
var w;
var h;
var picUrl;
var GameView = (function (_super) {
tslib.__extends(GameView, _super);
function GameView() {
var _this = _super.call(this) || this;
_this._timeCounter = 0;
_this._result = [];
_this.listenStageOn = 1;
_this.once(engine.Event.ADDED_TO_STAGE, _this.setup, _this);
return _this;
}
GameView.prototype.start = function () {
var _this = this;
picUrl = props.picUrl;
MAX_COL = props.MAX_COL;
MAX_ROW = props.MAX_ROW;
GAME_TIME = props.GAME_TIME;
W = props.W;
H = props.H;
GAP = props.GAP;
w = W / MAX_COL;
h = H / MAX_ROW;
console.log('on start');
engine.globalEvent.dispatchEvent('pictures-time-update', {
second: this.getSecond(),
});
if (this._result.length !== 0) {
this._result = [];
}
this._result = qietu(this.picturesWrapper, picUrl, MAX_COL, MAX_ROW);
this.pictures = this._result[0];
if (this.rightList !== null) {
this.rightList = [];
}
this.rightList = this.pictures.concat([]);
var posList = this._result[1];
getRandomArray(this.pictures);
var i = 0;
var len;
len = this.pictures.length;
for (; i < len; i++) {
this.dragPic = this.pictures[i];
this.pictures[i].addEventListener(engine.MouseEvent.MOUSE_DOWN, this.onDown, this);
var _a = posList[i], x = _a[0], y = _a[1];
this.dragPic.x = x;
this.dragPic.y = y;
}
this._timer = setInterval(function () {
_this.onTimer();
}, 10);
this.date = new Date().getTime();
};
GameView.prototype.onTimer = function () {
var date = new Date().getTime();
var gap = ((date - this.date) / 1000);
this.date = date;
GAME_TIME -= gap;
if (GAME_TIME < 0) {
GAME_TIME = 0;
}
GAME_TIME = this.afterPointTwo(GAME_TIME);
GAME_TIME = GAME_TIME.toFixed(2);
if (GAME_TIME < 10) {
GAME_TIME = '0' + GAME_TIME;
}
engine.globalEvent.dispatchEvent('pictures-time-update', {
second: this.getSecond(),
});
if (this.getSecond() == 0) {
this.stop();
engine.globalEvent.dispatchEvent('pictures-game-fail', {
reason: 1
});
this.stage.removeEventListener(engine.MouseEvent.MOUSE_UP, this.stageOnUp, this);
}
};
GameView.prototype.afterPointTwo = function (n) {
var floatN = parseFloat(n);
if (isNaN(floatN)) {
return;
}
floatN = Math.round(floatN * 100) / 100;
return floatN;
};
GameView.prototype.getSecond = function () {
return GAME_TIME;
};
GameView.prototype.stop = function () {
GAME_TIME = props.GAME_TIME;
clearInterval(this._timer);
var len = this.pictures.length;
for (var i = 0; i < len; i++) {
this.pictures[i].removeAllEventListener();
}
};
GameView.prototype.createRects = function () { };
GameView.prototype.setup = function () {
console.log('onSteup', props);
var parent = new engine.Sprite();
this.picturesWrapper = parent;
this.addChild(parent);
};
GameView.prototype.onDown = function (e) {
var stageLeft = (750 - props.W) / 2;
var stageTop = (this.stage.height - props.H) / 2;
this.dragPic = e.target;
this.picturesWrapper.addChild(this.dragPic);
this.localPicX = e.localX / MAX_COL;
this.localPicY = e.localY / MAX_ROW;
this.distanceX = this.dragPic.x;
this.distanceY = this.dragPic.y;
this.indexJ = Math.floor((this.distanceX) / (w + GAP));
this.indexI = Math.floor((this.distanceY) / (h + GAP));
this.index = (this.indexI) * MAX_COL + this.indexJ;
this.centerX = Math.floor((e.clientX - stageLeft) / w) * w + w / 2;
this.centerY = Math.floor((e.clientY - stageTop) / h) * h + h / 2;
this.stage.addEventListener(engine.MouseEvent.MOUSE_MOVE, this.onMove, this);
this.stage.addEventListener(engine.MouseEvent.MOUSE_UP, this.stageOnUp, this);
};
GameView.prototype.stageOnUp = function (e) {
var stageLeft = (750 - props.W) / 2;
var stageTop = (this.stage.height - props.H) / 2;
this.stage.removeEventListener(engine.MouseEvent.MOUSE_MOVE, this.onMove, this);
this.stage.removeEventListener(engine.MouseEvent.MOUSE_UP, this.stageOnUp, this);
if (this.centerY < stageTop || this.centerX < stageLeft) {
this.dragPic.x = this.distanceX;
this.dragPic.y = this.distanceY;
}
var curJ = Math.floor(this.centerX / (w + GAP));
var curI = Math.floor(this.centerY / (h + GAP));
if (0 <= curJ && curJ < (MAX_COL) && 0 <= curI && curI < (MAX_ROW)) {
var index = getIndexFromRC(curI, curJ, MAX_COL);
var dropPic = this.pictures[index];
var dropPicX = dropPic.x + stageLeft;
var dropPicy = dropPic.y + stageTop;
dropPic.x = this.distanceX;
dropPic.y = this.distanceY;
this.dragPic.x = dropPicX - stageLeft;
this.dragPic.y = dropPicy - stageTop;
var dropPicIndex = this.pictures.indexOf(dropPic);
var dragPicIndex = this.pictures.indexOf(this.dragPic);
this.pictures[dropPicIndex] = this.dragPic;
this.pictures[dragPicIndex] = dropPic;
if (dragPicIndex === dropPicIndex) {
this.dragPic.x = this.distanceX;
this.dragPic.y = this.distanceY;
}
var result = true;
for (var j = 0; j < this.rightList.length; j++) {
if (this.rightList[j] != this.pictures[j]) {
result = false;
break;
}
}
if (result) {
this.onSuccess();
}
}
else {
this.dragPic.x = this.distanceX;
this.dragPic.y = this.distanceY;
}
};
GameView.prototype.onSuccess = function () {
console.log('拼图成功!');
engine.globalEvent.dispatchEvent('pictures-game-success', { time: GAME_TIME });
this.stop();
props.GAME_TIME *= 0.9;
++props.MAX_ROW;
++props.MAX_COL;
};
GameView.prototype.onMove = function (e) {
this.dragPic.x = e.stageX - this.localPicX - (750 - props.W) / 2;
this.dragPic.y = e.stageY - this.localPicY - (this.stage.height - props.H) / 2;
this.centerX = this.dragPic.x + w / 2;
this.centerY = this.dragPic.y + h / 2;
};
return GameView;
}(engine.Container));
//# sourceMappingURL=GameView.js.map
var GameWrapper = (function (_super) {
tslib.__extends(GameWrapper, _super);
function GameWrapper() {
var _this = _super.call(this) || this;
engine.globalEvent.addEventListener('pictures-start', _this.start, _this);
engine.globalEvent.addEventListener('pictures-stop', _this.stop, _this);
var gameView = _this._gameView = new GameView();
_this.addChild(gameView);
return _this;
}
GameWrapper.prototype.start = function (event) {
injectProps(event.data);
this._gameView.start();
};
GameWrapper.prototype.stop = function (event) {
this._gameView.stop();
};
return GameWrapper;
}(engine.Container));
//# sourceMappingURL=GameWrapper.js.map
function index (props) {
prepareProps();
injectProps(props);
var instance = new GameWrapper();
return instance;
}
//# sourceMappingURL=index.js.map
return index;
})));
//# sourceMappingURL=main.js.map
\ No newline at end of file
{"version":3,"file":"index.js","sources":["src/custom/rounds-pic/src/props.ts","src/custom/rounds-pic/src/game/qietu.ts","src/custom/rounds-pic/src/game/utils.ts","src/custom/rounds-pic/src/game/GameView.ts","src/custom/rounds-pic/src/game/GameWrapper.ts","src/custom/rounds-pic/src/index.ts"],"sourcesContent":["/**\r\n * Created by rockyl on 2020-01-21.\r\n */\r\n\r\nexport let props: any = {};\r\n\r\nexport function prepareProps() {\r\n\tlet metaProps = getProps();\r\n\r\n\tengine.injectProp(props, metaProps);\r\n}\r\n\r\nexport function injectProps(p) {\r\n\tengine.injectProp(props, p);\r\n}\r\n","import { props } from \"../props\";\r\nconst urls = [];\r\nconst picMap = {};\r\nconst posMap = {};\r\nexport default (parent, url, MAX_COL, MAX_ROW) => {\r\n // if (picMap[url]) {\r\n // const pics:any[] = picMap[url];\r\n // for (const pic of pics) {\r\n // parent.addChild(pic);\r\n // }\r\n // return [picMap[url], posMap[url]]\r\n // }\r\n\r\n const W = props.W;\r\n const H = props.H;\r\n const GAP = props.GAP;\r\n\r\n const spr = [];\r\n const pos = []\r\n\r\n for (let row = 0; row < MAX_ROW; row++) {\r\n for (let col = 0; col < MAX_COL; col++) {\r\n\r\n const child = new engine.Sprite(); \r\n // spr.push(child);\r\n\r\n child.scaleX = 1 / MAX_COL;\r\n child.scaleY = 1 / MAX_ROW;\r\n parent.addChild(child);\r\n child.x = col * (W / MAX_COL + GAP);\r\n child.y = row * (H / MAX_ROW + GAP);\r\n pos.push([child.x, child.y]);\r\n spr.push(child);\r\n child.addEventListener(engine.Event.COMPLETE, () => {\r\n const uvs = new Float32Array([\r\n col / MAX_COL,\r\n row / MAX_ROW,\r\n (col + 1) / MAX_COL,\r\n row / MAX_ROW,\r\n (col + 1) / MAX_COL,\r\n (row + 1) / MAX_ROW,\r\n col / MAX_COL,\r\n (row + 1) / MAX_ROW,\r\n ]);\r\n\r\n child.uvs = uvs;\r\n });\r\n\r\n child.texture = engine.Texture.fromImage(url);\r\n }\r\n }\r\n // picMap[url] = spr.concat([]);\r\n // posMap[url] = pos.concat([]);\r\n console.log(spr);\r\n return [spr, pos];\r\n};\r\n","/**\r\n * Created by rockyl on 2020-01-21.\r\n */\r\nimport {props} from '../props'\r\nexport function getTexture(uuid) {\r\n return engine.Texture.from(getAssetByUUID(uuid).uuid);\r\n}\r\n\r\nexport function getTextureByName(name) {\r\n return getTexture(engine.getAssetByName(name).uuid);\r\n}\r\n\r\nexport function playSound(name) {\r\n engine.playSound(engine.getAssetByName(name).uuid, { keep: true });\r\n}\r\nexport function createSvga(name, anchorName?) {\r\n let inst = new svga.Svga();\r\n inst.source = \"asset://\" + engine.getAssetByName(name).uuid;\r\n return inst;\r\n}\r\n\r\nexport function getIndexFromRC(row, col, maxCol) {\r\n let index;\r\n index = row * maxCol + col;\r\n return index;\r\n}\r\n\r\nexport function getRandomArray(array) {\r\n array.sort(function () {\r\n return 0.5 - Math.random();\r\n });\r\n}\r\n\r\n","/**\r\n * Created by rockyl on 2018/8/16.\r\n */\r\n\r\nimport { props } from \"../props\";\r\nimport qietu from \"./qietu\";\r\nimport { getIndexFromRC, getRandomArray, getTexture } from \"./utils\";\r\nimport ObjectPool = engine.ObjectPool;\r\n\r\n// let OFFSET_X;\r\n// let OFFSET_Y;\r\nlet MAX_COL;\r\nlet MAX_ROW;\r\nlet W;\r\nlet H;\r\nlet GAP;\r\nlet GAME_TIME;\r\n// 每张图片宽\r\nlet w;\r\n// 每张图片高\r\nlet h;\r\n// 图片\r\nlet picUrl\r\n\r\nexport default class GameView extends engine.Container {\r\n private _timer;\r\n private _timeCounter = 0;\r\n private _result = []\r\n private date\r\n\r\n \r\n\r\n start() {\r\n picUrl = props.picUrl;\r\n MAX_COL = props.MAX_COL;\r\n MAX_ROW = props.MAX_ROW;\r\n GAME_TIME = props.GAME_TIME;\r\n // OFFSET_X = props.OFFSET_X;\r\n // OFFSET_Y = props.OFFSET_Y;\r\n W = props.W;\r\n H = props.H;\r\n GAP = props.GAP;\r\n // 每张图片宽\r\n w = W / MAX_COL;\r\n // 每张图片高\r\n h = H / MAX_ROW;\r\n\r\n \r\n // if (!this.guideHole) {\r\n // this.guideHole = new engine.Image();\r\n // this.guideHole.source = 'asset://' + props.blockUrl;\r\n // this.guideHole.mouseChildren = this.guideHole.mouseEnabled = false;\r\n // }\r\n\r\n // if (this.pictures) {\r\n // for (const pic of this.pictures) {\r\n // if (pic && pic.parent)\r\n // pic.parent.removeChild(pic);\r\n // }\r\n // }\r\n\r\n console.log('on start')\r\n engine.globalEvent.dispatchEvent('pictures-time-update', {\r\n second: this.getSecond(),\r\n });\r\n\r\n // 图片一维数组\r\n if(this._result.length !==0){\r\n this._result = []\r\n }\r\n\r\n this._result = qietu(this.picturesWrapper, picUrl, MAX_COL, MAX_ROW);\r\n // this.picturesWrapper.addChild(this.guideHole);\r\n\r\n // console.log(this.picturesWrapper)\r\n\r\n this.pictures = this._result[0];\r\n if(this.rightList !== null){\r\n this.rightList = []\r\n }\r\n this.rightList = this.pictures.concat([]);\r\n const posList = this._result[1];\r\n getRandomArray(this.pictures);\r\n\r\n let i = 0;\r\n let len;\r\n len = this.pictures.length;\r\n\r\n\r\n for (; i < len; i++) {\r\n this.dragPic = this.pictures[i];\r\n this.pictures[i].addEventListener(\r\n engine.MouseEvent.MOUSE_DOWN,\r\n this.onDown,\r\n this\r\n );\r\n const [x, y] = posList[i];\r\n this.dragPic.x = x;\r\n this.dragPic.y = y;\r\n\r\n }\r\n\r\n this._timer = setInterval(() => {\r\n this.onTimer();\r\n }, 10)\r\n\r\n this.date = new Date().getTime();\r\n\r\n }\r\n\r\n onTimer() {\r\n\r\n let date = new Date().getTime();\r\n\r\n let gap = ((date - this.date) / 1000);\r\n this.date = date;\r\n // console.log(gap,\"gap\");\r\n\r\n // 以GAME_TIME为标准\r\n GAME_TIME -= gap;\r\n if(GAME_TIME < 0){\r\n GAME_TIME = 0;\r\n }\r\n GAME_TIME = this.afterPointTwo(GAME_TIME);\r\n GAME_TIME = GAME_TIME.toFixed(2);\r\n if (GAME_TIME < 10) {\r\n GAME_TIME = '0' + GAME_TIME\r\n }\r\n // console.log(GAME_TIME);\r\n\r\n\r\n engine.globalEvent.dispatchEvent('pictures-time-update', {\r\n second: this.getSecond(),\r\n });\r\n\r\n if (this.getSecond() == 0) {\r\n this.stop();\r\n engine.globalEvent.dispatchEvent('pictures-game-fail', {\r\n reason: 1\r\n });\r\n\r\n this.stage.removeEventListener(\r\n engine.MouseEvent.MOUSE_UP,\r\n this.stageOnUp,\r\n this\r\n );\r\n\r\n }\r\n }\r\n\r\n afterPointTwo(n) {\r\n\r\n var floatN = parseFloat(n);\r\n if (isNaN(floatN)) {\r\n return;\r\n }\r\n floatN = Math.round(floatN * 100) / 100;\r\n return floatN;\r\n\r\n }\r\n\r\n getSecond() {\r\n return GAME_TIME\r\n }\r\n\r\n stop() {\r\n \r\n GAME_TIME = props.GAME_TIME\r\n clearInterval(this._timer);\r\n let len = this.pictures.length;\r\n for(let i=0;i<len;i++){\r\n this.pictures[i].removeAllEventListener();\r\n }\r\n }\r\n\r\n constructor() {\r\n super();\r\n this.once(engine.Event.ADDED_TO_STAGE, this.setup, this);\r\n }\r\n\r\n //当前图片对象\r\n dragPic;\r\n // 鼠标在当前图片上的位置\r\n localPicX;\r\n localPicY;\r\n // 拖动的图片最开始的位置(左上角为准)\r\n distanceX;\r\n distanceY;\r\n // 图片中心的位置\r\n centerX: number;\r\n centerY: number;\r\n\r\n pictures: engine.Sprite[];\r\n\r\n // 点击图片时的一维数组索引\r\n index;\r\n // 计算目标图片行和列的位置\r\n indexI: number;\r\n indexJ: number;\r\n rightList: engine.Sprite[];\r\n\r\n private picturesWrapper: engine.Sprite;\r\n private guideHole: engine.Image;\r\n\r\n createRects() { }\r\n setup() {\r\n\r\n \r\n\r\n console.log('onSteup', props);\r\n\r\n const parent = new engine.Sprite();\r\n this.picturesWrapper = parent;\r\n this.addChild(parent);\r\n\r\n // this.picturesWrapper.x = OFFSET_X;\r\n // this.picturesWrapper.y = OFFSET_Y;\r\n\r\n // 添加按钮\r\n // const btn = new engine.Rect();\r\n // btn.width = 200;\r\n // btn.height = 100;\r\n // btn.stage.top = 1000;\r\n // btn.stage.left = 350;\r\n // btn.fillColor = 'cyan';\r\n // this.addChild(btn)\r\n\r\n // btn.addEventListener(engine.MouseEvent.CLICK,this.onClk,this)\r\n\r\n }\r\n\r\n onDown(e: engine.MouseEvent) {\r\n // console.log(e);\r\n\r\n let stageLeft = (750 - props.W) / 2\r\n let stageTop = (this.stage.height - props.H) / 2;\r\n\r\n // 创建一个图片对象接收当前位置信息\r\n this.dragPic = e.target;\r\n this.picturesWrapper.addChild(this.dragPic);\r\n\r\n\r\n // 鼠标的偏移量\r\n this.localPicX = e.localX / MAX_COL;\r\n this.localPicY = e.localY / MAX_ROW;\r\n\r\n // 最开始图片的位置\r\n this.distanceX = this.dragPic.x ;\r\n this.distanceY = this.dragPic.y;\r\n\r\n // 最开始点击的图片的索引值\r\n\r\n this.indexJ = Math.floor((this.distanceX) / (w + GAP));\r\n this.indexI = Math.floor((this.distanceY) / (h + GAP));\r\n this.index = (this.indexI) * MAX_COL + this.indexJ;\r\n\r\n\r\n // this.centerX = Math.floor(e.clientX / w) * w + w / 2;\r\n // this.centerY = Math.floor(e.clientY / h) * h + h / 2;\r\n\r\n this.centerX = Math.floor((e.clientX - stageLeft) / w) * w + w / 2;\r\n this.centerY = Math.floor((e.clientY - stageTop) / h) * h + h / 2;\r\n\r\n this.stage.addEventListener(\r\n engine.MouseEvent.MOUSE_MOVE,\r\n this.onMove,\r\n this\r\n );\r\n this.stage.addEventListener(\r\n engine.MouseEvent.MOUSE_UP,\r\n this.stageOnUp,\r\n this\r\n );\r\n\r\n }\r\n\r\n listenStageOn = 1;\r\n\r\n stageOnUp(e) {\r\n\r\n let stageLeft = (750 - props.W) / 2\r\n let stageTop = (this.stage.height - props.H) / 2;\r\n\r\n this.stage.removeEventListener(\r\n engine.MouseEvent.MOUSE_MOVE,\r\n this.onMove,\r\n this\r\n );\r\n\r\n this.stage.removeEventListener(\r\n engine.MouseEvent.MOUSE_UP,\r\n this.stageOnUp,\r\n this\r\n );\r\n\r\n // 拖动的图片的中心位置在图片之外,回到原来的位置\r\n if (this.centerY < stageTop || this.centerX < stageLeft) {\r\n this.dragPic.x = this.distanceX ;\r\n this.dragPic.y = this.distanceY ;\r\n }\r\n\r\n // 判断图片是否进入另一张图片的范围内\r\n // 要交换的图片第几行第几列\r\n let curJ = Math.floor(this.centerX / (w + GAP));\r\n let curI = Math.floor(this.centerY / (h + GAP));\r\n\r\n // this.picturesWrapper.addChild(this.guideHole);\r\n\r\n\r\n\r\n // 点击图片的位置\r\n\r\n if ( 0 <= curJ && curJ < (MAX_COL) && 0 <= curI && curI < (MAX_ROW)) {\r\n\r\n // 获取交互图片的索引值\r\n let index = getIndexFromRC(curI, curJ, MAX_COL);\r\n // console.log(index);\r\n\r\n //要交换的图片\r\n let dropPic = this.pictures[index];\r\n\r\n let dropPicX = dropPic.x + stageLeft;\r\n let dropPicy = dropPic.y + stageTop;\r\n\r\n dropPic.x = this.distanceX;\r\n dropPic.y = this.distanceY;\r\n\r\n this.dragPic.x = dropPicX - stageLeft;\r\n this.dragPic.y = dropPicy - stageTop;\r\n\r\n // 交换之后索引也需要交换\r\n\r\n const dropPicIndex = this.pictures.indexOf(dropPic);\r\n const dragPicIndex = this.pictures.indexOf(this.dragPic);\r\n\r\n this.pictures[dropPicIndex] = this.dragPic;\r\n this.pictures[dragPicIndex] = dropPic;\r\n\r\n // 图片中心还是在原来的位置\r\n if (dragPicIndex === dropPicIndex) {\r\n this.dragPic.x = this.distanceX\r\n this.dragPic.y = this.distanceY\r\n }\r\n\r\n let result = true;\r\n for (let j = 0; j < this.rightList.length; j++) {\r\n if (this.rightList[j] != this.pictures[j]) {\r\n result = false;\r\n break;\r\n }\r\n }\r\n\r\n if (result) {\r\n this.onSuccess();\r\n\r\n }\r\n } else {\r\n this.dragPic.x = this.distanceX\r\n this.dragPic.y = this.distanceY\r\n }\r\n\r\n }\r\n\r\n private onSuccess() {\r\n console.log('拼图成功!');\r\n engine.globalEvent.dispatchEvent('pictures-game-success', { time: GAME_TIME });\r\n this.stop();\r\n props.GAME_TIME *= 0.9;\r\n ++props.MAX_ROW ;\r\n ++props.MAX_COL ;\r\n\r\n }\r\n\r\n onMove(e: engine.MouseEvent) {\r\n // 当前图片的位置\r\n this.dragPic.x = e.stageX - this.localPicX - (750 - props.W) / 2;\r\n this.dragPic.y = e.stageY - this.localPicY - (this.stage.height - props.H) / 2;\r\n\r\n // 当前图片的中心位置\r\n this.centerX = this.dragPic.x + w / 2;\r\n this.centerY = this.dragPic.y + h / 2;\r\n }\r\n\r\n // onClk(e){\r\n // // 重置时间\r\n // this._timeCounter = 0;\r\n // //重置图片顺序\r\n // }\r\n\r\n\r\n}\r\n","/**\r\n * Created by rockyl on 2020-01-09.\r\n */\r\n\r\nimport GameView from \"./GameView\";\r\nimport { injectProps } from \"../props\";\r\n\r\n\r\nexport class GameWrapper extends engine.Container {\r\n\t// private _status;\r\n\tprivate _gameView: GameView;\r\n\r\n\tconstructor() {\r\n\t\tsuper();\r\n\r\n\t\tengine.globalEvent.addEventListener('pictures-start', this.start, this);\r\n\t\tengine.globalEvent.addEventListener('pictures-stop', this.stop, this);\r\n\r\n\t\t//创建实例\r\n\t\tlet gameView = this._gameView = new GameView();\r\n\t\tthis.addChild(gameView);\r\n\r\n\t}\r\n\r\n\tstart(event: engine.Event) {\r\n\t\tinjectProps(event.data);\r\n\r\n\t\t\r\n\t\t// this._status = 1;\r\n\r\n\t\tthis._gameView.start();\r\n\t}\r\n\tstop(event: engine.Event) {\r\n\t\t\r\n\t\tthis._gameView.stop();\r\n\t}\r\n}\r\n","/**\r\n * Created by rockyl on 2019-11-20.\r\n */\r\n\r\nimport {GameWrapper} from \"./game/GameWrapper\";\r\nimport {injectProps, prepareProps} from \"./props\";\r\n\r\nexport default function (props) {\r\n\tprepareProps();\r\n\tinjectProps(props);\r\n\r\n\tlet instance = new GameWrapper();\r\n\t\r\n\treturn instance;\r\n}\r\n"],"names":["__extends"],"mappings":";;;;;;CAIO,IAAI,KAAK,GAAQ,EAAE,CAAC;UAEX,YAAY;KAC3B,IAAI,SAAS,GAAG,QAAQ,EAAE,CAAC;KAE3B,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;CACrC,CAAC;UAEe,WAAW,CAAC,CAAC;KAC5B,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;CAC7B,CAAC;;;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,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;SACtC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;MACvC;KASH,eAAC;CAAD,CAAC,CA9WqC,MAAM,CAAC,SAAS,GA8WrD;;;CC9XD;KAAiCA,qCAAgB;KAIhD;SAAA,YACC,iBAAO,SASP;SAPA,MAAM,CAAC,WAAW,CAAC,gBAAgB,CAAC,gBAAgB,EAAE,KAAI,CAAC,KAAK,EAAE,KAAI,CAAC,CAAC;SACxE,MAAM,CAAC,WAAW,CAAC,gBAAgB,CAAC,eAAe,EAAE,KAAI,CAAC,IAAI,EAAE,KAAI,CAAC,CAAC;SAGtE,IAAI,QAAQ,GAAG,KAAI,CAAC,SAAS,GAAG,IAAI,QAAQ,EAAE,CAAC;SAC/C,KAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;;MAExB;KAED,2BAAK,GAAL,UAAM,KAAmB;SACxB,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;SAKxB,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;MACvB;KACD,0BAAI,GAAJ,UAAK,KAAmB;SAEvB,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;MACtB;KACF,kBAAC;CAAD,CAAC,CA5BgC,MAAM,CAAC,SAAS,GA4BhD;;;iBC7BwB,KAAK;KAC7B,YAAY,EAAE,CAAC;KACf,WAAW,CAAC,KAAK,CAAC,CAAC;KAEnB,IAAI,QAAQ,GAAG,IAAI,WAAW,EAAE,CAAC;KAEjC,OAAO,QAAQ,CAAC;CACjB,CAAC;;;;;;;;;"}
\ No newline at end of file
/**
* Created by rockyl on 2020-01-21.
*/
let customModuleProps = {
};
{
"name": "拼图",
"desc": "拼图模块1.0",
"props": {
"MAX_COL": {
"alias": "图片分成几列",
"type": "number",
"default": 3
},
"MAX_ROW": {
"alias": "图片分成几行",
"type": "number",
"default": 4
},
"W": {
"alias": "图片的宽度",
"type": "number",
"default": 618
},
"H": {
"alias": "图片的高度",
"type": "number",
"default": 827
},
"OFFSET_X": {
"alias": "OFFSET_X",
"type": "number",
"default": 0
},
"OFFSET_Y": {
"alias": "OFFSET_Y",
"type": "number",
"default": 0
},
"GAME_TIME": {
"alias": "游戏时间",
"type": "number",
"default": 30
},
"GAP": {
"alias": "图片间隙",
"type": "number",
"default": 0
}
},
"assets": [
{
"name": "遮罩",
"url": "//yun.duiba.com.cn/aurora/assets/5b3e30496b2d9fdafb0cf3835fd6704ce10e45b4.png",
"uuid": "888",
"ext": ".png"
}
],
"events": {
"in": {
"pictures-start": {
"alias": "开始",
"data": {
"picUrl":"图片路径",
"blockUrl":"blockUrl",
"GAME_TIME":"每局的游戏时间",
"MAX_ROW":"行",
"MAX_COL":"列",
"W":"宽",
"H":"高",
"GAP":"图片间隙",
"OFFSET_X":"OFFSET_X",
"OFFSET_Y":"OFFSET_Y"
}
},
"pictures-stop": {
"alias": "停止"
}
},
"out": {
"pictures-time-update": {
"alias": "倒计时更新",
"data": {
"time":"剩余时间"
}
},
"pictures-game-fail": {
"alias": "游戏结束",
"data": {
"reason": "结束原因(1:时间到了)"
}
},
"pictures-game-success": {
"alias": "游戏成功",
"data": {
"time": "游戏消耗时间"
}
}
}
}
}
\ No newline at end of file
/**
* Created by rockyl on 2018/8/16.
*/
import { props } from "../props";
import qietu from "./qietu";
import { getIndexFromRC, getRandomArray, getTexture } from "./utils";
import ObjectPool = engine.ObjectPool;
// let OFFSET_X;
// let OFFSET_Y;
let MAX_COL;
let MAX_ROW;
let W;
let H;
let GAP;
let GAME_TIME;
// 每张图片宽
let w;
// 每张图片高
let h;
// 图片
let picUrl
export default class GameView extends engine.Container {
private _timer;
private _timeCounter = 0;
private _result = []
private date
start() {
picUrl = props.picUrl;
MAX_COL = props.MAX_COL;
MAX_ROW = props.MAX_ROW;
GAME_TIME = props.GAME_TIME;
// OFFSET_X = props.OFFSET_X;
// OFFSET_Y = props.OFFSET_Y;
W = props.W;
H = props.H;
GAP = props.GAP;
// 每张图片宽
w = W / MAX_COL;
// 每张图片高
h = H / MAX_ROW;
// if (!this.guideHole) {
// this.guideHole = new engine.Image();
// this.guideHole.source = 'asset://' + props.blockUrl;
// this.guideHole.mouseChildren = this.guideHole.mouseEnabled = false;
// }
// if (this.pictures) {
// for (const pic of this.pictures) {
// if (pic && pic.parent)
// pic.parent.removeChild(pic);
// }
// }
console.log('on start')
engine.globalEvent.dispatchEvent('pictures-time-update', {
second: this.getSecond(),
});
// 图片一维数组
if(this._result.length !==0){
this._result = []
}
this._result = qietu(this.picturesWrapper, picUrl, MAX_COL, MAX_ROW);
// this.picturesWrapper.addChild(this.guideHole);
// console.log(this.picturesWrapper)
this.pictures = this._result[0];
if(this.rightList !== null){
this.rightList = []
}
this.rightList = this.pictures.concat([]);
const posList = this._result[1];
getRandomArray(this.pictures);
let i = 0;
let len;
len = this.pictures.length;
for (; i < len; i++) {
this.dragPic = this.pictures[i];
this.pictures[i].addEventListener(
engine.MouseEvent.MOUSE_DOWN,
this.onDown,
this
);
const [x, y] = posList[i];
this.dragPic.x = x;
this.dragPic.y = y;
}
this._timer = setInterval(() => {
this.onTimer();
}, 10)
this.date = new Date().getTime();
}
onTimer() {
let date = new Date().getTime();
let gap = ((date - this.date) / 1000);
this.date = date;
// console.log(gap,"gap");
// 以GAME_TIME为标准
GAME_TIME -= gap;
if(GAME_TIME < 0){
GAME_TIME = 0;
}
GAME_TIME = this.afterPointTwo(GAME_TIME);
GAME_TIME = GAME_TIME.toFixed(2);
if (GAME_TIME < 10) {
GAME_TIME = '0' + GAME_TIME
}
// console.log(GAME_TIME);
engine.globalEvent.dispatchEvent('pictures-time-update', {
second: this.getSecond(),
});
if (this.getSecond() == 0) {
this.stop();
engine.globalEvent.dispatchEvent('pictures-game-fail', {
reason: 1
});
this.stage.removeEventListener(
engine.MouseEvent.MOUSE_UP,
this.stageOnUp,
this
);
}
}
afterPointTwo(n) {
var floatN = parseFloat(n);
if (isNaN(floatN)) {
return;
}
floatN = Math.round(floatN * 100) / 100;
return floatN;
}
getSecond() {
return GAME_TIME
}
stop() {
GAME_TIME = props.GAME_TIME
clearInterval(this._timer);
let len = this.pictures.length;
for(let i=0;i<len;i++){
this.pictures[i].removeAllEventListener();
}
}
constructor() {
super();
this.once(engine.Event.ADDED_TO_STAGE, this.setup, this);
}
//当前图片对象
dragPic;
// 鼠标在当前图片上的位置
localPicX;
localPicY;
// 拖动的图片最开始的位置(左上角为准)
distanceX;
distanceY;
// 图片中心的位置
centerX: number;
centerY: number;
pictures: engine.Sprite[];
// 点击图片时的一维数组索引
index;
// 计算目标图片行和列的位置
indexI: number;
indexJ: number;
rightList: engine.Sprite[];
private picturesWrapper: engine.Sprite;
private guideHole: engine.Image;
createRects() { }
setup() {
console.log('onSteup', props);
const parent = new engine.Sprite();
this.picturesWrapper = parent;
this.addChild(parent);
// this.picturesWrapper.x = OFFSET_X;
// this.picturesWrapper.y = OFFSET_Y;
// 添加按钮
// const btn = new engine.Rect();
// btn.width = 200;
// btn.height = 100;
// btn.stage.top = 1000;
// btn.stage.left = 350;
// btn.fillColor = 'cyan';
// this.addChild(btn)
// btn.addEventListener(engine.MouseEvent.CLICK,this.onClk,this)
}
onDown(e: engine.MouseEvent) {
// console.log(e);
let stageLeft = (750 - props.W) / 2
let stageTop = (this.stage.height - props.H) / 2;
// 创建一个图片对象接收当前位置信息
this.dragPic = e.target;
this.picturesWrapper.addChild(this.dragPic);
// 鼠标的偏移量
this.localPicX = e.localX / MAX_COL;
this.localPicY = e.localY / MAX_ROW;
// 最开始图片的位置
this.distanceX = this.dragPic.x ;
this.distanceY = this.dragPic.y;
// 最开始点击的图片的索引值
this.indexJ = Math.floor((this.distanceX) / (w + GAP));
this.indexI = Math.floor((this.distanceY) / (h + GAP));
this.index = (this.indexI) * MAX_COL + this.indexJ;
// this.centerX = Math.floor(e.clientX / w) * w + w / 2;
// this.centerY = Math.floor(e.clientY / h) * h + h / 2;
this.centerX = Math.floor((e.clientX - stageLeft) / w) * w + w / 2;
this.centerY = Math.floor((e.clientY - stageTop) / h) * h + h / 2;
this.stage.addEventListener(
engine.MouseEvent.MOUSE_MOVE,
this.onMove,
this
);
this.stage.addEventListener(
engine.MouseEvent.MOUSE_UP,
this.stageOnUp,
this
);
}
listenStageOn = 1;
stageOnUp(e) {
let stageLeft = (750 - props.W) / 2
let stageTop = (this.stage.height - props.H) / 2;
this.stage.removeEventListener(
engine.MouseEvent.MOUSE_MOVE,
this.onMove,
this
);
this.stage.removeEventListener(
engine.MouseEvent.MOUSE_UP,
this.stageOnUp,
this
);
// 拖动的图片的中心位置在图片之外,回到原来的位置
if (this.centerY < stageTop || this.centerX < stageLeft) {
this.dragPic.x = this.distanceX ;
this.dragPic.y = this.distanceY ;
}
// 判断图片是否进入另一张图片的范围内
// 要交换的图片第几行第几列
let curJ = Math.floor(this.centerX / (w + GAP));
let curI = Math.floor(this.centerY / (h + GAP));
// this.picturesWrapper.addChild(this.guideHole);
// 点击图片的位置
if ( 0 <= curJ && curJ < (MAX_COL) && 0 <= curI && curI < (MAX_ROW)) {
// 获取交互图片的索引值
let index = getIndexFromRC(curI, curJ, MAX_COL);
// console.log(index);
//要交换的图片
let dropPic = this.pictures[index];
let dropPicX = dropPic.x + stageLeft;
let dropPicy = dropPic.y + stageTop;
dropPic.x = this.distanceX;
dropPic.y = this.distanceY;
this.dragPic.x = dropPicX - stageLeft;
this.dragPic.y = dropPicy - stageTop;
// 交换之后索引也需要交换
const dropPicIndex = this.pictures.indexOf(dropPic);
const dragPicIndex = this.pictures.indexOf(this.dragPic);
this.pictures[dropPicIndex] = this.dragPic;
this.pictures[dragPicIndex] = dropPic;
// 图片中心还是在原来的位置
if (dragPicIndex === dropPicIndex) {
this.dragPic.x = this.distanceX
this.dragPic.y = this.distanceY
}
let result = true;
for (let j = 0; j < this.rightList.length; j++) {
if (this.rightList[j] != this.pictures[j]) {
result = false;
break;
}
}
if (result) {
this.onSuccess();
}
} else {
this.dragPic.x = this.distanceX
this.dragPic.y = this.distanceY
}
}
private onSuccess() {
console.log('拼图成功!');
engine.globalEvent.dispatchEvent('pictures-game-success', { time: GAME_TIME });
this.stop();
props.GAME_TIME *= 0.9;
++props.MAX_ROW ;
++props.MAX_COL ;
}
onMove(e: engine.MouseEvent) {
// 当前图片的位置
this.dragPic.x = e.stageX - this.localPicX - (750 - props.W) / 2;
this.dragPic.y = e.stageY - this.localPicY - (this.stage.height - props.H) / 2;
// 当前图片的中心位置
this.centerX = this.dragPic.x + w / 2;
this.centerY = this.dragPic.y + h / 2;
}
// onClk(e){
// // 重置时间
// this._timeCounter = 0;
// //重置图片顺序
// }
}
/**
* Created by rockyl on 2020-01-09.
*/
import GameView from "./GameView";
import { injectProps } from "../props";
export class GameWrapper extends engine.Container {
// private _status;
private _gameView: GameView;
constructor() {
super();
engine.globalEvent.addEventListener('pictures-start', this.start, this);
engine.globalEvent.addEventListener('pictures-stop', this.stop, this);
//创建实例
let gameView = this._gameView = new GameView();
this.addChild(gameView);
}
start(event: engine.Event) {
injectProps(event.data);
// this._status = 1;
this._gameView.start();
}
stop(event: engine.Event) {
this._gameView.stop();
}
}
/**
* Created by rockyl on 2020-02-03.
*/
import {Goods} from "./Goods";
import ObjectPool = engine.ObjectPool;
export const PoolName: string = 'goods';
ObjectPool.registerPool(PoolName, function () {
return new Goods();
}, function (item: Goods, data) {
item.reset();
});
import { props } from "../props";
const urls = [];
const picMap = {};
const posMap = {};
export default (parent, url, MAX_COL, MAX_ROW) => {
// if (picMap[url]) {
// const pics:any[] = picMap[url];
// for (const pic of pics) {
// parent.addChild(pic);
// }
// return [picMap[url], posMap[url]]
// }
const W = props.W;
const H = props.H;
const GAP = props.GAP;
const spr = [];
const pos = []
for (let row = 0; row < MAX_ROW; row++) {
for (let col = 0; col < MAX_COL; col++) {
const child = new engine.Sprite();
// spr.push(child);
child.scaleX = 1 / MAX_COL;
child.scaleY = 1 / MAX_ROW;
parent.addChild(child);
child.x = col * (W / MAX_COL + GAP);
child.y = row * (H / MAX_ROW + GAP);
pos.push([child.x, child.y]);
spr.push(child);
child.addEventListener(engine.Event.COMPLETE, () => {
const uvs = new Float32Array([
col / MAX_COL,
row / MAX_ROW,
(col + 1) / MAX_COL,
row / MAX_ROW,
(col + 1) / MAX_COL,
(row + 1) / MAX_ROW,
col / MAX_COL,
(row + 1) / MAX_ROW,
]);
child.uvs = uvs;
});
child.texture = engine.Texture.fromImage(url);
}
}
// picMap[url] = spr.concat([]);
// posMap[url] = pos.concat([]);
console.log(spr);
return [spr, pos];
};
/**
* Created by rockyl on 2020-01-21.
*/
import {props} from '../props'
export function getTexture(uuid) {
return engine.Texture.from(getAssetByUUID(uuid).uuid);
}
export function getTextureByName(name) {
return getTexture(engine.getAssetByName(name).uuid);
}
export function playSound(name) {
engine.playSound(engine.getAssetByName(name).uuid, { keep: true });
}
export function createSvga(name, anchorName?) {
let inst = new svga.Svga();
inst.source = "asset://" + engine.getAssetByName(name).uuid;
return inst;
}
export function getIndexFromRC(row, col, maxCol) {
let index;
index = row * maxCol + col;
return index;
}
export function getRandomArray(array) {
array.sort(function () {
return 0.5 - Math.random();
});
}
/**
* Created by rockyl on 2019-11-20.
*/
import {GameWrapper} from "./game/GameWrapper";
import {injectProps, prepareProps} from "./props";
export default function (props) {
prepareProps();
injectProps(props);
let instance = new GameWrapper();
return instance;
}
/**
* Created by rockyl on 2020-01-21.
*/
export let props: any = {};
export function prepareProps() {
let metaProps = getProps();
engine.injectProp(props, metaProps);
}
export function injectProps(p) {
engine.injectProp(props, p);
}
/**
* Created by renjianfeng on 2020-03-13.
*/
const customId = 'seabed-game';
(async function () {
let customModule = await fetch(`../meta.json`);
customModule = await customModule.json();
console.log(customModule);
await loadAssets(customModule.assets);
launchWithCustomModule(customModule);
})();
function launchWithCustomModule(customModule) {
//engine.registerCustomCodeModule(customModule);
engine.registerCustomModule(customId, window[customId]);
const { props: propsOption, assets } = customModule;
let props = engine.computeProps(customModuleProps, propsOption);
const customModuleIns = {
id: customId,
props,
assets,
};
engine.registerCustomModules([customModuleIns]);
engine.launchWithConfig({
options: {
entrySceneView: 'entry',
},
assets: [],
views: [{
name: 'entry',
type: 'node',
properties: {
x: 0,
y: 0,
}
}],
customs: [],
}, null, function () {
setTimeout(() => {
engine.addCustomModule(customId, engine.gameStage.sceneContainer.getChildAt(0));
}, 100);
setTimeout(() => {
engine.globalEvent.dispatchEvent('seabed-game-start',{color:"0x000000"});
}, 150);
});
engine.globalEvent.addEventListener('seabed-game-time-update', (e) => {
// console.log(e.type, e.data);
});
engine.globalEvent.addEventListener('seabed-game-game-fail', (e) => {
console.log(e.type, e.data);
});
engine.globalEvent.addEventListener('seabed-game-game-success', (e) => {
console.log(e.type, e.data);
});
}
function getAssetByUUID(uuid) {
return engine.resolveCustomAsset(customId, uuid);
}
function getProps() {
return engine.getProps(customId);
}
This source diff could not be displayed because it is too large. You can view the blob instead.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>海底游戏机</title>
<meta name="viewport"
content="width=device-width,initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no"/>
<meta name="apple-mobile-web-app-capable" content="yes"/>
<meta name="full-screen" content="true"/>
<meta name="screen-orientation" content="portrait"/>
<meta name="x5-fullscreen" content="true"/>
<meta name="360-fullscreen" content="true"/>
<style>
html,
body {
padding: 0;
margin: 0;
border: 0;
width: 100%;
height: 100%;
overflow: hidden;
position: absolute;
background-color: gray;
}
.game-container{
width: 100%;
height: 100%;
line-height:0;
font-size:0;
}
</style>
</head>
<body>
<div id="game-container" class="game-container"></div>
<script crossorigin="anonymous" src="//yun.duiba.com.cn/editor/zeroing/libs/engine.1de84ff79dba19e949088de63aa75af51a515e5c.js"></script>
<script crossorigin="anonymous" src="//yun.duiba.com.cn/editor/zeroing/libs/svga.fd3923ae6e664251ca7981801a65809cc5f36bc3.js"></script>
<!-- <script src="//yun.duiba.com.cn/editor/zeroing/libs/engine.ebc906f6b50b8da0a669f77027981d5f3cb560ce.js"></script> -->
<!-- <script src="http://localhost:4002/debug/engine.js"></script>
<script src="http://localhost:4003/debug/engine-svga.js"></script> -->
<!--<script src="//yun.duiba.com.cn/editor/zeroing/libs/engine.9a9dbfda4cb2dd5508ecddfe3d95dfd88063f7b5.js"></script>-->
<script src="app.js"></script>
<script src="props.js"></script>
<script src="load-assets.js"></script>
<script src="main.js"></script>
<script src="matter.min.js"></script>
<script src="matter_decomp.min.js"></script>
<div id="debugCanvas" style="position:absolute;opacity: .5;pointer-events: none"></div>
<script>
</script>
</body>
\ No newline at end of file
/**
* Created by rockyl on 2020-01-21.
*/
const assets = [
{
"name": "玩家icon",
"url": "//yun.duiba.com.cn/aurora/assets/5b3e30496b2d9fdafb0cf3835fd6704ce10e45b4.png",
"uuid": "888",
"ext": ".png"
},
{
"name": "雨滴",
"url": "//yun.duiba.com.cn/aurora/assets/8564c8c9be3aead71b05a0bab8d7d07ac3f778a1.png",
"uuid": "264a6192-d7bf-45e8-8f15-6ba2c439a532",
"ext": ".png"
},
{
"name": "炸弹",
"url": "//yun.duiba.com.cn/aurora/assets/171e92283cd13c013ee1b76d28d252ff08815d47.png",
"uuid": "eb88b42d-e151-4c1b-94b9-7c16f7bfac29",
"ext": ".png"
},
{
"name": "石块",
"url": "//yun.duiba.com.cn/aurora/assets/99b0af0c59fe79a415a3f032149cfacc27e3ac2c.png",
"uuid": "ab1bdabc-21ba-46bf-9299-6c638f766c88",
"ext": ".png"
},
{
"name": "水花",
"url": "//yun.duiba.com.cn/aurora/assets/93d37b4a0e367e80e375308a6b4414d72d7666fc.svga",
"uuid": "b521bf94-20e1-44dd-8eca-d24996cbaeae",
"ext": ".svga"
},
{
"name": "炸弹",
"url": "//yun.duiba.com.cn/aurora/assets/4dd18f0689c663bbcf710a7afc4d929084d97d36.svga",
"uuid": "322edf39-805b-4e84-9d07-5573dfeebc0e",
"ext": ".svga"
},
{
"name": "玩家",
"url": "//yun.duiba.com.cn/aurora/assets/b66300c5d4f27134b0aac3dc90a3220e8ae572eb.svga",
"uuid": "71d8dcbc-3931-471a-b585-b3ae01b25aa6",
"ext": ".svga"
}
];
function loadAssets(customModuleAssets, onProgress, onComplete){
return engine.loadAssets(assets.concat(...customModuleAssets), onProgress, onComplete);
}
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('tslib')) :
typeof define === 'function' && define.amd ? define(['tslib'], factory) :
(global = global || self, global['seabed-game'] = factory(global.tslib));
}(this, (function (tslib) { 'use strict';
var LabelType;
(function (LabelType) {
LabelType["boom"] = "boom";
LabelType["candy"] = "candy";
LabelType["coin"] = "coin";
LabelType["gift"] = "gift";
LabelType["egg"] = "egg";
})(LabelType || (LabelType = {}));
var LabelType$1 = LabelType;
//# sourceMappingURL=LabelType.js.map
var props = {};
function prepareProps() {
var metaProps = getProps();
engine.injectProp(props, metaProps);
}
function injectProps(p) {
engine.injectProp(props, p);
}
//# sourceMappingURL=props.js.map
var levels;
var setlevelData = function () {
levels = {
'1': { max: props.level_1[0], items: [[LabelType$1.boom, props.level_1[1]], [LabelType$1.coin, props.level_1[2]]], time: props.level_1[3] },
'2': { max: props.level_2[0], items: [[LabelType$1.boom, props.level_2[1]], [LabelType$1.coin, props.level_2[2]]], time: props.level_2[3] },
'3': { max: props.level_3[0], items: [[LabelType$1.boom, props.level_3[1]], [LabelType$1.coin, props.level_3[2]]], time: props.level_3[3] },
};
};
var touchEnabled = false;
var getTouchEnabled = function () {
return touchEnabled;
};
var setTouchEnabled = function (b) {
touchEnabled = b;
};
//# sourceMappingURL=GoldData.js.map
function getTexture(uuid) {
return engine.Texture.from(getAssetByUUID(uuid).uuid);
}
function getTextureByName(name) {
return getTexture(engine.getAssetByName(name).uuid);
}
//# sourceMappingURL=utils.js.map
var Tool = (function () {
function Tool() {
}
Tool.getLabel = function (txt, size, color, bold, align, x, y) {
if (color === void 0) { color = "#ffffff"; }
if (bold === void 0) { bold = false; }
if (align === void 0) { align = engine.TEXT_ALIGN.LEFT; }
if (x === void 0) { x = 0; }
if (y === void 0) { y = 0; }
var label = new engine.Label();
label.fillColor = color;
label.bold = bold;
label.size = size;
label.textAlign = align;
label.x = x;
label.y = y;
label.text = txt;
return label;
};
return Tool;
}());
//# sourceMappingURL=Tools.js.map
var curScore;
function getScore() {
return curScore;
}
function addScore(addCount) {
curScore += addCount;
return curScore;
}
function setScore(scoreCount) {
curScore = scoreCount;
}
var curLevel;
function getCurLevel() {
return curLevel;
}
function setCurLevel(level) {
curLevel = level;
return curLevel;
}
var levels$1;
var setlevelData$1 = function () {
levels$1 = {
'1': { max: props.level_1[0], items: [[LabelType$1.boom, props.level_1[1]], [LabelType$1.coin, props.level_1[2]]], time: props.level_1[3] },
'2': { max: props.level_2[0], items: [[LabelType$1.boom, props.level_2[1]], [LabelType$1.coin, props.level_2[2]]], time: props.level_2[3] },
'3': { max: props.level_3[0], items: [[LabelType$1.boom, props.level_3[1]], [LabelType$1.coin, props.level_3[2]]], time: props.level_3[3] },
};
};
var getLevelData = function () {
if (!levels$1) {
setlevelData$1();
}
return levels$1[getCurLevel()];
};
var getCurrentItems = function () {
if (!levels$1) {
setlevelData$1();
}
return getLevelData().items;
};
var getlevelTime = function () {
if (!levels$1) {
setlevelData$1();
}
return getLevelData().time;
};
var getlevelMax = function () {
if (!levels$1) {
setlevelData$1();
}
return getLevelData().max;
};
//# sourceMappingURL=goldData.js.map
var GameData = (function (_super) {
tslib.__extends(GameData, _super);
function GameData(parentNode, color) {
var _this = _super.call(this) || this;
_this.starList = [];
_this._parentNode = parentNode;
_this._color = color;
_this.init();
return _this;
}
GameData.prototype.init = function () {
var scoreCount = this._scoreCount = Tool.getLabel('', 36, "#ffffff", true);
scoreCount.y = 48;
this.addChild(scoreCount);
var scorelabel = this._scorelabel = Tool.getLabel('分', 22, "#ffffff");
scorelabel.y = 56;
this.addChild(scorelabel);
var progress = new engine.Sprite(getTextureByName('进度'));
progress.x = 212;
progress.y = 8;
this.addChild(progress);
var progressMask = this._progressMask = new engine.Rect();
progressMask.fillColor = 0x000000;
progressMask.width = 245;
progressMask.height = 100;
progressMask.x = 213;
progressMask.y = 5;
progressMask.scaleX = 0;
this.addChild(progressMask);
progress.mask = progressMask;
var star1 = new engine.Sprite(getTextureByName('点亮'));
star1.x = 270;
star1.y = 6;
star1.visible = false;
this.addChild(star1);
this.starList.push(star1);
var star2 = new engine.Sprite(getTextureByName('点亮'));
star2.x = 365;
star2.y = 6;
star2.visible = false;
this.addChild(star2);
this.starList.push(star2);
var star3 = new engine.Sprite(getTextureByName('点亮'));
star3.x = 435;
star3.y = 50;
star3.visible = false;
this.addChild(star3);
this.starList.push(star3);
this.scorePosUpdate();
var levelLabel = this._levelLabel = Tool.getLabel('', 28, this._color || "#28c1ec", false);
levelLabel.y = 98;
this.addChild(levelLabel);
this.levelUpdate();
this.updateProgressMask();
};
GameData.prototype.scorePosUpdate = function () {
this._scoreCount.text = getScore();
this._scoreCount.x = (this._parentNode.width - this._scoreCount.width - this._scorelabel.width - 5) / 2;
this._scorelabel.x = this._scoreCount.x + this._scoreCount.width + 5;
this.updateProgressMask();
};
GameData.prototype.levelUpdate = function (color) {
this._levelLabel.text = "\u7B2C" + getCurLevel() + "/3\u5173";
this._levelLabel.x = (this._parentNode.width - this._levelLabel.width) / 2;
};
GameData.prototype.updateProgressMask = function () {
var ratio = getScore() / getlevelMax();
this._progressMask.scaleX = ratio;
if (ratio >= 0.35) {
this.starList[0].visible = true;
}
if (ratio >= 0.75) {
this.starList[1].visible = true;
}
if (ratio >= 1) {
this.starList[2].visible = true;
}
};
GameData.prototype.resetMask = function () {
this.starList.forEach(function (element) {
element.visible = false;
});
};
return GameData;
}(engine.Container));
//# sourceMappingURL=gameData.js.map
var BaseItem = (function (_super) {
tslib.__extends(BaseItem, _super);
function BaseItem(mc, type) {
var _this = _super.call(this) || this;
_this.type = type;
_this._mc = mc;
var bubble = getTextureByName('bubble');
var bubblePic = new engine.Sprite(bubble);
bubblePic.anchorTexture.set(0.5, 0.5);
_this._mc.anchorTexture.set(0.5, 0.5);
_this._mc.x = bubblePic.x / 4;
_this._mc.y = bubblePic.y / 4;
_this.addChild(bubblePic);
_this.addChild(_this._mc);
return _this;
}
Object.defineProperty(BaseItem.prototype, "mc", {
get: function () { return this._mc; },
enumerable: true,
configurable: true
});
return BaseItem;
}(engine.Sprite));
//# sourceMappingURL=BaseItem.js.map
var EgretRender = (function () {
function EgretRender(root, engine) {
this._root = root;
this._engine = engine;
}
EgretRender.prototype.addBody = function (body, display, x, y) {
if (display) {
body['display'] = display;
this._root.addChildAt(display, 0);
display.x = x;
display.y = y;
}
return body;
};
EgretRender.prototype.remove = function (body) {
this.removeBody(body);
this.removeDisplay(body);
};
EgretRender.prototype.removeBody = function (body) {
Matter.World.remove(this._engine.world, body);
};
EgretRender.prototype.removeDisplay = function (body) {
var display = body['display'];
if (display && display.parent)
display.parent.removeChild(display);
};
EgretRender.prototype.run = function () {
var bodies = Matter.Composite.allBodies(this._engine.world);
for (var i = 0; i < bodies.length; i++) {
var body = bodies[i];
var display = body['display'];
if (!display)
continue;
var x1 = Math.round(display.x);
var x2 = Math.round(body.position.x);
var y1 = Math.round(display.y);
var y2 = Math.round(body.position.y);
var distanceX = Math.abs(x1 - x2);
var distanceY = Math.abs(y1 - y2);
var precision = 1;
if (distanceX > precision || distanceY > precision) {
if (display instanceof BaseItem)
display.mc.resume();
}
else {
if (display instanceof BaseItem)
display.mc.pause();
}
display.x = body.position.x;
display.y = body.position.y;
display.rotation = this.getRotation(body.angle);
}
};
EgretRender.prototype.rectangle = function (x, y, width, height, display, options) {
var body = this.rectangleToRender(x, y, width, height, display, options);
this.addBodyToWorld(body);
return body;
};
EgretRender.prototype.circle = function (x, y, radius, display, options) {
var body = this.circleToRender(x, y, radius, display, options);
this.addBodyToWorld(body);
return body;
};
EgretRender.prototype.addBodyToWorld = function (body) {
Matter.World.add(this._engine.world, body);
return body;
};
EgretRender.prototype.rectangleToRender = function (x, y, width, height, display, options) {
var body = Matter.Bodies.rectangle(x, y, width, height, options);
this.addBody(body, display, x, y);
return body;
};
EgretRender.prototype.circleToRender = function (x, y, radius, display, options) {
var body = Matter.Bodies.circle(x, y, radius, options);
this.addBody(body, display, x, y);
return body;
};
EgretRender.prototype.getRotation = function (angle) {
return angle / Math.PI / 2 * 360;
};
return EgretRender;
}());
//# sourceMappingURL=EgretRender.js.map
var wall = 1;
var basket = 2;
var award = 4;
var bubble = 8;
var bubbleStandby = 16;
var bubbleGroup = -1;
var bubbleStandbyGroup = -2;
var wallMask = award + bubble + bubbleStandby;
var basketMask = award + bubble + bubbleStandby;
var awardMask = wall + basket + bubble;
var bubbleMask = wall + basket + award;
var bubbleStandbyMask = wall + basket;
//# sourceMappingURL=collisionConfig.js.map
var vibrate = (function (view, count, strength) {
if (count === void 0) { count = 2; }
if (strength === void 0) { strength = 10; }
return new Promise(function (r) {
var pos = [
{ x: strength, y: 0 },
{ x: 0, y: -strength },
{ x: -strength, y: 0 },
{ x: 0, y: strength },
{ x: 0, y: 0 },
];
var list = [];
for (var i = 0; i < count; i++) {
list = list.concat(pos);
}
var x0 = view.x;
var y0 = view.y;
var counter = list.length;
var _loop_1 = function (i) {
var element = list[i];
setTimeout(function () {
view.x = element.x + x0;
view.y = element.y + y0;
counter--;
if (counter == 0) {
view.x = x0;
view.y = y0;
r();
}
}, 1000 / 60 * i);
};
for (var i = 0; i < list.length; i++) {
_loop_1(i);
}
});
});
//# sourceMappingURL=vibrate.js.map
var MovieClip = (function (_super) {
tslib.__extends(MovieClip, _super);
function MovieClip(_a) {
var spritesheet = _a.spritesheet, frames = _a.frames, scale = _a.scale, position = _a.position, _b = _a.keys, keys = _b === void 0 ? null : _b, _c = _a.autoplay, autoplay = _c === void 0 ? true : _c, _d = _a.loop, loop = _d === void 0 ? true : _d, anchor = _a.anchor, _e = _a.frameInterval, frameInterval = _e === void 0 ? 1 : _e, _f = _a.callBack, callBack = _f === void 0 ? null : _f;
var _this = _super.call(this) || this;
_this.frames = frames;
_this.frameInterval = frameInterval;
_this.keys = keys;
_this.autoplay = autoplay;
_this.loop = loop;
_this.anchorXtmp = anchor;
_this.anchorYtmp = anchor;
_this._callBack = callBack;
if (Array.isArray(anchor)) {
_this.anchorXtmp = anchor[0];
_this.anchorYtmp = anchor[1];
}
_this.x = position[0];
_this.y = position[1];
_this.spritesheet = spritesheet;
if (_this.autoplay) {
_this.play();
}
_this.scaleX = _this.scaleY = scale;
return _this;
}
MovieClip.prototype.pause = function () {
this.removeEventListener(engine.Event.ENTER_FRAME, this.onTick, this);
};
MovieClip.prototype.resume = function () {
this.addEventListener(engine.Event.ENTER_FRAME, this.onTick, this);
};
MovieClip.prototype.play = function (start) {
if (start === void 0) { start = 0; }
this.goto(start);
this.currentFrame = 0;
this.counter = 0;
this.addEventListener(engine.Event.ENTER_FRAME, this.onTick, this);
};
MovieClip.prototype.goto = function (frame) {
this.texture = this.textures[frame];
};
MovieClip.prototype.onTick = function () {
this.counter++;
if (this.counter == this.frameInterval) {
this.counter = 0;
this.currentFrame++;
this.goto(this.currentFrame);
if (this.currentFrame == this.frames.length - 1) {
if (this.loop) {
this.currentFrame = 0;
}
else {
this.stop();
if (this._callBack) {
this._callBack();
this._callBack = null;
}
}
}
}
return false;
};
MovieClip.prototype.stop = function () {
this.currentFrame = 0;
this.removeEventListener(engine.Event.ENTER_FRAME, this.onTick, this);
};
Object.defineProperty(MovieClip.prototype, "spritesheet", {
set: function (value) {
this.textures = this.frames.map(function (frame) { return value[frame]; });
this.anchorTexture.set(this.anchorXtmp, this.anchorYtmp);
},
enumerable: true,
configurable: true
});
Object.defineProperty(MovieClip.prototype, "textureItemWidth", {
get: function () { return this.textures[0].width; },
enumerable: true,
configurable: true
});
Object.defineProperty(MovieClip.prototype, "textureItemHeight", {
get: function () { return this.textures[0].height; },
enumerable: true,
configurable: true
});
return MovieClip;
}(engine.Image));
//# sourceMappingURL=MovieClip.js.map
var wait = function (duration) { return tslib.__awaiter(void 0, void 0, void 0, function () {
return tslib.__generator(this, function (_a) {
return [2, new Promise(function (resolve) { return setTimeout(resolve, duration); })];
});
}); };
//# sourceMappingURL=wait.js.map
var josnData = {};
function getJsonAsset(name) {
var config = engine.getAssetByName(name + '_json');
var tmpJosnData = engine.globalLoader.get(config.uuid);
if (tmpJosnData) {
josnData[name] = convert(tmpJosnData);
}
}
function convert(data) {
var frames = data.frames;
var jsonName = data.file.split('.')[0];
var obj = {};
for (var key in frames) {
var f = frames[key];
obj[jsonName + key + ".png"] = {
"x": f.x,
"y": f.y,
"w": f.w,
"h": f.h,
"ox": f.offX,
"oy": f.offY,
"sw": f.sourceW,
"sh": f.sourceH,
"ro": false,
};
}
return obj || null;
}
function getJosnData(jsonName) {
return josnData[jsonName] || null;
}
//# sourceMappingURL=JsonTools.js.map
function createTextureSheet(baseTexture, altaData) {
var frames = altaData;
var frameKeys = Object.keys(frames);
var frameIndex = 0;
var textures = {};
while (frameIndex < frameKeys.length) {
var i = frameKeys[frameIndex];
var data = frames[i];
var frame = null;
var trim = null;
var orig = new engine.Rectangle(0, 0, Math.floor(data.sw), Math.floor(data.sh));
if (data.ro) {
frame = new engine.Rectangle(Math.floor(data.x), Math.floor(data.y), Math.floor(data.h), Math.floor(data.w));
}
else {
frame = new engine.Rectangle(Math.floor(data.x), Math.floor(data.y), Math.floor(data.w), Math.floor(data.h));
}
if (data.ox || data.oy) {
trim = new engine.Rectangle(Math.floor(data.ox), Math.floor(data.oy), Math.floor(data.w), Math.floor(data.h));
}
var texture = new engine.Texture(baseTexture, frame, orig, trim, data.ro ? 2 : 0);
engine.Texture.addToCache(texture, i);
textures[i] = texture;
frameIndex++;
}
return textures;
}
//# sourceMappingURL=createTextureSheet.js.map
function playMovieClip(parent, key, frames, frameInterval) {
if (frameInterval === void 0) { frameInterval = 5; }
return tslib.__awaiter(this, void 0, void 0, function () {
var _this = this;
return tslib.__generator(this, function (_a) {
return [2, new Promise(function (r) { return tslib.__awaiter(_this, void 0, void 0, function () {
var josnData, texture;
var _this = this;
return tslib.__generator(this, function (_a) {
switch (_a.label) {
case 0:
josnData = getJosnData(key);
if (!josnData) {
getJsonAsset(key);
josnData = getJosnData(key);
}
texture = createTextureSheet(getTextureByName(key).baseTexture, josnData);
if (!texture) return [3, 2];
return [4, createMc(parent, texture, frames, frameInterval)];
case 1:
_a.sent();
r(1);
return [3, 3];
case 2:
wait(300).then(function () { return tslib.__awaiter(_this, void 0, void 0, function () {
var josnData;
return tslib.__generator(this, function (_a) {
switch (_a.label) {
case 0:
josnData = getJosnData(key);
if (!josnData) {
getJsonAsset(key);
josnData = getJosnData(key);
}
texture = createTextureSheet(getTextureByName(key).baseTexture, josnData);
if (!texture) return [3, 2];
return [4, createMc(parent, texture, frames, frameInterval)];
case 1:
_a.sent();
r(1);
return [3, 3];
case 2:
r(0);
_a.label = 3;
case 3: return [2];
}
});
}); });
_a.label = 3;
case 3: return [2];
}
});
}); })];
});
});
}
function createMc(parent, spritesheet, frames, frameInterval) {
if (frameInterval === void 0) { frameInterval = 5; }
return new Promise(function (r) {
var movieclip = new MovieClip({
spritesheet: spritesheet,
frameInterval: frameInterval,
frames: frames,
position: [0, 150],
scale: 1,
anchor: [0, 0],
loop: false,
callBack: function () {
setTimeout(function () {
parent.removeChild(movieclip);
r(1);
}, 100);
}
});
parent.addChild(movieclip);
});
}
var playBoom = function (parent) {
return playMovieClip(parent, 'fail', ['fail1.png', 'fail2.png', 'fail3.png', 'fail4.png', 'fail5.png', 'fail6.png', 'fail7.png', 'fail8.png'], 5);
};
var playSuccess = function (parent) {
return playMovieClip(parent, 'success', ['success1.png', 'success2.png', 'success3.png', 'success4.png', 'success5.png', 'success6.png', 'success7.png', 'success8.png', 'success9.png'], 5);
};
//# sourceMappingURL=playMovieClip.js.map
var createCoin = function (scale) {
var josnData = getJosnData('coin');
if (!josnData) {
getJsonAsset('coin');
josnData = getJosnData('coin');
}
var texture = createTextureSheet(getTextureByName('coin').baseTexture, josnData);
var animation = createMovieClip(texture, 0.6);
var baseItem = new BaseItem(animation, LabelType$1.coin);
baseItem.scaleX = baseItem.scaleY = scale;
return baseItem;
};
var createMovieClip = function (spritesheet, scale) {
if (scale === void 0) { scale = 1; }
var list = ['coin1.png', 'coin2.png', 'coin3.png', 'coin4.png', 'coin5.png', 'coin6.png', 'coin7.png', 'coin8.png'];
var movieclip = new MovieClip({
spritesheet: spritesheet,
frameInterval: 6,
frames: list,
position: [0, 0],
scale: scale,
anchor: [.5, .5]
});
return movieclip;
};
//# sourceMappingURL=createCoin.js.map
var createBoom = function (scale) {
var josnData = getJosnData('boom');
if (!josnData) {
getJsonAsset('boom');
josnData = getJosnData('boom');
}
var boomTexture = createTextureSheet(getTextureByName('boom').baseTexture, josnData);
var animation = createMovieClip$1(boomTexture);
var baseItem = new BaseItem(animation, LabelType$1.boom);
baseItem.scaleX = baseItem.scaleY = scale;
return baseItem;
};
var createMovieClip$1 = function (spritesheet, scale) {
if (scale === void 0) { scale = 1; }
var list = ['boom1.png', 'boom2.png', 'boom3.png', 'boom4.png', 'boom5.png', 'boom6.png', 'boom7.png', 'boom8.png', 'boom9.png', 'boom10.png'];
var movieclip = new MovieClip({
spritesheet: spritesheet,
frameInterval: 5,
frames: list,
position: [0, 0],
scale: scale,
anchor: [.5, .5]
});
return movieclip;
};
//# sourceMappingURL=createBoom.js.map
var createGift = function (scale) {
var josnData = getJosnData('gift');
if (!josnData) {
getJsonAsset('gift');
josnData = getJosnData('gift');
}
var texture = createTextureSheet(getTextureByName('gift').baseTexture, josnData);
var animation = createMovieClip$2(texture, 0.6);
var baseItem = new BaseItem(animation, LabelType$1.gift);
baseItem.scaleX = baseItem.scaleY = scale;
return baseItem;
};
var createMovieClip$2 = function (spritesheet, scale) {
if (scale === void 0) { scale = 1; }
var list = ['gift1.png', 'gift2.png', 'gift3.png', 'gift4.png', 'gift5.png', 'gift6.png', 'gift7.png', 'gift8.png', 'gift9.png', 'gift10.png'];
var movieclip = new MovieClip({
spritesheet: spritesheet,
frameInterval: 5,
frames: list,
position: [0, 0],
scale: scale,
anchor: [.5, .5]
});
return movieclip;
};
//# sourceMappingURL=createGift.js.map
var createCandy = function (scale) {
var josnData = getJosnData('candy');
if (!josnData) {
getJsonAsset('candy');
josnData = getJosnData('candy');
}
var boomTexture = createTextureSheet(getTextureByName('candy').baseTexture, josnData);
var animation = createMovieClip$3(boomTexture);
var baseItem = new BaseItem(animation, LabelType$1.candy);
baseItem.scaleX = baseItem.scaleY = scale;
return baseItem;
};
var createMovieClip$3 = function (spritesheet, scale) {
if (scale === void 0) { scale = 1; }
var list = ['candy1.png', 'candy2.png', 'candy3.png', 'candy4.png', 'candy5.png', 'candy6.png', 'candy7.png', 'candy8.png'];
var movieclip = new MovieClip({
spritesheet: spritesheet,
frameInterval: 6,
frames: list,
position: [0, 0],
scale: scale,
anchor: [.5, .5]
});
return movieclip;
};
//# sourceMappingURL=createCandy.js.map
var createEgg = function (scale) {
var josnData = getJosnData('egg');
if (!josnData) {
getJsonAsset('gift');
josnData = getJosnData('egg');
}
var texture = createTextureSheet(getTextureByName('egg').baseTexture, josnData);
var animation = createMovieClip$4(texture, 0.6);
var baseItem = new BaseItem(animation, LabelType$1.egg);
baseItem.scaleX = baseItem.scaleY = scale;
return baseItem;
};
var createMovieClip$4 = function (spritesheet, scale) {
if (scale === void 0) { scale = 1; }
var list = ['egg1.png', 'egg2.png', 'egg3.png', 'egg4.png', 'egg5.png', 'egg6.png', 'egg7.png', 'egg8.png', 'egg9.png'];
var movieclip = new MovieClip({
spritesheet: spritesheet,
frameInterval: 5,
frames: list,
position: [0, 0],
scale: scale,
anchor: [.5, .5]
});
return movieclip;
};
//# sourceMappingURL=createEgg.js.map
var createItem = function (scale, type) {
var funcs = {
'boom': createBoom,
'gift': createGift,
'candy': createCandy,
'egg': createEgg,
'coin': createCoin
};
var func = funcs[type];
return func(scale);
};
//# sourceMappingURL=createItem.js.map
var createBubble = function (_this, type, x, y, force, density) {
if (force === void 0) { force = { x: 0, y: 0 }; }
if (density === void 0) { density = 0.001; }
var scale;
var size = random(85, 100);
var maxsize = 100;
scale = size / maxsize;
var baseItem = createItem(scale, type);
var angle;
angle = 0;
_this._egretRender.circle(x, y, (size - 17) / 2, baseItem, {
frictionAir: 0,
collisionFilter: { group: award, category: award, mask: awardMask },
angle: angle,
label: baseItem.type,
friction: 0,
force: force,
density: density
});
};
var random = function (start, end) {
var n = end - start;
return Math.random() * n + start;
};
var createItems = (function (_this) {
var score = getScore();
var items = getCurrentItems();
var list = [];
for (var _i = 0, items_1 = items; _i < items_1.length; _i++) {
var item = items_1[_i];
var type = item[0];
var nums = item[1];
if (type == LabelType$1.coin)
nums = nums - score;
for (var i = 0; i < nums; i++) {
list.push(type);
}
}
var count = 0;
var coinsFall = setInterval(function () {
if (count <= list.length - 1) {
var type = list[count];
createBubble(_this, type, 375 + Math.random() * 200 - 100, 400 + 200 + 200);
count++;
}
}, 100);
});
//# sourceMappingURL=createItems.js.map
var clear = function (that) {
TextList.forEach(function (i) {
engine.Tween.removeTweens(that.gameHint[i]);
that.gameHint[i].alpha = 0;
});
};
var playgreat = function (image) {
engine.Tween.get(image).set({ x: 750, alpha: 1, scaleX: .9, scaleY: .9, rotation: 20 }).to({ x: 540.5, scaleX: 1, scaleY: 1, rotation: 0 }, 200, engine.Ease.getBackOut(2)).wait(500).to({ alpha: 0 }, 200);
};
var playcool = function (image) {
engine.Tween.get(image).set({ x: 750, alpha: 1, scaleX: .9, scaleY: .9, rotation: 60 }).to({ x: 526.09, scaleX: 1, scaleY: 1, rotation: 0 }, 200, engine.Ease.getBackOut(7)).wait(500).to({ alpha: 0 }, 200);
};
var playperfect = function (image) {
engine.Tween.get(image).set({ scaleX: 0, scaleY: 0, alpha: 1, }).to({ scaleX: 1, scaleY: 1 }, 200, engine.Ease.getBackOut(10)).wait(500).to({ alpha: 0 }, 200);
};
var playawesome = function (image) {
engine.Tween.get(image).set({ scaleX: 0, scaleY: 0, alpha: 1, rotation: -20 }).to({ scaleX: 1, scaleY: 1, rotation: 0 }, 200, engine.Ease.getBackOut(20)).wait(500).to({ alpha: 0 }, 200);
};
var playunbelievable = function (image) {
engine.Tween.get(image).set({ scaleX: 0, scaleY: 0, alpha: 1, rotation: -60 }).to({ scaleX: 1, scaleY: 1, rotation: 0 }, 200, engine.Ease.getBackOut(40)).wait(500).to({ alpha: 0 }, 200);
};
var funcs = [playgreat, playcool, playperfect, playawesome, playunbelievable];
var cdtimer;
var count = 0;
var playTextAni = function (that) { return tslib.__awaiter(void 0, void 0, void 0, function () {
var image;
return tslib.__generator(this, function (_a) {
clear(that);
count++;
if (count >= TextList.length)
count = TextList.length;
console.log(count);
image = that.gameHint[TextList[count - 1]];
image.visible = true;
funcs[count - 1](image);
if (cdtimer > 0)
clearTimeout(cdtimer);
cdtimer = setTimeout(function () {
count = 0;
console.log('clear');
}, 5000);
return [2];
});
}); };
var TextList = ['great', 'cool', 'perfect', 'awesome', 'unbelievable'];
//# sourceMappingURL=playTextAni.js.map
function check(_this) {
var egretRenderContainer = _this.egretRenderContainer;
var center = 375;
var paddingX = 50;
var ypos = 570;
var h = 40;
var bodies = Matter.Composite.allBodies(_this._engine.world);
var isAward = function (i) { return i.collisionFilter.group == award; };
bodies.forEach(function (i) {
if (!isAward(i))
return;
if (i['timer']) {
var t0 = Date.now() - i['timer'];
if (t0 > 3000) {
delete i['timer'];
}
}
var _a = i.position, x = _a.x, y = _a.y;
var xResult = x > (center - paddingX) && x < (center + paddingX);
var yResult = y > ypos && y < (ypos + h);
if (xResult && yResult && i.velocity.y > 0 && !i['timer']) {
i['timer'] = Date.now();
if (i.label == LabelType$1.boom) {
_this._egretRender.remove(i);
vibrate(_this, 2);
playBoom(egretRenderContainer);
_this.onBoom();
}
else if (i.label == LabelType$1.egg) {
_this._egretRender.remove(i);
}
else if (i.label == LabelType$1.candy) {
_this._egretRender.remove(i);
}
else if (i.label == LabelType$1.gift) {
_this._egretRender.remove(i);
}
else {
playSuccess(_this.egretRenderContainer);
_this._egretRender.remove(i);
_this.addScore();
playTextAni(_this);
}
}
});
}
//# sourceMappingURL=check.js.map
var createBox = function (_this) {
var path1 = Matter.Vertices.fromPath('385 370 630 380 670 728 620 1080 370 1100 109 1090 57 728 108 370 0 370 0 1624 750 1624 750 0', null);
var body = Matter.Bodies.fromVertices(400, 880, [path1], { isStatic: true, collisionFilter: { group: wall, category: wall, mask: wallMask } }, true);
Matter.World.add(_this._engine.world, body);
var path2 = Matter.Vertices.fromPath('108 370 385 370 385 300', null);
var body2 = Matter.Bodies.fromVertices(296, 365, [path2], { isStatic: true, collisionFilter: { group: wall, category: wall, mask: wallMask } }, true);
Matter.World.add(_this._engine.world, body2);
var basketpath1 = Matter.Vertices.fromPath('290 560 324 600 326 600 313 565', null);
var basketbody1 = Matter.Bodies.fromVertices(305, 575, [basketpath1], { isStatic: true, friction: 0, collisionFilter: { group: basket, category: basket, mask: basketMask } }, true);
Matter.World.add(_this._engine.world, basketbody1);
var basketpath2 = Matter.Vertices.fromPath('465 563 443 605 441 605 456 560', null);
var basketbody2 = Matter.Bodies.fromVertices(453, 570, [basketpath2], { isStatic: true, friction: 0, collisionFilter: { group: basket, category: basket, mask: basketMask } }, true);
Matter.World.add(_this._engine.world, basketbody2);
var basketLeft = Matter.Bodies.circle(285, 560, 12, { isStatic: true, friction: 0, collisionFilter: { group: basket, category: basket, mask: basketMask } });
Matter.World.add(_this._engine.world, basketLeft);
var basketRight = Matter.Bodies.circle(461, 560, 12, { isStatic: true, friction: 0, collisionFilter: { group: basket, category: basket, mask: basketMask } });
Matter.World.add(_this._engine.world, basketRight);
var w = 100;
var h = 50;
var rect = _this._egretRender.rectangle(180, 1080, w, h, null, { isStatic: true, collisionFilter: { group: wall, category: wall, mask: wallMask } });
var rect2 = _this._egretRender.rectangle(560, 1080, w, h, null, { isStatic: true, collisionFilter: { group: wall, category: wall, mask: wallMask } });
var w2 = 300;
var h2 = 10;
var rect3 = _this._egretRender.rectangle(375, 1100, w2, h2, null, { isStatic: true, collisionFilter: { group: wall, category: wall, mask: wallMask } });
};
//# sourceMappingURL=createBox.js.map
var createBubblePic = function (r) {
var bubbleTexture = getTextureByName('bubble');
var bubblePic = new engine.Sprite(bubbleTexture);
bubblePic.scaleX = bubblePic.scaleY = r * 2 / 100;
return bubblePic;
};
//# sourceMappingURL=createBubblePic.js.map
var timerLeft;
var timerRight;
var startStandbyBubblesLeft = function (egretRender) {
timerLeft = setInterval(function () {
var scale = 0.2;
var p1 = { x: 180, y: 1050 };
var r = random$1(8, 10);
var bubblePic = createBubblePic(r);
var body = egretRender.circle(p1.x, p1.y, r, bubblePic, {
restitution: 0,
frictionAir: 0,
force: { x: random$1(-0.005, 0.005) * scale, y: -0.02 * scale },
collisionFilter: { group: bubbleStandbyGroup, category: bubbleStandby, mask: bubbleStandbyMask }
});
setTimeout(function () {
egretRender.remove(body);
}, 1000);
}, 700);
};
var startStandbyBubblesRight = function (egretRender) {
timerRight = setInterval(function () {
var scale = 0.2;
var p2 = { x: 560, y: 1050 };
var r2 = random$1(8, 10);
var bubblePic2 = createBubblePic(r2);
var body2 = egretRender.circle(p2.x, p2.y, r2, bubblePic2, {
restitution: 0,
frictionAir: 0,
force: { x: random$1(-0.005, 0.005) * scale, y: -0.02 * scale },
collisionFilter: { group: bubbleStandbyGroup, category: bubbleStandby, mask: bubbleStandbyMask }
});
setTimeout(function () {
egretRender.remove(body2);
}, 1000);
}, 700);
};
var stopStandbyBubblesLeft = function () {
clearInterval(timerLeft);
};
var stopStandbyBubblesRight = function () {
clearInterval(timerRight);
};
var random$1 = function (start, end) {
var n = end - start;
return Math.random() * n + start;
};
//# sourceMappingURL=standbyBubbles.js.map
var createBtns = (function (that) {
var createShape = function () {
var shape = new engine.Shape();
shape.beginFill(0, .6);
shape.drawCircle(0, 0, that._leftBtn.width / 2);
shape.endFill();
return shape;
};
[that._leftBtn, that._rightBtn].forEach(function (btn) {
btn.addEventListener(engine.MouseEvent.MOUSE_DOWN, function (e) {
var btn = e.target;
engine.Tween.removeTweens(btn);
engine.Tween.get(btn)
.to({ scaleY: 0.9 }, 200);
}, that);
});
[that._leftBtn, that._rightBtn].forEach(function (btn) {
btn.addEventListener(engine.MouseEvent.MOUSE_UP, function (e) {
var btn = e.target;
engine.Tween.removeTweens(btn);
engine.Tween.get(btn)
.to({ scaleX: 1, scaleY: 1 }, 200);
}, that);
});
[that._leftBtn, that._rightBtn].forEach(function (btn) {
btn.addEventListener(engine.MouseEvent.MOUSE_OUT, function (e) {
var btn = e.target;
engine.Tween.removeTweens(btn);
engine.Tween.get(btn)
.to({ scaleX: 1, scaleY: 1 }, 200);
}, that);
});
var shapeLeft = createShape();
shapeLeft.x = that._leftBtn.width / 2;
shapeLeft.y = that._leftBtn.height / 2;
that._leftBtn.addChild(shapeLeft);
var shapeR = createShape();
shapeR.x = that._rightBtn.width / 2;
shapeR.y = that._rightBtn.height / 2;
that._rightBtn.addChild(shapeR);
shapeLeft.alpha = shapeR.alpha = 0;
});
//# sourceMappingURL=createBtns.js.map
var GameView = (function (_super) {
tslib.__extends(GameView, _super);
function GameView() {
var _this = _super.call(this) || this;
_this.gameHint = {};
_this.addForce = false;
_this.stageX = 0;
_this.stageY = 0;
_this._frameCount = 0;
return _this;
}
GameView.prototype.start = function (color) {
return tslib.__awaiter(this, void 0, void 0, function () {
var a, gameNode, contPng, leftBtn, rightBtn, light, basket_bottom, tmpRect, basket_top, glass, gameData, countDown, countDownLabel;
return tslib.__generator(this, function (_a) {
a = new engine.Shape();
this.addChild(a);
engine.globalLoader.loadImage('//yun.duiba.com.cn/aurora/assets/66ab48ff49a741f0c93335d4eb0c9e50b7ab6e1e.png', 'bg_dot')
.then(function (img) {
a.beginBitmapFill(img, null);
a.drawRect(0, 0, 750, 1624);
a.endFill();
});
gameNode = this._gameNode = new engine.Sprite(getTextureByName('机子'));
gameNode.y = 260;
this.addChild(gameNode);
contPng = new engine.Image(getTextureByName('contPng'));
contPng.x = (750 - contPng.width) / 2;
contPng.y = 215;
this.addChild(contPng);
leftBtn = this._leftBtn = new engine.Sprite(getTextureByName('左按钮'));
leftBtn.anchorY = leftBtn.height - 50;
leftBtn.x = 83;
leftBtn.y = 920;
gameNode.addChild(leftBtn);
rightBtn = this._rightBtn = new engine.Sprite(getTextureByName('右按钮'));
rightBtn.anchorY = rightBtn.height - 50;
rightBtn.x = 400;
rightBtn.y = 920;
gameNode.addChild(rightBtn);
light = this._light = new engine.Sprite(getTextureByName('灯'));
light.x = 12;
light.y = 44;
gameNode.addChild(light);
basket_bottom = this._basket_bottom = new engine.Sprite(getTextureByName('basket_bottom'));
basket_bottom.x = (contPng.width - basket_bottom.width) / 2;
basket_bottom.y = 85;
contPng.addChild(basket_bottom);
tmpRect = new engine.Rect();
tmpRect.x = 230;
tmpRect.y = 372;
tmpRect.width = 300;
tmpRect.height = 300;
this.addChild(tmpRect);
basket_bottom.mask = tmpRect;
basket_top = this._basket_top = new engine.Sprite(getTextureByName('basket_top'));
basket_top.x = 287;
basket_top.y = 485;
this.addChild(basket_top);
glass = this._basket_top = new engine.Sprite(getTextureByName('玻璃'));
glass.x = (750 - glass.width) / 2;
glass.y = 340;
this.addChild(glass);
gameData = this._gameData = new GameData(contPng, color);
contPng.addChild(gameData);
countDown = this._countDown = new engine.Sprite(getTextureByName('倒计时'));
countDown.x = 5;
countDown.y = 180;
this.addChild(countDown);
this._curLevelTime = getlevelTime();
countDownLabel = this._countDownLabel = Tool.getLabel(this._curLevelTime, 48, "#ffffff");
countDownLabel.x = (countDown.width - countDownLabel.width) / 2;
countDownLabel.y = (countDown.height - countDownLabel.height) / 2 - 5;
countDown.addChild(countDownLabel);
this.initGameHint();
this.startHandle();
this.levelHint();
return [2];
});
});
};
GameView.prototype.levelHint = function () {
var lvBg = this._lvbg = new engine.Rect();
lvBg.fillColor = 0x000000;
lvBg.alpha = 0.7;
lvBg.width = 750;
lvBg.height = 1624;
lvBg.x = lvBg.y = 0;
lvBg.visible = false;
this.addChild(lvBg);
var lv_common = this._lv_common = new engine.Sprite(getTextureByName('lv_common'));
lv_common.x = (750 - lv_common.width) / 2;
lv_common.y = 500;
lv_common.visible = false;
this.addChild(lv_common);
var lv1 = this._lv = new engine.Sprite(getTextureByName('lv1'));
lv1.anchorTexture.set(0.5, 0.5);
lv1.x = lv_common.width / 2;
lv1.y = 80;
lv_common.addChild(lv1);
var lv1_label = this._lv_label = Tool.getLabel("5", 38, "#28c1ec", true, engine.TEXT_ALIGN.CENTER);
lv1_label.width = 100;
lv1_label.x = 205;
lv1_label.y = 205;
lv1_label.fillColor = 0xffffff;
lv_common.addChild(lv1_label);
};
GameView.prototype.initGameHint = function () {
var awesome = new engine.Sprite(getTextureByName('awesome'));
awesome.anchorTexture.set(0.5, 0.5);
awesome.x = 520;
awesome.y = 490;
awesome.alpha = 0;
this.addChild(awesome);
this.gameHint['awesome'] = awesome;
var cool = new engine.Sprite(getTextureByName('cool'));
cool.anchorTexture.set(0.5, 0.5);
cool.x = 520;
cool.y = 490;
cool.alpha = 0;
this.addChild(cool);
this.gameHint['cool'] = cool;
var good = new engine.Sprite(getTextureByName('good'));
good.anchorTexture.set(0.5, 0.5);
good.x = 520;
good.y = 490;
good.alpha = 0;
this.addChild(good);
this.gameHint['good'] = good;
var great = new engine.Sprite(getTextureByName('great'));
great.anchorTexture.set(0.5, 0.5);
great.x = 520;
great.y = 490;
great.alpha = 0;
this.addChild(great);
this.gameHint['great'] = great;
var perfect = new engine.Sprite(getTextureByName('perfect'));
perfect.anchorTexture.set(0.5, 0.5);
perfect.x = 530;
perfect.y = 490;
perfect.alpha = 0;
this.addChild(perfect);
this.gameHint['perfect'] = perfect;
var unbelievable = new engine.Sprite(getTextureByName('unbelievable'));
unbelievable.anchorTexture.set(0.5, 0.5);
unbelievable.x = 480;
unbelievable.y = 460;
unbelievable.alpha = 0;
this.addChild(unbelievable);
this.gameHint['unbelievable'] = unbelievable;
};
GameView.prototype.startNextLevel = function () {
this.clearAwardBody();
this.playLevelAni();
setTouchEnabled(true);
createItems(this);
this._gameData.scorePosUpdate();
this._gameData.resetMask();
this._gameData.levelUpdate();
this._curLevelTime = getlevelTime();
this._countDownLabel.text = this._curLevelTime;
this._countDownLabel.x = (this._countDown.width - this._countDownLabel.width) / 2;
this.runEngine();
};
GameView.prototype.themeChange = function (data) {
this._countDown.texture = engine.Texture.fromImage(data.gameCountdownImage);
this._leftBtn.texture = engine.Texture.fromImage(data.leftButtonImage);
this._leftBtn.anchorY = this._leftBtn.height - 50;
this._leftBtn.x = 83;
this._leftBtn.y = 920;
this._rightBtn.texture = engine.Texture.fromImage(data.rightButtonImage);
this._rightBtn.anchorY = this._rightBtn.height - 50;
this._rightBtn.x = 400;
this._rightBtn.y = 920;
};
GameView.prototype.revive = function () {
setTouchEnabled(true);
this.runEngine();
};
GameView.prototype.startHandle = function () {
var engineMatter = Matter.Engine.create();
this._engine = engineMatter;
this._engine.world.gravity.y = 0.2;
this.egretRenderContainer = new engine.Sprite();
this.addChild(this.egretRenderContainer);
this._egretRender = new EgretRender(this.egretRenderContainer, this._engine);
var options = {
width: 750,
height: 1624,
wireframes: !1,
};
var render = Matter.Render.create({
element: document.getElementById('debugCanvas'),
engine: engineMatter,
options: options
});
Matter.Render.run(render);
this.runGame();
};
GameView.prototype.runGame = function () {
var _this = this;
createBox(this);
Matter.Events.on(this._engine, 'beforeUpdate', function () {
if (!_this.addForce)
return;
_this.addForce = false;
var isleft = _this.stageX < 375;
var start = isleft ? { x: 180, y: 1050 } : { x: 560, y: 1050 };
var scale = 2.2;
for (var i = 0; i < 15; i++) {
setTimeout(function () {
var r = _this.random(10, 14);
var bubblePic;
bubblePic = createBubblePic(r);
var basex = 0.02;
var xoffset = 0.007;
var fx = isleft ? _this.random(-basex, basex) : _this.random(-basex, basex);
var padding = 50;
var startx = _this.random(start.x - padding, start.x + padding);
if (fx < -xoffset || fx > xoffset)
bubblePic = null;
var body = _this._egretRender.circle(startx, start.y, r, bubblePic, {
density: 0.001 * 3,
restitution: 1,
force: { x: fx * scale, y: -0.02 * scale },
collisionFilter: { group: bubbleGroup, category: bubble, mask: bubbleMask }
});
setTimeout(function () {
_this._egretRender.remove(body);
}, 1000);
}, Math.random() * 200);
}
var _loop_1 = function (j) {
var start_1 = isleft ? { x: 180 + 50, y: 1050 + 30 } : { x: 560 - 50, y: 1050 + 30 };
var r = _this.random(10, 14);
var body = _this._egretRender.circle(start_1.x, start_1.y, r, null, {
density: 0.001 * 3,
restitution: 1,
force: { x: (isleft ? 1 : -1) * 0.02 * 1.7, y: 0 },
collisionFilter: { group: bubbleGroup, category: bubble, mask: bubbleMask }
});
setTimeout(function () {
_this._egretRender.remove(body);
}, 1000);
};
for (var j = 0; j < 1; j++) {
_loop_1();
}
});
this._leftBtn.addEventListener(engine.MouseEvent.CLICK, function (e) {
if (!getTouchEnabled())
return;
_this.addForce = true;
_this.stageX = e.stageX;
stopStandbyBubblesLeft();
clearTimeout(_this._startStandbyBubblesLeft);
_this._startStandbyBubblesLeft = setTimeout(function () {
startStandbyBubblesLeft(_this._egretRender);
}, 1000);
}, this);
this._rightBtn.addEventListener(engine.MouseEvent.CLICK, function (e) {
if (!getTouchEnabled())
return;
_this.addForce = true;
_this.stageX = e.stageX;
stopStandbyBubblesRight();
clearTimeout(_this._startStandbyBubblesRight);
_this._startStandbyBubblesRight = setTimeout(function () {
startStandbyBubblesRight(_this._egretRender);
}, 1000);
}, this);
createBtns(this);
startStandbyBubblesLeft(this._egretRender);
startStandbyBubblesRight(this._egretRender);
};
GameView.prototype.enterFrame = function () {
var now = Date.now();
var deltaTime = this.lastTime ? now - this.lastTime : 16.7;
this.lastTime = now;
this._frameCount += deltaTime;
if (this._frameCount >= 1000) {
this._frameCount = 0;
this.updateCountDown();
}
if (deltaTime > 20)
deltaTime = 20;
Matter.Engine.update(this._engine, deltaTime);
this._egretRender.run();
check(this);
return false;
};
GameView.prototype.random = function (start, end) {
var n = end - start;
return Math.random() * n + start;
};
GameView.prototype.runEngine = function () {
engine.gameStage.addEventListener(engine.Event.ENTER_FRAME, this.enterFrame, this);
};
GameView.prototype.updateCountDown = function () {
this._curLevelTime--;
this._countDownLabel.text = this._curLevelTime;
this._countDownLabel.x = (this._countDown.width - this._countDownLabel.width) / 2;
if (this._curLevelTime <= 0) {
this.end();
console.log('时间结束');
}
};
GameView.prototype.onBoom = function () {
this.end();
};
GameView.prototype.addScore = function () {
addScore(1);
if (getScore() >= getlevelMax()) {
setTouchEnabled(false);
engine.gameStage.removeEventListener(engine.Event.ENTER_FRAME, this.enterFrame, this);
engine.globalEvent.dispatchEvent('seabed-game-success', { level: getCurLevel(), score: getScore() });
}
this._gameData.scorePosUpdate();
};
GameView.prototype.playLevelAni = function () {
var _this = this;
var lv = getCurLevel();
this._lv.texture = getTextureByName("lv" + lv);
this._lv_label.text = getlevelMax() + '';
this._lvbg.visible = true;
this._lv_common.visible = true;
engine.Tween.get(this._lv_common).set({ y: 500 - 1624 }).to({ y: 500 }, 700, engine.Ease.backOut)
.wait(1000).to({ y: 1624 + 500 }, 500, engine.Ease.backIn)
.call(function () {
_this._lvbg.visible = false;
});
};
GameView.prototype.clearAwardBody = function () {
var _this = this;
var bodies = Matter.Composite.allBodies(this._engine.world);
var isAward = function (i) { return i.collisionFilter.group == award; };
bodies.forEach(function (i) {
if (isAward(i))
_this._egretRender.remove(i);
});
};
GameView.prototype.end = function () {
engine.gameStage.removeEventListener(engine.Event.ENTER_FRAME, this.enterFrame, this);
engine.globalEvent.dispatchEvent('seabed-game-fail', { level: getCurLevel(), score: getScore(), time: this._curLevelTime });
setTouchEnabled(false);
};
return GameView;
}(engine.Container));
//# sourceMappingURL=GameView.js.map
var GameWrapper = (function (_super) {
tslib.__extends(GameWrapper, _super);
function GameWrapper() {
var _this = _super.call(this) || this;
engine.globalEvent.addEventListener('seabed-game-start', _this.start, _this);
engine.globalEvent.addEventListener('seabed-game-revive', _this.revive, _this);
engine.globalEvent.addEventListener('seabed-game-startNextLevel', _this.startNextLevel, _this);
engine.globalEvent.addEventListener('seabed-game-themeChange', _this.themeChange, _this);
var gameView = _this._gameView = new GameView();
_this.addChild(gameView);
return _this;
}
GameWrapper.prototype.start = function (event) {
setlevelData();
this.initData();
this._gameView.start(event.data.color);
['coin', 'boom', 'fail', 'success'].forEach(function (element) {
getJsonAsset(element);
});
};
GameWrapper.prototype.startNextLevel = function (event) {
setScore(0);
setCurLevel(parseInt(event.data.level));
this._gameView.startNextLevel();
};
GameWrapper.prototype.initData = function () {
setScore(0);
setCurLevel(1);
};
GameWrapper.prototype.revive = function () {
this._gameView.revive();
};
GameWrapper.prototype.themeChange = function (event) {
this._gameView.themeChange(event.data.resData);
};
return GameWrapper;
}(engine.Container));
function index (props) {
prepareProps();
injectProps(props);
var instance = new GameWrapper();
return instance;
}
//# sourceMappingURL=index.js.map
return index;
})));
//# sourceMappingURL=main.js.map
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
/**
* matter-js 0.14.2 by @liabru 2018-06-11
* http://brm.io/matter-js/
* License MIT
*/
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.Matter=e()}}(function(){return function(){function e(t,n,o){function i(s,a){if(!n[s]){if(!t[s]){var l="function"==typeof require&&require;if(!a&&l)return l(s,!0);if(r)return r(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var d=n[s]={exports:{}};t[s][0].call(d.exports,function(e){return i(t[s][1][e]||e)},d,d.exports,e,t,n,o)}return n[s].exports}for(var r="function"==typeof require&&require,s=0;s<o.length;s++)i(o[s]);return i}return e}()({1:[function(e,t,n){var o={};t.exports=o;var i=e("../geometry/Vertices"),r=e("../geometry/Vector"),s=e("../core/Sleeping"),a=(e("../render/Render"),e("../core/Common")),l=e("../geometry/Bounds"),c=e("../geometry/Axes");!function(){o._inertiaScale=4,
o._nextCollidingGroupId=1,o._nextNonCollidingGroupId=-1,o._nextCategory=1,o.create=function(t){var n={id:a.nextId(),type:"body",label:"Body",parts:[],plugin:{},angle:0,vertices:i.fromPath("L 0 0 L 40 0 L 40 40 L 0 40"),position:{x:0,y:0},force:{x:0,y:0},torque:0,positionImpulse:{x:0,y:0},constraintImpulse:{x:0,y:0,angle:0},totalContacts:0,speed:0,angularSpeed:0,velocity:{x:0,y:0},angularVelocity:0,isSensor:!1,isStatic:!1,isSleeping:!1,motion:0,sleepThreshold:60,density:.001,restitution:0,friction:.1,frictionStatic:.5,frictionAir:.01,collisionFilter:{category:1,mask:4294967295,group:0},slop:.05,timeScale:1,render:{visible:!0,opacity:1,sprite:{xScale:1,yScale:1,xOffset:0,yOffset:0},lineWidth:0}},o=a.extend(n,t);return e(o,t),o},o.nextGroup=function(e){return e?o._nextNonCollidingGroupId--:o._nextCollidingGroupId++},o.nextCategory=function(){return o._nextCategory=o._nextCategory<<1,o._nextCategory};var e=function(e,t){t=t||{},o.set(e,{bounds:e.bounds||l.create(e.vertices),
positionPrev:e.positionPrev||r.clone(e.position),anglePrev:e.anglePrev||e.angle,vertices:e.vertices,parts:e.parts||[e],isStatic:e.isStatic,isSleeping:e.isSleeping,parent:e.parent||e}),i.rotate(e.vertices,e.angle,e.position),c.rotate(e.axes,e.angle),l.update(e.bounds,e.vertices,e.velocity),o.set(e,{axes:t.axes||e.axes,area:t.area||e.area,mass:t.mass||e.mass,inertia:t.inertia||e.inertia});var n=e.isStatic?"#2e2b44":a.choose(["#006BA6","#0496FF","#FFBC42","#D81159","#8F2D56"]);e.render.fillStyle=e.render.fillStyle||n,e.render.strokeStyle=e.render.strokeStyle||"#000",e.render.sprite.xOffset+=-(e.bounds.min.x-e.position.x)/(e.bounds.max.x-e.bounds.min.x),e.render.sprite.yOffset+=-(e.bounds.min.y-e.position.y)/(e.bounds.max.y-e.bounds.min.y)};o.set=function(e,t,n){var i;"string"==typeof t&&(i=t,t={},t[i]=n);for(i in t)if(n=t[i],t.hasOwnProperty(i))switch(i){case"isStatic":o.setStatic(e,n);break;case"isSleeping":s.set(e,n);break;case"mass":o.setMass(e,n);break;case"density":o.setDensity(e,n)
;break;case"inertia":o.setInertia(e,n);break;case"vertices":o.setVertices(e,n);break;case"position":o.setPosition(e,n);break;case"angle":o.setAngle(e,n);break;case"velocity":o.setVelocity(e,n);break;case"angularVelocity":o.setAngularVelocity(e,n);break;case"parts":o.setParts(e,n);break;default:e[i]=n}},o.setStatic=function(e,t){for(var n=0;n<e.parts.length;n++){var o=e.parts[n];o.isStatic=t,t?(o._original={restitution:o.restitution,friction:o.friction,mass:o.mass,inertia:o.inertia,density:o.density,inverseMass:o.inverseMass,inverseInertia:o.inverseInertia},o.restitution=0,o.friction=1,o.mass=o.inertia=o.density=1/0,o.inverseMass=o.inverseInertia=0,o.positionPrev.x=o.position.x,o.positionPrev.y=o.position.y,o.anglePrev=o.angle,o.angularVelocity=0,o.speed=0,o.angularSpeed=0,o.motion=0):o._original&&(o.restitution=o._original.restitution,o.friction=o._original.friction,o.mass=o._original.mass,o.inertia=o._original.inertia,o.density=o._original.density,
o.inverseMass=o._original.inverseMass,o.inverseInertia=o._original.inverseInertia,delete o._original)}},o.setMass=function(e,t){var n=e.inertia/(e.mass/6);e.inertia=n*(t/6),e.inverseInertia=1/e.inertia,e.mass=t,e.inverseMass=1/e.mass,e.density=e.mass/e.area},o.setDensity=function(e,t){o.setMass(e,t*e.area),e.density=t},o.setInertia=function(e,t){e.inertia=t,e.inverseInertia=1/e.inertia},o.setVertices=function(e,t){t[0].body===e?e.vertices=t:e.vertices=i.create(t,e),e.axes=c.fromVertices(e.vertices),e.area=i.area(e.vertices),o.setMass(e,e.density*e.area);var n=i.centre(e.vertices);i.translate(e.vertices,n,-1),o.setInertia(e,o._inertiaScale*i.inertia(e.vertices,e.mass)),i.translate(e.vertices,e.position),l.update(e.bounds,e.vertices,e.velocity)},o.setParts=function(e,t,n){var r;for(t=t.slice(0),e.parts.length=0,e.parts.push(e),e.parent=e,r=0;r<t.length;r++){var s=t[r];s!==e&&(s.parent=e,e.parts.push(s))}if(1!==e.parts.length){if(n=void 0===n||n){var a=[]
;for(r=0;r<t.length;r++)a=a.concat(t[r].vertices);i.clockwiseSort(a);var l=i.hull(a),c=i.centre(l);o.setVertices(e,l),i.translate(e.vertices,c)}var d=o._totalProperties(e);e.area=d.area,e.parent=e,e.position.x=d.centre.x,e.position.y=d.centre.y,e.positionPrev.x=d.centre.x,e.positionPrev.y=d.centre.y,o.setMass(e,d.mass),o.setInertia(e,d.inertia),o.setPosition(e,d.centre)}},o.setPosition=function(e,t){var n=r.sub(t,e.position);e.positionPrev.x+=n.x,e.positionPrev.y+=n.y;for(var o=0;o<e.parts.length;o++){var s=e.parts[o];s.position.x+=n.x,s.position.y+=n.y,i.translate(s.vertices,n),l.update(s.bounds,s.vertices,e.velocity)}},o.setAngle=function(e,t){var n=t-e.angle;e.anglePrev+=n;for(var o=0;o<e.parts.length;o++){var s=e.parts[o];s.angle+=n,i.rotate(s.vertices,n,e.position),c.rotate(s.axes,n),l.update(s.bounds,s.vertices,e.velocity),o>0&&r.rotateAbout(s.position,n,e.position,s.position)}},o.setVelocity=function(e,t){e.positionPrev.x=e.position.x-t.x,e.positionPrev.y=e.position.y-t.y,
e.velocity.x=t.x,e.velocity.y=t.y,e.speed=r.magnitude(e.velocity)},o.setAngularVelocity=function(e,t){e.anglePrev=e.angle-t,e.angularVelocity=t,e.angularSpeed=Math.abs(e.angularVelocity)},o.translate=function(e,t){o.setPosition(e,r.add(e.position,t))},o.rotate=function(e,t,n){if(n){var i=Math.cos(t),r=Math.sin(t),s=e.position.x-n.x,a=e.position.y-n.y;o.setPosition(e,{x:n.x+(s*i-a*r),y:n.y+(s*r+a*i)}),o.setAngle(e,e.angle+t)}else o.setAngle(e,e.angle+t)},o.scale=function(e,t,n,r){var s=0,a=0;r=r||e.position;for(var d=0;d<e.parts.length;d++){var u=e.parts[d];i.scale(u.vertices,t,n,r),u.axes=c.fromVertices(u.vertices),u.area=i.area(u.vertices),o.setMass(u,e.density*u.area),i.translate(u.vertices,{x:-u.position.x,y:-u.position.y}),o.setInertia(u,o._inertiaScale*i.inertia(u.vertices,u.mass)),i.translate(u.vertices,{x:u.position.x,y:u.position.y}),d>0&&(s+=u.area,a+=u.inertia),u.position.x=r.x+(u.position.x-r.x)*t,u.position.y=r.y+(u.position.y-r.y)*n,l.update(u.bounds,u.vertices,e.velocity)
}e.parts.length>1&&(e.area=s,e.isStatic||(o.setMass(e,e.density*s),o.setInertia(e,a))),e.circleRadius&&(t===n?e.circleRadius*=t:e.circleRadius=null)},o.update=function(e,t,n,o){var s=Math.pow(t*n*e.timeScale,2),a=1-e.frictionAir*n*e.timeScale,d=e.position.x-e.positionPrev.x,u=e.position.y-e.positionPrev.y;e.velocity.x=d*a*o+e.force.x/e.mass*s,e.velocity.y=u*a*o+e.force.y/e.mass*s,e.positionPrev.x=e.position.x,e.positionPrev.y=e.position.y,e.position.x+=e.velocity.x,e.position.y+=e.velocity.y,e.angularVelocity=(e.angle-e.anglePrev)*a*o+e.torque/e.inertia*s,e.anglePrev=e.angle,e.angle+=e.angularVelocity,e.speed=r.magnitude(e.velocity),e.angularSpeed=Math.abs(e.angularVelocity);for(var p=0;p<e.parts.length;p++){var f=e.parts[p];i.translate(f.vertices,e.velocity),p>0&&(f.position.x+=e.velocity.x,f.position.y+=e.velocity.y),0!==e.angularVelocity&&(i.rotate(f.vertices,e.angularVelocity,e.position),c.rotate(f.axes,e.angularVelocity),
p>0&&r.rotateAbout(f.position,e.angularVelocity,e.position,f.position)),l.update(f.bounds,f.vertices,e.velocity)}},o.applyForce=function(e,t,n){e.force.x+=n.x,e.force.y+=n.y;var o={x:t.x-e.position.x,y:t.y-e.position.y};e.torque+=o.x*n.y-o.y*n.x},o._totalProperties=function(e){for(var t={mass:0,area:0,inertia:0,centre:{x:0,y:0}},n=1===e.parts.length?0:1;n<e.parts.length;n++){var o=e.parts[n],i=o.mass!==1/0?o.mass:1;t.mass+=i,t.area+=o.area,t.inertia+=o.inertia,t.centre=r.add(t.centre,r.mult(o.position,i))}return t.centre=r.div(t.centre,t.mass),t}}()},{"../core/Common":14,"../core/Sleeping":22,"../geometry/Axes":25,"../geometry/Bounds":26,"../geometry/Vector":28,"../geometry/Vertices":29,"../render/Render":31}],2:[function(e,t,n){var o={};t.exports=o;var i=e("../core/Events"),r=e("../core/Common"),s=e("../geometry/Bounds"),a=e("./Body");!function(){o.create=function(e){return r.extend({id:r.nextId(),type:"composite",parent:null,isModified:!1,bodies:[],constraints:[],composites:[],
label:"Composite",plugin:{}},e)},o.setModified=function(e,t,n,i){if(e.isModified=t,n&&e.parent&&o.setModified(e.parent,t,n,i),i)for(var r=0;r<e.composites.length;r++){var s=e.composites[r];o.setModified(s,t,n,i)}},o.add=function(e,t){var n=[].concat(t);i.trigger(e,"beforeAdd",{object:t});for(var s=0;s<n.length;s++){var a=n[s];switch(a.type){case"body":if(a.parent!==a){r.warn("Composite.add: skipped adding a compound body part (you must add its parent instead)");break}o.addBody(e,a);break;case"constraint":o.addConstraint(e,a);break;case"composite":o.addComposite(e,a);break;case"mouseConstraint":o.addConstraint(e,a.constraint)}}return i.trigger(e,"afterAdd",{object:t}),e},o.remove=function(e,t,n){var r=[].concat(t);i.trigger(e,"beforeRemove",{object:t});for(var s=0;s<r.length;s++){var a=r[s];switch(a.type){case"body":o.removeBody(e,a,n);break;case"constraint":o.removeConstraint(e,a,n);break;case"composite":o.removeComposite(e,a,n);break;case"mouseConstraint":
o.removeConstraint(e,a.constraint)}}return i.trigger(e,"afterRemove",{object:t}),e},o.addComposite=function(e,t){return e.composites.push(t),t.parent=e,o.setModified(e,!0,!0,!1),e},o.removeComposite=function(e,t,n){var i=r.indexOf(e.composites,t);if(-1!==i&&(o.removeCompositeAt(e,i),o.setModified(e,!0,!0,!1)),n)for(var s=0;s<e.composites.length;s++)o.removeComposite(e.composites[s],t,!0);return e},o.removeCompositeAt=function(e,t){return e.composites.splice(t,1),o.setModified(e,!0,!0,!1),e},o.addBody=function(e,t){return e.bodies.push(t),o.setModified(e,!0,!0,!1),e},o.removeBody=function(e,t,n){var i=r.indexOf(e.bodies,t);if(-1!==i&&(o.removeBodyAt(e,i),o.setModified(e,!0,!0,!1)),n)for(var s=0;s<e.composites.length;s++)o.removeBody(e.composites[s],t,!0);return e},o.removeBodyAt=function(e,t){return e.bodies.splice(t,1),o.setModified(e,!0,!0,!1),e},o.addConstraint=function(e,t){return e.constraints.push(t),o.setModified(e,!0,!0,!1),e},o.removeConstraint=function(e,t,n){
var i=r.indexOf(e.constraints,t);if(-1!==i&&o.removeConstraintAt(e,i),n)for(var s=0;s<e.composites.length;s++)o.removeConstraint(e.composites[s],t,!0);return e},o.removeConstraintAt=function(e,t){return e.constraints.splice(t,1),o.setModified(e,!0,!0,!1),e},o.clear=function(e,t,n){if(n)for(var i=0;i<e.composites.length;i++)o.clear(e.composites[i],t,!0);return t?e.bodies=e.bodies.filter(function(e){return e.isStatic}):e.bodies.length=0,e.constraints.length=0,e.composites.length=0,o.setModified(e,!0,!0,!1),e},o.allBodies=function(e){for(var t=[].concat(e.bodies),n=0;n<e.composites.length;n++)t=t.concat(o.allBodies(e.composites[n]));return t},o.allConstraints=function(e){for(var t=[].concat(e.constraints),n=0;n<e.composites.length;n++)t=t.concat(o.allConstraints(e.composites[n]));return t},o.allComposites=function(e){for(var t=[].concat(e.composites),n=0;n<e.composites.length;n++)t=t.concat(o.allComposites(e.composites[n]));return t},o.get=function(e,t,n){var i,r;switch(n){case"body":
i=o.allBodies(e);break;case"constraint":i=o.allConstraints(e);break;case"composite":i=o.allComposites(e).concat(e)}return i?(r=i.filter(function(e){return e.id.toString()===t.toString()}),0===r.length?null:r[0]):null},o.move=function(e,t,n){return o.remove(e,t),o.add(n,t),e},o.rebase=function(e){for(var t=o.allBodies(e).concat(o.allConstraints(e)).concat(o.allComposites(e)),n=0;n<t.length;n++)t[n].id=r.nextId();return o.setModified(e,!0,!0,!1),e},o.translate=function(e,t,n){for(var i=n?o.allBodies(e):e.bodies,r=0;r<i.length;r++)a.translate(i[r],t);return o.setModified(e,!0,!0,!1),e},o.rotate=function(e,t,n,i){for(var r=Math.cos(t),s=Math.sin(t),l=i?o.allBodies(e):e.bodies,c=0;c<l.length;c++){var d=l[c],u=d.position.x-n.x,p=d.position.y-n.y;a.setPosition(d,{x:n.x+(u*r-p*s),y:n.y+(u*s+p*r)}),a.rotate(d,t)}return o.setModified(e,!0,!0,!1),e},o.scale=function(e,t,n,i,r){for(var s=r?o.allBodies(e):e.bodies,l=0;l<s.length;l++){var c=s[l],d=c.position.x-i.x,u=c.position.y-i.y
;a.setPosition(c,{x:i.x+d*t,y:i.y+u*n}),a.scale(c,t,n)}return o.setModified(e,!0,!0,!1),e},o.bounds=function(e){for(var t=o.allBodies(e),n=[],i=0;i<t.length;i+=1){var r=t[i];n.push(r.bounds.min,r.bounds.max)}return s.create(n)}}()},{"../core/Common":14,"../core/Events":16,"../geometry/Bounds":26,"./Body":1}],3:[function(e,t,n){var o={};t.exports=o;var i=e("./Composite"),r=(e("../constraint/Constraint"),e("../core/Common"));!function(){o.create=function(e){var t=i.create(),n={label:"World",gravity:{x:0,y:1,scale:.001},bounds:{min:{x:-1/0,y:-1/0},max:{x:1/0,y:1/0}}};return r.extend(t,n,e)}}()},{"../constraint/Constraint":12,"../core/Common":14,"./Composite":2}],4:[function(e,t,n){var o={};t.exports=o,function(){o.create=function(e){return{id:o.id(e),vertex:e,normalImpulse:0,tangentImpulse:0}},o.id=function(e){return e.body.id+"_"+e.index}}()},{}],5:[function(e,t,n){var o={};t.exports=o;var i=e("./SAT"),r=e("./Pair"),s=e("../geometry/Bounds");!function(){o.collisions=function(e,t){
for(var n=[],a=t.pairs.table,l=0;l<e.length;l++){var c=e[l][0],d=e[l][1];if((!c.isStatic&&!c.isSleeping||!d.isStatic&&!d.isSleeping)&&(o.canCollide(c.collisionFilter,d.collisionFilter)&&s.overlaps(c.bounds,d.bounds)))for(var u=c.parts.length>1?1:0;u<c.parts.length;u++)for(var p=c.parts[u],f=d.parts.length>1?1:0;f<d.parts.length;f++){var m=d.parts[f];if(p===c&&m===d||s.overlaps(p.bounds,m.bounds)){var v,y=r.id(p,m),g=a[y];v=g&&g.isActive?g.collision:null;var x=i.collides(p,m,v);x.collided&&n.push(x)}}}return n},o.canCollide=function(e,t){return e.group===t.group&&0!==e.group?e.group>0:0!=(e.mask&t.category)&&0!=(t.mask&e.category)}}()},{"../geometry/Bounds":26,"./Pair":7,"./SAT":11}],6:[function(e,t,n){var o={};t.exports=o;var i=e("./Pair"),r=e("./Detector"),s=e("../core/Common");!function(){o.create=function(e){var t={controller:o,detector:r.collisions,buckets:{},pairs:{},pairsList:[],bucketWidth:48,bucketHeight:48};return s.extend(t,e)},o.update=function(e,t,n,i){
var r,s,a,l,c,d=n.world,u=e.buckets,p=!1;for(r=0;r<t.length;r++){var f=t[r];if((!f.isSleeping||i)&&!(f.bounds.max.x<d.bounds.min.x||f.bounds.min.x>d.bounds.max.x||f.bounds.max.y<d.bounds.min.y||f.bounds.min.y>d.bounds.max.y)){var m=o._getRegion(e,f);if(!f.region||m.id!==f.region.id||i){f.region&&!i||(f.region=m);var v=o._regionUnion(m,f.region);for(s=v.startCol;s<=v.endCol;s++)for(a=v.startRow;a<=v.endRow;a++){c=o._getBucketId(s,a),l=u[c];var y=s>=m.startCol&&s<=m.endCol&&a>=m.startRow&&a<=m.endRow,g=s>=f.region.startCol&&s<=f.region.endCol&&a>=f.region.startRow&&a<=f.region.endRow;!y&&g&&g&&l&&o._bucketRemoveBody(e,l,f),(f.region===m||y&&!g||i)&&(l||(l=o._createBucket(u,c)),o._bucketAddBody(e,l,f))}f.region=m,p=!0}}}p&&(e.pairsList=o._createActivePairsList(e))},o.clear=function(e){e.buckets={},e.pairs={},e.pairsList=[]},o._regionUnion=function(e,t){var n=Math.min(e.startCol,t.startCol),i=Math.max(e.endCol,t.endCol),r=Math.min(e.startRow,t.startRow),s=Math.max(e.endRow,t.endRow)
;return o._createRegion(n,i,r,s)},o._getRegion=function(e,t){var n=t.bounds,i=Math.floor(n.min.x/e.bucketWidth),r=Math.floor(n.max.x/e.bucketWidth),s=Math.floor(n.min.y/e.bucketHeight),a=Math.floor(n.max.y/e.bucketHeight);return o._createRegion(i,r,s,a)},o._createRegion=function(e,t,n,o){return{id:e+","+t+","+n+","+o,startCol:e,endCol:t,startRow:n,endRow:o}},o._getBucketId=function(e,t){return"C"+e+"R"+t},o._createBucket=function(e,t){return e[t]=[]},o._bucketAddBody=function(e,t,n){for(var o=0;o<t.length;o++){var r=t[o];if(!(n.id===r.id||n.isStatic&&r.isStatic)){var s=i.id(n,r),a=e.pairs[s];a?a[2]+=1:e.pairs[s]=[n,r,1]}}t.push(n)},o._bucketRemoveBody=function(e,t,n){t.splice(s.indexOf(t,n),1);for(var o=0;o<t.length;o++){var r=t[o],a=i.id(n,r),l=e.pairs[a];l&&(l[2]-=1)}},o._createActivePairsList=function(e){var t,n,o=[];t=s.keys(e.pairs);for(var i=0;i<t.length;i++)n=e.pairs[t[i]],n[2]>0?o.push(n):delete e.pairs[t[i]];return o}}()},{"../core/Common":14,"./Detector":5,"./Pair":7}],
7:[function(e,t,n){var o={};t.exports=o;var i=e("./Contact");!function(){o.create=function(e,t){var n=e.bodyA,i=e.bodyB,r=e.parentA,s=e.parentB,a={id:o.id(n,i),bodyA:n,bodyB:i,contacts:{},activeContacts:[],separation:0,isActive:!0,isSensor:n.isSensor||i.isSensor,timeCreated:t,timeUpdated:t,inverseMass:r.inverseMass+s.inverseMass,friction:Math.min(r.friction,s.friction),frictionStatic:Math.max(r.frictionStatic,s.frictionStatic),restitution:Math.max(r.restitution,s.restitution),slop:Math.max(r.slop,s.slop)};return o.update(a,e,t),a},o.update=function(e,t,n){var r=e.contacts,s=t.supports,a=e.activeContacts,l=t.parentA,c=t.parentB;if(e.collision=t,e.inverseMass=l.inverseMass+c.inverseMass,e.friction=Math.min(l.friction,c.friction),e.frictionStatic=Math.max(l.frictionStatic,c.frictionStatic),e.restitution=Math.max(l.restitution,c.restitution),e.slop=Math.max(l.slop,c.slop),a.length=0,t.collided){for(var d=0;d<s.length;d++){var u=s[d],p=i.id(u),f=r[p];f?a.push(f):a.push(r[p]=i.create(u))}
e.separation=t.depth,o.setActive(e,!0,n)}else!0===e.isActive&&o.setActive(e,!1,n)},o.setActive=function(e,t,n){t?(e.isActive=!0,e.timeUpdated=n):(e.isActive=!1,e.activeContacts.length=0)},o.id=function(e,t){return e.id<t.id?"A"+e.id+"B"+t.id:"A"+t.id+"B"+e.id}}()},{"./Contact":4}],8:[function(e,t,n){var o={};t.exports=o;var i=e("./Pair"),r=e("../core/Common");!function(){o._pairMaxIdleLife=1e3,o.create=function(e){return r.extend({table:{},list:[],collisionStart:[],collisionActive:[],collisionEnd:[]},e)},o.update=function(e,t,n){var o,s,a,l,c=e.list,d=e.table,u=e.collisionStart,p=e.collisionEnd,f=e.collisionActive,m=[];for(u.length=0,p.length=0,f.length=0,l=0;l<t.length;l++)o=t[l],o.collided&&(s=i.id(o.bodyA,o.bodyB),m.push(s),a=d[s],a?(a.isActive?f.push(a):u.push(a),i.update(a,o,n)):(a=i.create(o,n),d[s]=a,u.push(a),c.push(a)));for(l=0;l<c.length;l++)a=c[l],a.isActive&&-1===r.indexOf(m,a.id)&&(i.setActive(a,!1,n),p.push(a))},o.removeOld=function(e,t){
var n,i,r,s,a=e.list,l=e.table,c=[];for(s=0;s<a.length;s++)n=a[s],i=n.collision,i.bodyA.isSleeping||i.bodyB.isSleeping?n.timeUpdated=t:t-n.timeUpdated>o._pairMaxIdleLife&&c.push(s);for(s=0;s<c.length;s++)r=c[s]-s,n=a[r],delete l[n.id],a.splice(r,1)},o.clear=function(e){return e.table={},e.list.length=0,e.collisionStart.length=0,e.collisionActive.length=0,e.collisionEnd.length=0,e}}()},{"../core/Common":14,"./Pair":7}],9:[function(e,t,n){var o={};t.exports=o;var i=e("../geometry/Vector"),r=e("./SAT"),s=e("../geometry/Bounds"),a=e("../factory/Bodies"),l=e("../geometry/Vertices");!function(){o.collides=function(e,t){for(var n=[],o=0;o<t.length;o++){var i=t[o];if(s.overlaps(i.bounds,e.bounds))for(var a=1===i.parts.length?0:1;a<i.parts.length;a++){var l=i.parts[a];if(s.overlaps(l.bounds,e.bounds)){var c=r.collides(l,e);if(c.collided){n.push(c);break}}}}return n},o.ray=function(e,t,n,r){r=r||1e-100
;for(var s=i.angle(t,n),l=i.magnitude(i.sub(t,n)),c=.5*(n.x+t.x),d=.5*(n.y+t.y),u=a.rectangle(c,d,l,r,{angle:s}),p=o.collides(u,e),f=0;f<p.length;f+=1){var m=p[f];m.body=m.bodyB=m.bodyA}return p},o.region=function(e,t,n){for(var o=[],i=0;i<e.length;i++){var r=e[i],a=s.overlaps(r.bounds,t);(a&&!n||!a&&n)&&o.push(r)}return o},o.point=function(e,t){for(var n=[],o=0;o<e.length;o++){var i=e[o];if(s.contains(i.bounds,t))for(var r=1===i.parts.length?0:1;r<i.parts.length;r++){var a=i.parts[r];if(s.contains(a.bounds,t)&&l.contains(a.vertices,t)){n.push(i);break}}}return n}}()},{"../factory/Bodies":23,"../geometry/Bounds":26,"../geometry/Vector":28,"../geometry/Vertices":29,"./SAT":11}],10:[function(e,t,n){var o={};t.exports=o;var i=e("../geometry/Vertices"),r=e("../geometry/Vector"),s=e("../core/Common"),a=e("../geometry/Bounds");!function(){o._restingThresh=4,o._restingThreshTangent=6,o._positionDampen=.9,o._positionWarming=.8,o._frictionNormalMultiplier=5,o.preSolvePosition=function(e){
var t,n,o;for(t=0;t<e.length;t++)n=e[t],n.isActive&&(o=n.activeContacts.length,n.collision.parentA.totalContacts+=o,n.collision.parentB.totalContacts+=o)},o.solvePosition=function(e,t){var n,i,s,a,l,c,d,u,p,f=r._temp[0],m=r._temp[1],v=r._temp[2],y=r._temp[3];for(n=0;n<e.length;n++)i=e[n],i.isActive&&!i.isSensor&&(s=i.collision,a=s.parentA,l=s.parentB,c=s.normal,d=r.sub(r.add(l.positionImpulse,l.position,f),r.add(a.positionImpulse,r.sub(l.position,s.penetration,m),v),y),i.separation=r.dot(c,d));for(n=0;n<e.length;n++)i=e[n],i.isActive&&!i.isSensor&&(s=i.collision,a=s.parentA,l=s.parentB,c=s.normal,p=(i.separation-i.slop)*t,(a.isStatic||l.isStatic)&&(p*=2),a.isStatic||a.isSleeping||(u=o._positionDampen/a.totalContacts,a.positionImpulse.x+=c.x*p*u,a.positionImpulse.y+=c.y*p*u),l.isStatic||l.isSleeping||(u=o._positionDampen/l.totalContacts,l.positionImpulse.x-=c.x*p*u,l.positionImpulse.y-=c.y*p*u))},o.postSolvePosition=function(e){for(var t=0;t<e.length;t++){var n=e[t]
;if(n.totalContacts=0,0!==n.positionImpulse.x||0!==n.positionImpulse.y){for(var s=0;s<n.parts.length;s++){var l=n.parts[s];i.translate(l.vertices,n.positionImpulse),a.update(l.bounds,l.vertices,n.velocity),l.position.x+=n.positionImpulse.x,l.position.y+=n.positionImpulse.y}n.positionPrev.x+=n.positionImpulse.x,n.positionPrev.y+=n.positionImpulse.y,r.dot(n.positionImpulse,n.velocity)<0?(n.positionImpulse.x=0,n.positionImpulse.y=0):(n.positionImpulse.x*=o._positionWarming,n.positionImpulse.y*=o._positionWarming)}}},o.preSolveVelocity=function(e){var t,n,o,i,s,a,l,c,d,u,p,f,m,v,y=r._temp[0],g=r._temp[1];for(t=0;t<e.length;t++)if(o=e[t],o.isActive&&!o.isSensor)for(i=o.activeContacts,s=o.collision,a=s.parentA,l=s.parentB,c=s.normal,d=s.tangent,n=0;n<i.length;n++)u=i[n],p=u.vertex,f=u.normalImpulse,m=u.tangentImpulse,0===f&&0===m||(y.x=c.x*f+d.x*m,y.y=c.y*f+d.y*m,a.isStatic||a.isSleeping||(v=r.sub(p,a.position,g),a.positionPrev.x+=y.x*a.inverseMass,a.positionPrev.y+=y.y*a.inverseMass,
a.anglePrev+=r.cross(v,y)*a.inverseInertia),l.isStatic||l.isSleeping||(v=r.sub(p,l.position,g),l.positionPrev.x-=y.x*l.inverseMass,l.positionPrev.y-=y.y*l.inverseMass,l.anglePrev-=r.cross(v,y)*l.inverseInertia))},o.solveVelocity=function(e,t){for(var n=t*t,i=r._temp[0],a=r._temp[1],l=r._temp[2],c=r._temp[3],d=r._temp[4],u=r._temp[5],p=0;p<e.length;p++){var f=e[p];if(f.isActive&&!f.isSensor){var m=f.collision,v=m.parentA,y=m.parentB,g=m.normal,x=m.tangent,h=f.activeContacts,b=1/h.length;v.velocity.x=v.position.x-v.positionPrev.x,v.velocity.y=v.position.y-v.positionPrev.y,y.velocity.x=y.position.x-y.positionPrev.x,y.velocity.y=y.position.y-y.positionPrev.y,v.angularVelocity=v.angle-v.anglePrev,y.angularVelocity=y.angle-y.anglePrev;for(var w=0;w<h.length;w++){
var S=h[w],C=S.vertex,A=r.sub(C,v.position,a),P=r.sub(C,y.position,l),B=r.add(v.velocity,r.mult(r.perp(A),v.angularVelocity),c),M=r.add(y.velocity,r.mult(r.perp(P),y.angularVelocity),d),k=r.sub(B,M,u),I=r.dot(g,k),_=r.dot(x,k),T=Math.abs(_),R=s.sign(_),V=(1+f.restitution)*I,E=s.clamp(f.separation+I,0,1)*o._frictionNormalMultiplier,L=_,F=1/0;T>f.friction*f.frictionStatic*E*n&&(F=T,L=s.clamp(f.friction*R*n,-F,F));var O=r.cross(A,g),q=r.cross(P,g),W=b/(v.inverseMass+y.inverseMass+v.inverseInertia*O*O+y.inverseInertia*q*q);if(V*=W,L*=W,I<0&&I*I>o._restingThresh*n)S.normalImpulse=0;else{var D=S.normalImpulse;S.normalImpulse=Math.min(S.normalImpulse+V,0),V=S.normalImpulse-D}if(_*_>o._restingThreshTangent*n)S.tangentImpulse=0;else{var N=S.tangentImpulse;S.tangentImpulse=s.clamp(S.tangentImpulse+L,-F,F),L=S.tangentImpulse-N}i.x=g.x*V+x.x*L,i.y=g.y*V+x.y*L,v.isStatic||v.isSleeping||(v.positionPrev.x+=i.x*v.inverseMass,v.positionPrev.y+=i.y*v.inverseMass,
v.anglePrev+=r.cross(A,i)*v.inverseInertia),y.isStatic||y.isSleeping||(y.positionPrev.x-=i.x*y.inverseMass,y.positionPrev.y-=i.y*y.inverseMass,y.anglePrev-=r.cross(P,i)*y.inverseInertia)}}}}}()},{"../core/Common":14,"../geometry/Bounds":26,"../geometry/Vector":28,"../geometry/Vertices":29}],11:[function(e,t,n){var o={};t.exports=o;var i=e("../geometry/Vertices"),r=e("../geometry/Vector");!function(){o.collides=function(e,t,n){var s,a,l,c,d=!1;if(n){var u=e.parent,p=t.parent,f=u.speed*u.speed+u.angularSpeed*u.angularSpeed+p.speed*p.speed+p.angularSpeed*p.angularSpeed;d=n&&n.collided&&f<.2,c=n}else c={collided:!1,bodyA:e,bodyB:t};if(n&&d){var m=c.axisBody,v=m===e?t:e,y=[m.axes[n.axisNumber]];if(l=o._overlapAxes(m.vertices,v.vertices,y),c.reused=!0,l.overlap<=0)return c.collided=!1,c}else{if(s=o._overlapAxes(e.vertices,t.vertices,e.axes),s.overlap<=0)return c.collided=!1,c;if(a=o._overlapAxes(t.vertices,e.vertices,t.axes),a.overlap<=0)return c.collided=!1,c;s.overlap<a.overlap?(l=s,
c.axisBody=e):(l=a,c.axisBody=t),c.axisNumber=l.axisNumber}c.bodyA=e.id<t.id?e:t,c.bodyB=e.id<t.id?t:e,c.collided=!0,c.depth=l.overlap,c.parentA=c.bodyA.parent,c.parentB=c.bodyB.parent,e=c.bodyA,t=c.bodyB,r.dot(l.axis,r.sub(t.position,e.position))<0?c.normal={x:l.axis.x,y:l.axis.y}:c.normal={x:-l.axis.x,y:-l.axis.y},c.tangent=r.perp(c.normal),c.penetration=c.penetration||{},c.penetration.x=c.normal.x*c.depth,c.penetration.y=c.normal.y*c.depth;var g=o._findSupports(e,t,c.normal),x=[];if(i.contains(e.vertices,g[0])&&x.push(g[0]),i.contains(e.vertices,g[1])&&x.push(g[1]),x.length<2){var h=o._findSupports(t,e,r.neg(c.normal));i.contains(t.vertices,h[0])&&x.push(h[0]),x.length<2&&i.contains(t.vertices,h[1])&&x.push(h[1])}return x.length<1&&(x=[g[0]]),c.supports=x,c},o._overlapAxes=function(e,t,n){for(var i,s,a=r._temp[0],l=r._temp[1],c={overlap:Number.MAX_VALUE},d=0;d<n.length;d++){if(s=n[d],o._projectToAxis(a,e,s),o._projectToAxis(l,t,s),
(i=Math.min(a.max-l.min,l.max-a.min))<=0)return c.overlap=i,c;i<c.overlap&&(c.overlap=i,c.axis=s,c.axisNumber=d)}return c},o._projectToAxis=function(e,t,n){for(var o=r.dot(t[0],n),i=o,s=1;s<t.length;s+=1){var a=r.dot(t[s],n);a>i?i=a:a<o&&(o=a)}e.min=o,e.max=i},o._findSupports=function(e,t,n){for(var o,i,s,a,l=Number.MAX_VALUE,c=r._temp[0],d=t.vertices,u=e.position,p=0;p<d.length;p++)i=d[p],c.x=i.x-u.x,c.y=i.y-u.y,(o=-r.dot(n,c))<l&&(l=o,s=i);return i=d[s.index-1>=0?s.index-1:d.length-1],c.x=i.x-u.x,c.y=i.y-u.y,l=-r.dot(n,c),a=i,i=d[(s.index+1)%d.length],c.x=i.x-u.x,c.y=i.y-u.y,o=-r.dot(n,c),o<l&&(a=i),[s,a]}}()},{"../geometry/Vector":28,"../geometry/Vertices":29}],12:[function(e,t,n){var o={};t.exports=o;var i=e("../geometry/Vertices"),r=e("../geometry/Vector"),s=e("../core/Sleeping"),a=e("../geometry/Bounds"),l=e("../geometry/Axes"),c=e("../core/Common");!function(){o._warming=.4,o._torqueDampen=1,o._minLength=1e-6,o.create=function(e){var t=e;t.bodyA&&!t.pointA&&(t.pointA={x:0,y:0}),
t.bodyB&&!t.pointB&&(t.pointB={x:0,y:0});var n=t.bodyA?r.add(t.bodyA.position,t.pointA):t.pointA,o=t.bodyB?r.add(t.bodyB.position,t.pointB):t.pointB,i=r.magnitude(r.sub(n,o));t.length=void 0!==t.length?t.length:i,t.id=t.id||c.nextId(),t.label=t.label||"Constraint",t.type="constraint",t.stiffness=t.stiffness||(t.length>0?1:.7),t.damping=t.damping||0,t.angularStiffness=t.angularStiffness||0,t.angleA=t.bodyA?t.bodyA.angle:t.angleA,t.angleB=t.bodyB?t.bodyB.angle:t.angleB,t.plugin={};var s={visible:!0,lineWidth:2,strokeStyle:"#ffffff",type:"line",anchors:!0};return 0===t.length&&t.stiffness>.1?(s.type="pin",s.anchors=!1):t.stiffness<.9&&(s.type="spring"),t.render=c.extend(s,t.render),t},o.preSolveAll=function(e){for(var t=0;t<e.length;t+=1){var n=e[t],o=n.constraintImpulse;n.isStatic||0===o.x&&0===o.y&&0===o.angle||(n.position.x+=o.x,n.position.y+=o.y,n.angle+=o.angle)}},o.solveAll=function(e,t){for(var n=0;n<e.length;n+=1){
var i=e[n],r=!i.bodyA||i.bodyA&&i.bodyA.isStatic,s=!i.bodyB||i.bodyB&&i.bodyB.isStatic;(r||s)&&o.solve(e[n],t)}for(n=0;n<e.length;n+=1)i=e[n],r=!i.bodyA||i.bodyA&&i.bodyA.isStatic,s=!i.bodyB||i.bodyB&&i.bodyB.isStatic,r||s||o.solve(e[n],t)},o.solve=function(e,t){var n=e.bodyA,i=e.bodyB,s=e.pointA,a=e.pointB;if(n||i){n&&!n.isStatic&&(r.rotate(s,n.angle-e.angleA,s),e.angleA=n.angle),i&&!i.isStatic&&(r.rotate(a,i.angle-e.angleB,a),e.angleB=i.angle);var l=s,c=a;if(n&&(l=r.add(n.position,s)),i&&(c=r.add(i.position,a)),l&&c){var d=r.sub(l,c),u=r.magnitude(d);u<o._minLength&&(u=o._minLength);var p,f,m,v,y,g=(u-e.length)/u,x=e.stiffness<1?e.stiffness*t:e.stiffness,h=r.mult(d,g*x),b=(n?n.inverseMass:0)+(i?i.inverseMass:0),w=(n?n.inverseInertia:0)+(i?i.inverseInertia:0),S=b+w;if(e.damping){var C=r.create();m=r.div(d,u),y=r.sub(i&&r.sub(i.position,i.positionPrev)||C,n&&r.sub(n.position,n.positionPrev)||C),v=r.dot(m,y)}n&&!n.isStatic&&(f=n.inverseMass/b,n.constraintImpulse.x-=h.x*f,
n.constraintImpulse.y-=h.y*f,n.position.x-=h.x*f,n.position.y-=h.y*f,e.damping&&(n.positionPrev.x-=e.damping*m.x*v*f,n.positionPrev.y-=e.damping*m.y*v*f),p=r.cross(s,h)/S*o._torqueDampen*n.inverseInertia*(1-e.angularStiffness),n.constraintImpulse.angle-=p,n.angle-=p),i&&!i.isStatic&&(f=i.inverseMass/b,i.constraintImpulse.x+=h.x*f,i.constraintImpulse.y+=h.y*f,i.position.x+=h.x*f,i.position.y+=h.y*f,e.damping&&(i.positionPrev.x+=e.damping*m.x*v*f,i.positionPrev.y+=e.damping*m.y*v*f),p=r.cross(a,h)/S*o._torqueDampen*i.inverseInertia*(1-e.angularStiffness),i.constraintImpulse.angle+=p,i.angle+=p)}}},o.postSolveAll=function(e){for(var t=0;t<e.length;t++){var n=e[t],c=n.constraintImpulse;if(!(n.isStatic||0===c.x&&0===c.y&&0===c.angle)){s.set(n,!1);for(var d=0;d<n.parts.length;d++){var u=n.parts[d];i.translate(u.vertices,c),d>0&&(u.position.x+=c.x,u.position.y+=c.y),0!==c.angle&&(i.rotate(u.vertices,c.angle,n.position),l.rotate(u.axes,c.angle),
d>0&&r.rotateAbout(u.position,c.angle,n.position,u.position)),a.update(u.bounds,u.vertices,n.velocity)}c.angle*=o._warming,c.x*=o._warming,c.y*=o._warming}}}}()},{"../core/Common":14,"../core/Sleeping":22,"../geometry/Axes":25,"../geometry/Bounds":26,"../geometry/Vector":28,"../geometry/Vertices":29}],13:[function(e,t,n){var o={};t.exports=o;var i=e("../geometry/Vertices"),r=e("../core/Sleeping"),s=e("../core/Mouse"),a=e("../core/Events"),l=e("../collision/Detector"),c=e("./Constraint"),d=e("../body/Composite"),u=e("../core/Common"),p=e("../geometry/Bounds");!function(){o.create=function(e,t){var n=(e?e.mouse:null)||(t?t.mouse:null);n||(e&&e.render&&e.render.canvas?n=s.create(e.render.canvas):t&&t.element?n=s.create(t.element):(n=s.create(),u.warn("MouseConstraint.create: options.mouse was undefined, options.element was undefined, may not function as expected")));var i=c.create({label:"Mouse Constraint",pointA:n.position,pointB:{x:0,y:0},length:.01,stiffness:.1,angularStiffness:1,
render:{strokeStyle:"#90EE90",lineWidth:3}}),r={type:"mouseConstraint",mouse:n,element:null,body:null,constraint:i,collisionFilter:{category:1,mask:4294967295,group:0}},l=u.extend(r,t);return a.on(e,"beforeUpdate",function(){var t=d.allBodies(e.world);o.update(l,t),o._triggerEvents(l)}),l},o.update=function(e,t){var n=e.mouse,o=e.constraint,s=e.body;if(0===n.button){if(o.bodyB)r.set(o.bodyB,!1),o.pointA=n.position;else for(var c=0;c<t.length;c++)if(s=t[c],p.contains(s.bounds,n.position)&&l.canCollide(s.collisionFilter,e.collisionFilter))for(var d=s.parts.length>1?1:0;d<s.parts.length;d++){var u=s.parts[d];if(i.contains(u.vertices,n.position)){o.pointA=n.position,o.bodyB=e.body=s,o.pointB={x:n.position.x-s.position.x,y:n.position.y-s.position.y},o.angleB=s.angle,r.set(s,!1),a.trigger(e,"startdrag",{mouse:n,body:s});break}}}else o.bodyB=e.body=null,o.pointB=null,s&&a.trigger(e,"enddrag",{mouse:n,body:s})},o._triggerEvents=function(e){var t=e.mouse,n=t.sourceEvents
;n.mousemove&&a.trigger(e,"mousemove",{mouse:t}),n.mousedown&&a.trigger(e,"mousedown",{mouse:t}),n.mouseup&&a.trigger(e,"mouseup",{mouse:t}),s.clearSourceEvents(t)}}()},{"../body/Composite":2,"../collision/Detector":5,"../core/Common":14,"../core/Events":16,"../core/Mouse":19,"../core/Sleeping":22,"../geometry/Bounds":26,"../geometry/Vertices":29,"./Constraint":12}],14:[function(e,t,n){(function(n){var o={};t.exports=o,function(){o._nextId=0,o._seed=0,o._nowStartTime=+new Date,o.extend=function(e,t){var n,i;"boolean"==typeof t?(n=2,i=t):(n=1,i=!0);for(var r=n;r<arguments.length;r++){var s=arguments[r];if(s)for(var a in s)i&&s[a]&&s[a].constructor===Object?e[a]&&e[a].constructor!==Object?e[a]=s[a]:(e[a]=e[a]||{},o.extend(e[a],i,s[a])):e[a]=s[a]}return e},o.clone=function(e,t){return o.extend({},t,e)},o.keys=function(e){if(Object.keys)return Object.keys(e);var t=[];for(var n in e)t.push(n);return t},o.values=function(e){var t=[];if(Object.keys){
for(var n=Object.keys(e),o=0;o<n.length;o++)t.push(e[n[o]]);return t}for(var i in e)t.push(e[i]);return t},o.get=function(e,t,n,o){t=t.split(".").slice(n,o);for(var i=0;i<t.length;i+=1)e=e[t[i]];return e},o.set=function(e,t,n,i,r){var s=t.split(".").slice(i,r);return o.get(e,t,0,-1)[s[s.length-1]]=n,n},o.shuffle=function(e){for(var t=e.length-1;t>0;t--){var n=Math.floor(o.random()*(t+1)),i=e[t];e[t]=e[n],e[n]=i}return e},o.choose=function(e){return e[Math.floor(o.random()*e.length)]},o.isElement=function(e){return"undefined"!=typeof HTMLElement?e instanceof HTMLElement:!!(e&&e.nodeType&&e.nodeName)},o.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)},o.isFunction=function(e){return"function"==typeof e},o.isPlainObject=function(e){return"object"==typeof e&&e.constructor===Object},o.isString=function(e){return"[object String]"===toString.call(e)},o.clamp=function(e,t,n){return e<t?t:e>n?n:e},o.sign=function(e){return e<0?-1:1},o.now=function(){
if(window.performance){if(window.performance.now)return window.performance.now();if(window.performance.webkitNow)return window.performance.webkitNow()}return new Date-o._nowStartTime},o.random=function(e,n){return e=void 0!==e?e:0,n=void 0!==n?n:1,e+t()*(n-e)};var t=function(){return o._seed=(9301*o._seed+49297)%233280,o._seed/233280};o.colorToNumber=function(e){return e=e.replace("#",""),3==e.length&&(e=e.charAt(0)+e.charAt(0)+e.charAt(1)+e.charAt(1)+e.charAt(2)+e.charAt(2)),parseInt(e,16)},o.logLevel=1,o.log=function(){console&&o.logLevel>0&&o.logLevel<=3&&console.log.apply(console,["matter-js:"].concat(Array.prototype.slice.call(arguments)))},o.info=function(){console&&o.logLevel>0&&o.logLevel<=2&&console.info.apply(console,["matter-js:"].concat(Array.prototype.slice.call(arguments)))},o.warn=function(){console&&o.logLevel>0&&o.logLevel<=3&&console.warn.apply(console,["matter-js:"].concat(Array.prototype.slice.call(arguments)))},o.nextId=function(){return o._nextId++},
o.indexOf=function(e,t){if(e.indexOf)return e.indexOf(t);for(var n=0;n<e.length;n++)if(e[n]===t)return n;return-1},o.map=function(e,t){if(e.map)return e.map(t);for(var n=[],o=0;o<e.length;o+=1)n.push(t(e[o]));return n},o.topologicalSort=function(e){var t=[],n=[],i=[];for(var r in e)n[r]||i[r]||o._topologicalSort(r,n,i,e,t);return t},o._topologicalSort=function(e,t,n,i,r){var s=i[e]||[];n[e]=!0;for(var a=0;a<s.length;a+=1){var l=s[a];n[l]||(t[l]||o._topologicalSort(l,t,n,i,r))}n[e]=!1,t[e]=!0,r.push(e)},o.chain=function(){for(var e=[],t=0;t<arguments.length;t+=1){var n=arguments[t];n._chained?e.push.apply(e,n._chained):e.push(n)}var o=function(){for(var t,n=new Array(arguments.length),o=0,i=arguments.length;o<i;o++)n[o]=arguments[o];for(o=0;o<e.length;o+=1){var r=e[o].apply(t,n);void 0!==r&&(t=r)}return t};return o._chained=e,o},o.chainPathBefore=function(e,t,n){return o.set(e,t,o.chain(n,o.get(e,t)))},o.chainPathAfter=function(e,t,n){return o.set(e,t,o.chain(o.get(e,t),n))},
o._requireGlobal=function(t,o){return("undefined"!=typeof window?window[t]:void 0!==n?n[t]:null)||e(o)}}()}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],15:[function(e,t,n){var o={};t.exports=o;var i=e("../body/World"),r=e("./Sleeping"),s=e("../collision/Resolver"),a=e("../render/Render"),l=e("../collision/Pairs"),c=(e("./Metrics"),e("../collision/Grid")),d=e("./Events"),u=e("../body/Composite"),p=e("../constraint/Constraint"),f=e("./Common"),m=e("../body/Body");!function(){o.create=function(e,t){t=f.isElement(e)?t:e,e=f.isElement(e)?e:null,t=t||{},(e||t.render)&&f.warn("Engine.create: engine.render is deprecated (see docs)");var n={positionIterations:6,velocityIterations:4,constraintIterations:2,enableSleeping:!1,events:[],plugin:{},timing:{timestamp:0,timeScale:1},broadphase:{controller:c}},o=f.extend(n,t);if(e||o.render){var r={element:e,controller:a};o.render=f.extend(r,o.render)}
return o.render&&o.render.controller&&(o.render=o.render.controller.create(o.render)),o.render&&(o.render.engine=o),o.world=t.world||i.create(o.world),o.pairs=l.create(),o.broadphase=o.broadphase.controller.create(o.broadphase),o.metrics=o.metrics||{extended:!1},o},o.update=function(e,t,n){t=t||1e3/60,n=n||1;var i,a=e.world,c=e.timing,f=e.broadphase,m=[];c.timestamp+=t*c.timeScale;var v={timestamp:c.timestamp};d.trigger(e,"beforeUpdate",v);var y=u.allBodies(a),g=u.allConstraints(a);for(e.enableSleeping&&r.update(y,c.timeScale),o._bodiesApplyGravity(y,a.gravity),o._bodiesUpdate(y,t,c.timeScale,n,a.bounds),p.preSolveAll(y),i=0;i<e.constraintIterations;i++)p.solveAll(g,c.timeScale);p.postSolveAll(y),f.controller?(a.isModified&&f.controller.clear(f),f.controller.update(f,y,e,a.isModified),m=f.pairsList):m=y,a.isModified&&u.setModified(a,!1,!1,!0);var x=f.detector(m,e),h=e.pairs,b=c.timestamp;for(l.update(h,x,b),l.removeOld(h,b),e.enableSleeping&&r.afterCollisions(h.list,c.timeScale),
h.collisionStart.length>0&&d.trigger(e,"collisionStart",{pairs:h.collisionStart}),s.preSolvePosition(h.list),i=0;i<e.positionIterations;i++)s.solvePosition(h.list,c.timeScale);for(s.postSolvePosition(y),p.preSolveAll(y),i=0;i<e.constraintIterations;i++)p.solveAll(g,c.timeScale);for(p.postSolveAll(y),s.preSolveVelocity(h.list),i=0;i<e.velocityIterations;i++)s.solveVelocity(h.list,c.timeScale);return h.collisionActive.length>0&&d.trigger(e,"collisionActive",{pairs:h.collisionActive}),h.collisionEnd.length>0&&d.trigger(e,"collisionEnd",{pairs:h.collisionEnd}),o._bodiesClearForces(y),d.trigger(e,"afterUpdate",v),e},o.merge=function(e,t){if(f.extend(e,t),t.world){e.world=t.world,o.clear(e);for(var n=u.allBodies(e.world),i=0;i<n.length;i++){var s=n[i];r.set(s,!1),s.id=f.nextId()}}},o.clear=function(e){var t=e.world;l.clear(e.pairs);var n=e.broadphase;if(n.controller){var o=u.allBodies(t);n.controller.clear(n),n.controller.update(n,o,e,!0)}},o._bodiesClearForces=function(e){
for(var t=0;t<e.length;t++){var n=e[t];n.force.x=0,n.force.y=0,n.torque=0}},o._bodiesApplyGravity=function(e,t){var n=void 0!==t.scale?t.scale:.001;if((0!==t.x||0!==t.y)&&0!==n)for(var o=0;o<e.length;o++){var i=e[o];i.isStatic||i.isSleeping||(i.force.y+=i.mass*t.y*n,i.force.x+=i.mass*t.x*n)}},o._bodiesUpdate=function(e,t,n,o,i){for(var r=0;r<e.length;r++){var s=e[r];s.isStatic||s.isSleeping||m.update(s,t,n,o)}}}()},{"../body/Body":1,"../body/Composite":2,"../body/World":3,"../collision/Grid":6,"../collision/Pairs":8,"../collision/Resolver":10,"../constraint/Constraint":12,"../render/Render":31,"./Common":14,"./Events":16,"./Metrics":18,"./Sleeping":22}],16:[function(e,t,n){var o={};t.exports=o;var i=e("./Common");!function(){o.on=function(e,t,n){for(var o,i=t.split(" "),r=0;r<i.length;r++)o=i[r],e.events=e.events||{},e.events[o]=e.events[o]||[],e.events[o].push(n);return n},o.off=function(e,t,n){if(!t)return void(e.events={});"function"==typeof t&&(n=t,t=i.keys(e.events).join(" "))
;for(var o=t.split(" "),r=0;r<o.length;r++){var s=e.events[o[r]],a=[];if(n&&s)for(var l=0;l<s.length;l++)s[l]!==n&&a.push(s[l]);e.events[o[r]]=a}},o.trigger=function(e,t,n){var o,r,s,a;if(e.events){n||(n={}),o=t.split(" ");for(var l=0;l<o.length;l++)if(r=o[l],s=e.events[r]){a=i.clone(n,!1),a.name=r,a.source=e;for(var c=0;c<s.length;c++)s[c].apply(e,[a])}}}}()},{"./Common":14}],17:[function(e,t,n){var o={};t.exports=o;var i=e("./Plugin"),r=e("./Common");!function(){o.name="matter-js",o.version="0.14.2",o.uses=[],o.used=[],o.use=function(){i.use(o,Array.prototype.slice.call(arguments))},o.before=function(e,t){return e=e.replace(/^Matter./,""),r.chainPathBefore(o,e,t)},o.after=function(e,t){return e=e.replace(/^Matter./,""),r.chainPathAfter(o,e,t)}}()},{"./Common":14,"./Plugin":20}],18:[function(e,t,n){},{"../body/Composite":2,"./Common":14}],19:[function(e,t,n){var o={};t.exports=o;var i=e("../core/Common");!function(){o.create=function(e){var t={}
;return e||i.log("Mouse.create: element was undefined, defaulting to document.body","warn"),t.element=e||document.body,t.absolute={x:0,y:0},t.position={x:0,y:0},t.mousedownPosition={x:0,y:0},t.mouseupPosition={x:0,y:0},t.offset={x:0,y:0},t.scale={x:1,y:1},t.wheelDelta=0,t.button=-1,t.pixelRatio=t.element.getAttribute("data-pixel-ratio")||1,t.sourceEvents={mousemove:null,mousedown:null,mouseup:null,mousewheel:null},t.mousemove=function(e){var n=o._getRelativeMousePosition(e,t.element,t.pixelRatio);e.changedTouches&&(t.button=0,e.preventDefault()),t.absolute.x=n.x,t.absolute.y=n.y,t.position.x=t.absolute.x*t.scale.x+t.offset.x,t.position.y=t.absolute.y*t.scale.y+t.offset.y,t.sourceEvents.mousemove=e},t.mousedown=function(e){var n=o._getRelativeMousePosition(e,t.element,t.pixelRatio);e.changedTouches?(t.button=0,e.preventDefault()):t.button=e.button,t.absolute.x=n.x,t.absolute.y=n.y,t.position.x=t.absolute.x*t.scale.x+t.offset.x,t.position.y=t.absolute.y*t.scale.y+t.offset.y,
t.mousedownPosition.x=t.position.x,t.mousedownPosition.y=t.position.y,t.sourceEvents.mousedown=e},t.mouseup=function(e){var n=o._getRelativeMousePosition(e,t.element,t.pixelRatio);e.changedTouches&&e.preventDefault(),t.button=-1,t.absolute.x=n.x,t.absolute.y=n.y,t.position.x=t.absolute.x*t.scale.x+t.offset.x,t.position.y=t.absolute.y*t.scale.y+t.offset.y,t.mouseupPosition.x=t.position.x,t.mouseupPosition.y=t.position.y,t.sourceEvents.mouseup=e},t.mousewheel=function(e){t.wheelDelta=Math.max(-1,Math.min(1,e.wheelDelta||-e.detail)),e.preventDefault()},o.setElement(t,t.element),t},o.setElement=function(e,t){e.element=t,t.addEventListener("mousemove",e.mousemove),t.addEventListener("mousedown",e.mousedown),t.addEventListener("mouseup",e.mouseup),t.addEventListener("mousewheel",e.mousewheel),t.addEventListener("DOMMouseScroll",e.mousewheel),t.addEventListener("touchmove",e.mousemove),t.addEventListener("touchstart",e.mousedown),t.addEventListener("touchend",e.mouseup)},
o.clearSourceEvents=function(e){e.sourceEvents.mousemove=null,e.sourceEvents.mousedown=null,e.sourceEvents.mouseup=null,e.sourceEvents.mousewheel=null,e.wheelDelta=0},o.setOffset=function(e,t){e.offset.x=t.x,e.offset.y=t.y,e.position.x=e.absolute.x*e.scale.x+e.offset.x,e.position.y=e.absolute.y*e.scale.y+e.offset.y},o.setScale=function(e,t){e.scale.x=t.x,e.scale.y=t.y,e.position.x=e.absolute.x*e.scale.x+e.offset.x,e.position.y=e.absolute.y*e.scale.y+e.offset.y},o._getRelativeMousePosition=function(e,t,n){var o,i,r=t.getBoundingClientRect(),s=document.documentElement||document.body.parentNode||document.body,a=void 0!==window.pageXOffset?window.pageXOffset:s.scrollLeft,l=void 0!==window.pageYOffset?window.pageYOffset:s.scrollTop,c=e.changedTouches;return c?(o=c[0].pageX-r.left-a,i=c[0].pageY-r.top-l):(o=e.pageX-r.left-a,i=e.pageY-r.top-l),{x:o/(t.clientWidth/(t.width||t.clientWidth)*n),y:i/(t.clientHeight/(t.height||t.clientHeight)*n)}}}()},{"../core/Common":14}],20:[function(e,t,n){
var o={};t.exports=o;var i=e("./Common");!function(){o._registry={},o.register=function(e){if(o.isPlugin(e)||i.warn("Plugin.register:",o.toString(e),"does not implement all required fields."),e.name in o._registry){var t=o._registry[e.name],n=o.versionParse(e.version).number,r=o.versionParse(t.version).number;n>r?(i.warn("Plugin.register:",o.toString(t),"was upgraded to",o.toString(e)),o._registry[e.name]=e):n<r?i.warn("Plugin.register:",o.toString(t),"can not be downgraded to",o.toString(e)):e!==t&&i.warn("Plugin.register:",o.toString(e),"is already registered to different plugin object")}else o._registry[e.name]=e;return e},o.resolve=function(e){return o._registry[o.dependencyParse(e).name]},o.toString=function(e){return"string"==typeof e?e:(e.name||"anonymous")+"@"+(e.version||e.range||"0.0.0")},o.isPlugin=function(e){return e&&e.name&&e.version&&e.install},o.isUsed=function(e,t){return e.used.indexOf(t)>-1},o.isFor=function(e,t){var n=e.for&&o.dependencyParse(e.for)
;return!e.for||t.name===n.name&&o.versionSatisfies(t.version,n.range)},o.use=function(e,t){if(e.uses=(e.uses||[]).concat(t||[]),0===e.uses.length)return void i.warn("Plugin.use:",o.toString(e),"does not specify any dependencies to install.");for(var n=o.dependencies(e),r=i.topologicalSort(n),s=[],a=0;a<r.length;a+=1)if(r[a]!==e.name){var l=o.resolve(r[a]);l?o.isUsed(e,l.name)||(o.isFor(l,e)||(i.warn("Plugin.use:",o.toString(l),"is for",l.for,"but installed on",o.toString(e)+"."),l._warned=!0),l.install?l.install(e):(i.warn("Plugin.use:",o.toString(l),"does not specify an install function."),l._warned=!0),l._warned?(s.push("🔶 "+o.toString(l)),delete l._warned):s.push("✅ "+o.toString(l)),e.used.push(l.name)):s.push("❌ "+r[a])}s.length>0&&i.info(s.join(" "))},o.dependencies=function(e,t){var n=o.dependencyParse(e),r=n.name;if(t=t||{},!(r in t)){e=o.resolve(e)||e,t[r]=i.map(e.uses||[],function(t){o.isPlugin(t)&&o.register(t);var r=o.dependencyParse(t),s=o.resolve(t)
;return s&&!o.versionSatisfies(s.version,r.range)?(i.warn("Plugin.dependencies:",o.toString(s),"does not satisfy",o.toString(r),"used by",o.toString(n)+"."),s._warned=!0,e._warned=!0):s||(i.warn("Plugin.dependencies:",o.toString(t),"used by",o.toString(n),"could not be resolved."),e._warned=!0),r.name});for(var s=0;s<t[r].length;s+=1)o.dependencies(t[r][s],t);return t}},o.dependencyParse=function(e){if(i.isString(e)){return/^[\w-]+(@(\*|[\^~]?\d+\.\d+\.\d+(-[0-9A-Za-z-]+)?))?$/.test(e)||i.warn("Plugin.dependencyParse:",e,"is not a valid dependency string."),{name:e.split("@")[0],range:e.split("@")[1]||"*"}}return{name:e.name,range:e.range||e.version}},o.versionParse=function(e){/^\*|[\^~]?\d+\.\d+\.\d+(-[0-9A-Za-z-]+)?$/.test(e)||i.warn("Plugin.versionParse:",e,"is not a valid version or range.");var t=e.split("-");e=t[0];var n=isNaN(Number(e[0])),o=n?e.substr(1):e,r=i.map(o.split("."),function(e){return Number(e)});return{isRange:n,version:o,range:e,operator:n?e[0]:"",parts:r,
prerelease:t[1],number:1e8*r[0]+1e4*r[1]+r[2]}},o.versionSatisfies=function(e,t){t=t||"*";var n=o.versionParse(t),i=n.parts,r=o.versionParse(e),s=r.parts;if(n.isRange){if("*"===n.operator||"*"===e)return!0;if("~"===n.operator)return s[0]===i[0]&&s[1]===i[1]&&s[2]>=i[2];if("^"===n.operator)return i[0]>0?s[0]===i[0]&&r.number>=n.number:i[1]>0?s[1]===i[1]&&s[2]>=i[2]:s[2]===i[2]}return e===t||"*"===e}}()},{"./Common":14}],21:[function(e,t,n){var o={};t.exports=o;var i=e("./Events"),r=e("./Engine"),s=e("./Common");!function(){var e,t;if("undefined"!=typeof window&&(e=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame,t=window.cancelAnimationFrame||window.mozCancelAnimationFrame||window.webkitCancelAnimationFrame||window.msCancelAnimationFrame),!e){var n;e=function(e){n=setTimeout(function(){e(s.now())},1e3/60)},t=function(){clearTimeout(n)}}o.create=function(e){var t={fps:60,correction:1,deltaSampleSize:60,
counterTimestamp:0,frameCounter:0,deltaHistory:[],timePrev:null,timeScalePrev:1,frameRequestId:null,isFixed:!1,enabled:!0},n=s.extend(t,e);return n.delta=n.delta||1e3/n.fps,n.deltaMin=n.deltaMin||1e3/n.fps,n.deltaMax=n.deltaMax||1e3/(.5*n.fps),n.fps=1e3/n.delta,n},o.run=function(t,n){return void 0!==t.positionIterations&&(n=t,t=o.create()),function i(r){t.frameRequestId=e(i),r&&t.enabled&&o.tick(t,n,r)}(),t},o.tick=function(e,t,n){var o,s=t.timing,a=1,l={timestamp:s.timestamp};i.trigger(e,"beforeTick",l),i.trigger(t,"beforeTick",l),e.isFixed?o=e.delta:(o=n-e.timePrev||e.delta,e.timePrev=n,e.deltaHistory.push(o),e.deltaHistory=e.deltaHistory.slice(-e.deltaSampleSize),o=Math.min.apply(null,e.deltaHistory),o=o<e.deltaMin?e.deltaMin:o,o=o>e.deltaMax?e.deltaMax:o,a=o/e.delta,e.delta=o),0!==e.timeScalePrev&&(a*=s.timeScale/e.timeScalePrev),0===s.timeScale&&(a=0),e.timeScalePrev=s.timeScale,e.correction=a,e.frameCounter+=1,
n-e.counterTimestamp>=1e3&&(e.fps=e.frameCounter*((n-e.counterTimestamp)/1e3),e.counterTimestamp=n,e.frameCounter=0),i.trigger(e,"tick",l),i.trigger(t,"tick",l),t.world.isModified&&t.render&&t.render.controller&&t.render.controller.clear&&t.render.controller.clear(t.render),i.trigger(e,"beforeUpdate",l),r.update(t,o,a),i.trigger(e,"afterUpdate",l),t.render&&t.render.controller&&(i.trigger(e,"beforeRender",l),i.trigger(t,"beforeRender",l),t.render.controller.world(t.render),i.trigger(e,"afterRender",l),i.trigger(t,"afterRender",l)),i.trigger(e,"afterTick",l),i.trigger(t,"afterTick",l)},o.stop=function(e){t(e.frameRequestId)},o.start=function(e,t){o.run(e,t)}}()},{"./Common":14,"./Engine":15,"./Events":16}],22:[function(e,t,n){var o={};t.exports=o;var i=e("./Events");!function(){o._motionWakeThreshold=.18,o._motionSleepThreshold=.08,o._minBias=.9,o.update=function(e,t){for(var n=t*t*t,i=0;i<e.length;i++){var r=e[i],s=r.speed*r.speed+r.angularSpeed*r.angularSpeed
;if(0===r.force.x&&0===r.force.y){var a=Math.min(r.motion,s),l=Math.max(r.motion,s);r.motion=o._minBias*a+(1-o._minBias)*l,r.sleepThreshold>0&&r.motion<o._motionSleepThreshold*n?(r.sleepCounter+=1,r.sleepCounter>=r.sleepThreshold&&o.set(r,!0)):r.sleepCounter>0&&(r.sleepCounter-=1)}else o.set(r,!1)}},o.afterCollisions=function(e,t){for(var n=t*t*t,i=0;i<e.length;i++){var r=e[i];if(r.isActive){var s=r.collision,a=s.bodyA.parent,l=s.bodyB.parent;if(!(a.isSleeping&&l.isSleeping||a.isStatic||l.isStatic)&&(a.isSleeping||l.isSleeping)){var c=a.isSleeping&&!a.isStatic?a:l,d=c===a?l:a;!c.isStatic&&d.motion>o._motionWakeThreshold*n&&o.set(c,!1)}}}},o.set=function(e,t){var n=e.isSleeping;t?(e.isSleeping=!0,e.sleepCounter=e.sleepThreshold,e.positionImpulse.x=0,e.positionImpulse.y=0,e.positionPrev.x=e.position.x,e.positionPrev.y=e.position.y,e.anglePrev=e.angle,e.speed=0,e.angularSpeed=0,e.motion=0,n||i.trigger(e,"sleepStart")):(e.isSleeping=!1,e.sleepCounter=0,n&&i.trigger(e,"sleepEnd"))}}()},{
"./Events":16}],23:[function(e,t,n){var o={};t.exports=o;var i,r=e("../geometry/Vertices"),s=e("../core/Common"),a=e("../body/Body"),l=e("../geometry/Bounds"),c=e("../geometry/Vector");!function(){o.rectangle=function(e,t,n,o,i){i=i||{};var l={label:"Rectangle Body",position:{x:e,y:t},vertices:r.fromPath("L 0 0 L "+n+" 0 L "+n+" "+o+" L 0 "+o)};if(i.chamfer){var c=i.chamfer;l.vertices=r.chamfer(l.vertices,c.radius,c.quality,c.qualityMin,c.qualityMax),delete i.chamfer}return a.create(s.extend({},l,i))},o.trapezoid=function(e,t,n,o,i,l){l=l||{},i*=.5;var c,d=(1-2*i)*n,u=n*i,p=u+d,f=p+u;c=i<.5?"L 0 0 L "+u+" "+-o+" L "+p+" "+-o+" L "+f+" 0":"L 0 0 L "+p+" "+-o+" L "+f+" 0";var m={label:"Trapezoid Body",position:{x:e,y:t},vertices:r.fromPath(c)};if(l.chamfer){var v=l.chamfer;m.vertices=r.chamfer(m.vertices,v.radius,v.quality,v.qualityMin,v.qualityMax),delete l.chamfer}return a.create(s.extend({},m,l))},o.circle=function(e,t,n,i,r){i=i||{};var a={label:"Circle Body",circleRadius:n};r=r||25
;var l=Math.ceil(Math.max(10,Math.min(r,n)));return l%2==1&&(l+=1),o.polygon(e,t,l,n,s.extend({},a,i))},o.polygon=function(e,t,n,i,l){if(l=l||{},n<3)return o.circle(e,t,i,l);for(var c=2*Math.PI/n,d="",u=.5*c,p=0;p<n;p+=1){var f=u+p*c,m=Math.cos(f)*i,v=Math.sin(f)*i;d+="L "+m.toFixed(3)+" "+v.toFixed(3)+" "}var y={label:"Polygon Body",position:{x:e,y:t},vertices:r.fromPath(d)};if(l.chamfer){var g=l.chamfer;y.vertices=r.chamfer(y.vertices,g.radius,g.quality,g.qualityMin,g.qualityMax),delete l.chamfer}return a.create(s.extend({},y,l))},o.fromVertices=function(e,t,n,o,d,u,p){i||(i=s._requireGlobal("decomp","poly-decomp"));var f,m,v,y,g,x,h,b,w;for(o=o||{},m=[],d=void 0!==d&&d,u=void 0!==u?u:.01,p=void 0!==p?p:10,i||s.warn("Bodies.fromVertices: poly-decomp.js required. Could not decompose vertices. Fallback to convex hull."),s.isArray(n[0])||(n=[n]),b=0;b<n.length;b+=1)if(y=n[b],(v=r.isConvex(y))||!i)y=v?r.clockwiseSort(y):r.hull(y),m.push({position:{x:e,y:t},vertices:y});else{
var S=y.map(function(e){return[e.x,e.y]});i.makeCCW(S),!1!==u&&i.removeCollinearPoints(S,u);var C=i.quickDecomp(S);for(g=0;g<C.length;g++){var A=C[g],P=A.map(function(e){return{x:e[0],y:e[1]}});p>0&&r.area(P)<p||m.push({position:r.centre(P),vertices:P})}}for(g=0;g<m.length;g++)m[g]=a.create(s.extend(m[g],o));if(d){for(g=0;g<m.length;g++){var B=m[g];for(x=g+1;x<m.length;x++){var M=m[x];if(l.overlaps(B.bounds,M.bounds)){var k=B.vertices,I=M.vertices;for(h=0;h<B.vertices.length;h++)for(w=0;w<M.vertices.length;w++){var _=c.magnitudeSquared(c.sub(k[(h+1)%k.length],I[w])),T=c.magnitudeSquared(c.sub(k[h],I[(w+1)%I.length]));_<5&&T<5&&(k[h].isInternal=!0,I[w].isInternal=!0)}}}}}return m.length>1?(f=a.create(s.extend({parts:m.slice(0)},o)),a.setPosition(f,{x:e,y:t}),f):m[0]}}()},{"../body/Body":1,"../core/Common":14,"../geometry/Bounds":26,"../geometry/Vector":28,"../geometry/Vertices":29}],24:[function(e,t,n){var o={};t.exports=o
;var i=e("../body/Composite"),r=e("../constraint/Constraint"),s=e("../core/Common"),a=e("../body/Body"),l=e("./Bodies");!function(){o.stack=function(e,t,n,o,r,s,l){for(var c,d=i.create({label:"Stack"}),u=e,p=t,f=0,m=0;m<o;m++){for(var v=0,y=0;y<n;y++){var g=l(u,p,y,m,c,f);if(g){var x=g.bounds.max.y-g.bounds.min.y,h=g.bounds.max.x-g.bounds.min.x;x>v&&(v=x),a.translate(g,{x:.5*h,y:.5*x}),u=g.bounds.max.x+r,i.addBody(d,g),c=g,f+=1}else u+=r}p+=v+s,u=e}return d},o.chain=function(e,t,n,o,a,l){for(var c=e.bodies,d=1;d<c.length;d++){var u=c[d-1],p=c[d],f=u.bounds.max.y-u.bounds.min.y,m=u.bounds.max.x-u.bounds.min.x,v=p.bounds.max.y-p.bounds.min.y,y=p.bounds.max.x-p.bounds.min.x,g={bodyA:u,pointA:{x:m*t,y:f*n},bodyB:p,pointB:{x:y*o,y:v*a}},x=s.extend(g,l);i.addConstraint(e,r.create(x))}return e.label+=" Chain",e},o.mesh=function(e,t,n,o,a){var l,c,d,u,p,f=e.bodies;for(l=0;l<n;l++){for(c=1;c<t;c++)d=f[c-1+l*t],u=f[c+l*t],i.addConstraint(e,r.create(s.extend({bodyA:d,bodyB:u},a)))
;if(l>0)for(c=0;c<t;c++)d=f[c+(l-1)*t],u=f[c+l*t],i.addConstraint(e,r.create(s.extend({bodyA:d,bodyB:u},a))),o&&c>0&&(p=f[c-1+(l-1)*t],i.addConstraint(e,r.create(s.extend({bodyA:p,bodyB:u},a)))),o&&c<t-1&&(p=f[c+1+(l-1)*t],i.addConstraint(e,r.create(s.extend({bodyA:p,bodyB:u},a))))}return e.label+=" Mesh",e},o.pyramid=function(e,t,n,i,r,s,l){return o.stack(e,t,n,i,r,s,function(t,o,s,c,d,u){var p=Math.min(i,Math.ceil(n/2)),f=d?d.bounds.max.x-d.bounds.min.x:0;if(!(c>p)){c=p-c;var m=c,v=n-1-c;if(!(s<m||s>v)){1===u&&a.translate(d,{x:(s+(n%2==1?1:-1))*f,y:0});return l(e+(d?s*f:0)+s*r,o,s,c,d,u)}}})},o.newtonsCradle=function(e,t,n,o,s){for(var a=i.create({label:"Newtons Cradle"}),c=0;c<n;c++){var d=l.circle(e+c*(1.9*o),t+s,o,{inertia:1/0,restitution:1,friction:0,frictionAir:1e-4,slop:1}),u=r.create({pointA:{x:e+c*(1.9*o),y:t},bodyB:d});i.addBody(a,d),i.addConstraint(a,u)}return a},o.car=function(e,t,n,o,s){var c=a.nextGroup(!0),d=.5*-n+20,u=.5*n-20,p=i.create({label:"Car"
}),f=l.rectangle(e,t,n,o,{collisionFilter:{group:c},chamfer:{radius:.5*o},density:2e-4}),m=l.circle(e+d,t+0,s,{collisionFilter:{group:c},friction:.8}),v=l.circle(e+u,t+0,s,{collisionFilter:{group:c},friction:.8}),y=r.create({bodyB:f,pointB:{x:d,y:0},bodyA:m,stiffness:1,length:0}),g=r.create({bodyB:f,pointB:{x:u,y:0},bodyA:v,stiffness:1,length:0});return i.addBody(p,f),i.addBody(p,m),i.addBody(p,v),i.addConstraint(p,y),i.addConstraint(p,g),p},o.softBody=function(e,t,n,i,r,a,c,d,u,p){u=s.extend({inertia:1/0},u),p=s.extend({stiffness:.2,render:{type:"line",anchors:!1}},p);var f=o.stack(e,t,n,i,r,a,function(e,t){return l.circle(e,t,d,u)});return o.mesh(f,n,i,c,p),f.label="Soft Body",f}}()},{"../body/Body":1,"../body/Composite":2,"../constraint/Constraint":12,"../core/Common":14,"./Bodies":23}],25:[function(e,t,n){var o={};t.exports=o;var i=e("../geometry/Vector"),r=e("../core/Common");!function(){o.fromVertices=function(e){for(var t={},n=0;n<e.length;n++){
var o=(n+1)%e.length,s=i.normalise({x:e[o].y-e[n].y,y:e[n].x-e[o].x}),a=0===s.y?1/0:s.x/s.y;a=a.toFixed(3).toString(),t[a]=s}return r.values(t)},o.rotate=function(e,t){if(0!==t)for(var n=Math.cos(t),o=Math.sin(t),i=0;i<e.length;i++){var r,s=e[i];r=s.x*n-s.y*o,s.y=s.x*o+s.y*n,s.x=r}}}()},{"../core/Common":14,"../geometry/Vector":28}],26:[function(e,t,n){var o={};t.exports=o,function(){o.create=function(e){var t={min:{x:0,y:0},max:{x:0,y:0}};return e&&o.update(t,e),t},o.update=function(e,t,n){e.min.x=1/0,e.max.x=-1/0,e.min.y=1/0,e.max.y=-1/0;for(var o=0;o<t.length;o++){var i=t[o];i.x>e.max.x&&(e.max.x=i.x),i.x<e.min.x&&(e.min.x=i.x),i.y>e.max.y&&(e.max.y=i.y),i.y<e.min.y&&(e.min.y=i.y)}n&&(n.x>0?e.max.x+=n.x:e.min.x+=n.x,n.y>0?e.max.y+=n.y:e.min.y+=n.y)},o.contains=function(e,t){return t.x>=e.min.x&&t.x<=e.max.x&&t.y>=e.min.y&&t.y<=e.max.y},o.overlaps=function(e,t){return e.min.x<=t.max.x&&e.max.x>=t.min.x&&e.max.y>=t.min.y&&e.min.y<=t.max.y},o.translate=function(e,t){e.min.x+=t.x,
e.max.x+=t.x,e.min.y+=t.y,e.max.y+=t.y},o.shift=function(e,t){var n=e.max.x-e.min.x,o=e.max.y-e.min.y;e.min.x=t.x,e.max.x=t.x+n,e.min.y=t.y,e.max.y=t.y+o}}()},{}],27:[function(e,t,n){var o={};t.exports=o;var i=(e("../geometry/Bounds"),e("../core/Common"));!function(){o.pathToVertices=function(e,t){"undefined"==typeof window||"SVGPathSeg"in window||i.warn("Svg.pathToVertices: SVGPathSeg not defined, a polyfill is required.");var n,r,s,a,l,c,d,u,p,f,m,v,y=[],g=0,x=0,h=0;t=t||15;var b=function(e,t,n){var o=n%2==1&&n>1;if(!p||e!=p.x||t!=p.y){p&&o?(m=p.x,v=p.y):(m=0,v=0);var i={x:m+e,y:v+t};!o&&p||(p=i),y.push(i),x=m+e,h=v+t}},w=function(e){var t=e.pathSegTypeAsLetter.toUpperCase();if("Z"!==t){switch(t){case"M":case"L":case"T":case"C":case"S":case"Q":x=e.x,h=e.y;break;case"H":x=e.x;break;case"V":h=e.y}b(x,h,e.pathSegType)}};for(o._svgPathToAbsolute(e),s=e.getTotalLength(),c=[],n=0;n<e.pathSegList.numberOfItems;n+=1)c.push(e.pathSegList.getItem(n));for(d=c.concat();g<s;){
if(f=e.getPathSegAtLength(g),(l=c[f])!=u){for(;d.length&&d[0]!=l;)w(d.shift());u=l}switch(l.pathSegTypeAsLetter.toUpperCase()){case"C":case"T":case"S":case"Q":case"A":a=e.getPointAtLength(g),b(a.x,a.y,0)}g+=t}for(n=0,r=d.length;n<r;++n)w(d[n]);return y},o._svgPathToAbsolute=function(e){for(var t,n,o,i,r,s,a=e.pathSegList,l=0,c=0,d=a.numberOfItems,u=0;u<d;++u){var p=a.getItem(u),f=p.pathSegTypeAsLetter;if(/[MLHVCSQTA]/.test(f))"x"in p&&(l=p.x),"y"in p&&(c=p.y);else switch("x1"in p&&(o=l+p.x1),"x2"in p&&(r=l+p.x2),"y1"in p&&(i=c+p.y1),"y2"in p&&(s=c+p.y2),"x"in p&&(l+=p.x),"y"in p&&(c+=p.y),f){case"m":a.replaceItem(e.createSVGPathSegMovetoAbs(l,c),u);break;case"l":a.replaceItem(e.createSVGPathSegLinetoAbs(l,c),u);break;case"h":a.replaceItem(e.createSVGPathSegLinetoHorizontalAbs(l),u);break;case"v":a.replaceItem(e.createSVGPathSegLinetoVerticalAbs(c),u);break;case"c":a.replaceItem(e.createSVGPathSegCurvetoCubicAbs(l,c,o,i,r,s),u);break;case"s":
a.replaceItem(e.createSVGPathSegCurvetoCubicSmoothAbs(l,c,r,s),u);break;case"q":a.replaceItem(e.createSVGPathSegCurvetoQuadraticAbs(l,c,o,i),u);break;case"t":a.replaceItem(e.createSVGPathSegCurvetoQuadraticSmoothAbs(l,c),u);break;case"a":a.replaceItem(e.createSVGPathSegArcAbs(l,c,p.r1,p.r2,p.angle,p.largeArcFlag,p.sweepFlag),u);break;case"z":case"Z":l=t,c=n}"M"!=f&&"m"!=f||(t=l,n=c)}}}()},{"../core/Common":14,"../geometry/Bounds":26}],28:[function(e,t,n){var o={};t.exports=o,function(){o.create=function(e,t){return{x:e||0,y:t||0}},o.clone=function(e){return{x:e.x,y:e.y}},o.magnitude=function(e){return Math.sqrt(e.x*e.x+e.y*e.y)},o.magnitudeSquared=function(e){return e.x*e.x+e.y*e.y},o.rotate=function(e,t,n){var o=Math.cos(t),i=Math.sin(t);n||(n={});var r=e.x*o-e.y*i;return n.y=e.x*i+e.y*o,n.x=r,n},o.rotateAbout=function(e,t,n,o){var i=Math.cos(t),r=Math.sin(t);o||(o={});var s=n.x+((e.x-n.x)*i-(e.y-n.y)*r);return o.y=n.y+((e.x-n.x)*r+(e.y-n.y)*i),o.x=s,o},o.normalise=function(e){
var t=o.magnitude(e);return 0===t?{x:0,y:0}:{x:e.x/t,y:e.y/t}},o.dot=function(e,t){return e.x*t.x+e.y*t.y},o.cross=function(e,t){return e.x*t.y-e.y*t.x},o.cross3=function(e,t,n){return(t.x-e.x)*(n.y-e.y)-(t.y-e.y)*(n.x-e.x)},o.add=function(e,t,n){return n||(n={}),n.x=e.x+t.x,n.y=e.y+t.y,n},o.sub=function(e,t,n){return n||(n={}),n.x=e.x-t.x,n.y=e.y-t.y,n},o.mult=function(e,t){return{x:e.x*t,y:e.y*t}},o.div=function(e,t){return{x:e.x/t,y:e.y/t}},o.perp=function(e,t){return t=!0===t?-1:1,{x:t*-e.y,y:t*e.x}},o.neg=function(e){return{x:-e.x,y:-e.y}},o.angle=function(e,t){return Math.atan2(t.y-e.y,t.x-e.x)},o._temp=[o.create(),o.create(),o.create(),o.create(),o.create(),o.create()]}()},{}],29:[function(e,t,n){var o={};t.exports=o;var i=e("../geometry/Vector"),r=e("../core/Common");!function(){o.create=function(e,t){for(var n=[],o=0;o<e.length;o++){var i=e[o],r={x:i.x,y:i.y,index:o,body:t,isInternal:!1};n.push(r)}return n},o.fromPath=function(e,t){
var n=/L?\s*([\-\d\.e]+)[\s,]*([\-\d\.e]+)*/gi,i=[];return e.replace(n,function(e,t,n){i.push({x:parseFloat(t),y:parseFloat(n)})}),o.create(i,t)},o.centre=function(e){for(var t,n,r,s=o.area(e,!0),a={x:0,y:0},l=0;l<e.length;l++)r=(l+1)%e.length,t=i.cross(e[l],e[r]),n=i.mult(i.add(e[l],e[r]),t),a=i.add(a,n);return i.div(a,6*s)},o.mean=function(e){for(var t={x:0,y:0},n=0;n<e.length;n++)t.x+=e[n].x,t.y+=e[n].y;return i.div(t,e.length)},o.area=function(e,t){for(var n=0,o=e.length-1,i=0;i<e.length;i++)n+=(e[o].x-e[i].x)*(e[o].y+e[i].y),o=i;return t?n/2:Math.abs(n)/2},o.inertia=function(e,t){for(var n,o,r=0,s=0,a=e,l=0;l<a.length;l++)o=(l+1)%a.length,n=Math.abs(i.cross(a[o],a[l])),r+=n*(i.dot(a[o],a[o])+i.dot(a[o],a[l])+i.dot(a[l],a[l])),s+=n;return t/6*(r/s)},o.translate=function(e,t,n){var o;if(n)for(o=0;o<e.length;o++)e[o].x+=t.x*n,e[o].y+=t.y*n;else for(o=0;o<e.length;o++)e[o].x+=t.x,e[o].y+=t.y;return e},o.rotate=function(e,t,n){if(0!==t){
for(var o=Math.cos(t),i=Math.sin(t),r=0;r<e.length;r++){var s=e[r],a=s.x-n.x,l=s.y-n.y;s.x=n.x+(a*o-l*i),s.y=n.y+(a*i+l*o)}return e}},o.contains=function(e,t){for(var n=0;n<e.length;n++){var o=e[n],i=e[(n+1)%e.length];if((t.x-o.x)*(i.y-o.y)+(t.y-o.y)*(o.x-i.x)>0)return!1}return!0},o.scale=function(e,t,n,r){if(1===t&&1===n)return e;r=r||o.centre(e);for(var s,a,l=0;l<e.length;l++)s=e[l],a=i.sub(s,r),e[l].x=r.x+a.x*t,e[l].y=r.y+a.y*n;return e},o.chamfer=function(e,t,n,o,s){t="number"==typeof t?[t]:t||[8],n=void 0!==n?n:-1,o=o||2,s=s||14;for(var a=[],l=0;l<e.length;l++){var c=e[l-1>=0?l-1:e.length-1],d=e[l],u=e[(l+1)%e.length],p=t[l<t.length?l:t.length-1];if(0!==p){var f=i.normalise({x:d.y-c.y,y:c.x-d.x}),m=i.normalise({x:u.y-d.y,y:d.x-u.x}),v=Math.sqrt(2*Math.pow(p,2)),y=i.mult(r.clone(f),p),g=i.normalise(i.mult(i.add(f,m),.5)),x=i.sub(d,i.mult(g,v)),h=n;-1===n&&(h=1.75*Math.pow(p,.32)),h=r.clamp(h,o,s),h%2==1&&(h+=1)
;for(var b=Math.acos(i.dot(f,m)),w=b/h,S=0;S<h;S++)a.push(i.add(i.rotate(y,w*S),x))}else a.push(d)}return a},o.clockwiseSort=function(e){var t=o.mean(e);return e.sort(function(e,n){return i.angle(t,e)-i.angle(t,n)}),e},o.isConvex=function(e){var t,n,o,i,r=0,s=e.length;if(s<3)return null;for(t=0;t<s;t++)if(n=(t+1)%s,o=(t+2)%s,i=(e[n].x-e[t].x)*(e[o].y-e[n].y),i-=(e[n].y-e[t].y)*(e[o].x-e[n].x),i<0?r|=1:i>0&&(r|=2),3===r)return!1;return 0!==r||null},o.hull=function(e){var t,n,o=[],r=[];for(e=e.slice(0),e.sort(function(e,t){var n=e.x-t.x;return 0!==n?n:e.y-t.y}),n=0;n<e.length;n+=1){for(t=e[n];r.length>=2&&i.cross3(r[r.length-2],r[r.length-1],t)<=0;)r.pop();r.push(t)}for(n=e.length-1;n>=0;n-=1){for(t=e[n];o.length>=2&&i.cross3(o[o.length-2],o[o.length-1],t)<=0;)o.pop();o.push(t)}return o.pop(),r.pop(),o.concat(r)}}()},{"../core/Common":14,"../geometry/Vector":28}],30:[function(e,t,n){var o=t.exports=e("../core/Matter");o.Body=e("../body/Body"),o.Composite=e("../body/Composite"),
o.World=e("../body/World"),o.Contact=e("../collision/Contact"),o.Detector=e("../collision/Detector"),o.Grid=e("../collision/Grid"),o.Pairs=e("../collision/Pairs"),o.Pair=e("../collision/Pair"),o.Query=e("../collision/Query"),o.Resolver=e("../collision/Resolver"),o.SAT=e("../collision/SAT"),o.Constraint=e("../constraint/Constraint"),o.MouseConstraint=e("../constraint/MouseConstraint"),o.Common=e("../core/Common"),o.Engine=e("../core/Engine"),o.Events=e("../core/Events"),o.Mouse=e("../core/Mouse"),o.Runner=e("../core/Runner"),o.Sleeping=e("../core/Sleeping"),o.Plugin=e("../core/Plugin"),o.Bodies=e("../factory/Bodies"),o.Composites=e("../factory/Composites"),o.Axes=e("../geometry/Axes"),o.Bounds=e("../geometry/Bounds"),o.Svg=e("../geometry/Svg"),o.Vector=e("../geometry/Vector"),o.Vertices=e("../geometry/Vertices"),o.Render=e("../render/Render"),o.RenderPixi=e("../render/RenderPixi"),o.World.add=o.Composite.add,o.World.remove=o.Composite.remove,
o.World.addComposite=o.Composite.addComposite,o.World.addBody=o.Composite.addBody,o.World.addConstraint=o.Composite.addConstraint,o.World.clear=o.Composite.clear,o.Engine.run=o.Runner.run},{"../body/Body":1,"../body/Composite":2,"../body/World":3,"../collision/Contact":4,"../collision/Detector":5,"../collision/Grid":6,"../collision/Pair":7,"../collision/Pairs":8,"../collision/Query":9,"../collision/Resolver":10,"../collision/SAT":11,"../constraint/Constraint":12,"../constraint/MouseConstraint":13,"../core/Common":14,"../core/Engine":15,"../core/Events":16,"../core/Matter":17,"../core/Metrics":18,"../core/Mouse":19,"../core/Plugin":20,"../core/Runner":21,"../core/Sleeping":22,"../factory/Bodies":23,"../factory/Composites":24,"../geometry/Axes":25,"../geometry/Bounds":26,"../geometry/Svg":27,"../geometry/Vector":28,"../geometry/Vertices":29,"../render/Render":31,"../render/RenderPixi":32}],31:[function(e,t,n){var o={};t.exports=o
;var i=e("../core/Common"),r=e("../body/Composite"),s=e("../geometry/Bounds"),a=e("../core/Events"),l=e("../collision/Grid"),c=e("../geometry/Vector"),d=e("../core/Mouse");!function(){var e,t;"undefined"!=typeof window&&(e=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame||function(e){window.setTimeout(function(){e(i.now())},1e3/60)},t=window.cancelAnimationFrame||window.mozCancelAnimationFrame||window.webkitCancelAnimationFrame||window.msCancelAnimationFrame),o.create=function(e){var t={controller:o,engine:null,element:null,canvas:null,mouse:null,frameRequestId:null,options:{width:800,height:600,pixelRatio:1,background:"#18181d",wireframeBackground:"#0f0f13",hasBounds:!!e.bounds,enabled:!0,wireframes:!0,showSleeping:!0,showDebug:!1,showBroadphase:!1,showBounds:!1,showVelocity:!1,showCollisions:!1,showSeparations:!1,showAxes:!1,showPositions:!1,showAngleIndicator:!1,showIds:!1,showShadows:!1,
showVertexNumbers:!1,showConvexHulls:!1,showInternalEdges:!1,showMousePosition:!1}},r=i.extend(t,e);return r.canvas&&(r.canvas.width=r.options.width||r.canvas.width,r.canvas.height=r.options.height||r.canvas.height),r.mouse=e.mouse,r.engine=e.engine,r.canvas=r.canvas||n(r.options.width,r.options.height),r.context=r.canvas.getContext("2d"),r.textures={},r.bounds=r.bounds||{min:{x:0,y:0},max:{x:r.canvas.width,y:r.canvas.height}},1!==r.options.pixelRatio&&o.setPixelRatio(r,r.options.pixelRatio),i.isElement(r.element)?r.element.appendChild(r.canvas):r.canvas.parentNode||i.log("Render.create: options.element was undefined, render.canvas was created but not appended","warn"),r},o.run=function(t){!function n(i){t.frameRequestId=e(n),o.world(t)}()},o.stop=function(e){t(e.frameRequestId)},o.setPixelRatio=function(e,t){var n=e.options,o=e.canvas;"auto"===t&&(t=u(o)),n.pixelRatio=t,o.setAttribute("data-pixel-ratio",t),o.width=n.width*t,o.height=n.height*t,o.style.width=n.width+"px",
o.style.height=n.height+"px",e.context.scale(t,t)},o.lookAt=function(e,t,n,o){o=void 0===o||o,t=i.isArray(t)?t:[t],n=n||{x:0,y:0};for(var r={min:{x:1/0,y:1/0},max:{x:-1/0,y:-1/0}},s=0;s<t.length;s+=1){var a=t[s],l=a.bounds?a.bounds.min:a.min||a.position||a,c=a.bounds?a.bounds.max:a.max||a.position||a;l&&c&&(l.x<r.min.x&&(r.min.x=l.x),c.x>r.max.x&&(r.max.x=c.x),l.y<r.min.y&&(r.min.y=l.y),c.y>r.max.y&&(r.max.y=c.y))}var u=r.max.x-r.min.x+2*n.x,p=r.max.y-r.min.y+2*n.y,f=e.canvas.height,m=e.canvas.width,v=m/f,y=u/p,g=1,x=1;y>v?x=y/v:g=v/y,e.options.hasBounds=!0,e.bounds.min.x=r.min.x,e.bounds.max.x=r.min.x+u*g,e.bounds.min.y=r.min.y,e.bounds.max.y=r.min.y+p*x,o&&(e.bounds.min.x+=.5*u-u*g*.5,e.bounds.max.x+=.5*u-u*g*.5,e.bounds.min.y+=.5*p-p*x*.5,e.bounds.max.y+=.5*p-p*x*.5),e.bounds.min.x-=n.x,e.bounds.max.x-=n.x,e.bounds.min.y-=n.y,e.bounds.max.y-=n.y,e.mouse&&(d.setScale(e.mouse,{x:(e.bounds.max.x-e.bounds.min.x)/e.canvas.width,y:(e.bounds.max.y-e.bounds.min.y)/e.canvas.height}),
d.setOffset(e.mouse,e.bounds.min))},o.startViewTransform=function(e){var t=e.bounds.max.x-e.bounds.min.x,n=e.bounds.max.y-e.bounds.min.y,o=t/e.options.width,i=n/e.options.height;e.context.scale(1/o,1/i),e.context.translate(-e.bounds.min.x,-e.bounds.min.y)},o.endViewTransform=function(e){e.context.setTransform(e.options.pixelRatio,0,0,e.options.pixelRatio,0,0)},o.world=function(e){var t,n=e.engine,i=n.world,u=e.canvas,p=e.context,m=e.options,v=r.allBodies(i),y=r.allConstraints(i),g=m.wireframes?m.wireframeBackground:m.background,x=[],h=[],b={timestamp:n.timing.timestamp};if(a.trigger(e,"beforeRender",b),e.currentBackground!==g&&f(e,g),p.globalCompositeOperation="source-in",p.fillStyle="transparent",p.fillRect(0,0,u.width,u.height),p.globalCompositeOperation="source-over",m.hasBounds){for(t=0;t<v.length;t++){var w=v[t];s.overlaps(w.bounds,e.bounds)&&x.push(w)}for(t=0;t<y.length;t++){var S=y[t],C=S.bodyA,A=S.bodyB,P=S.pointA,B=S.pointB;C&&(P=c.add(C.position,S.pointA)),
A&&(B=c.add(A.position,S.pointB)),P&&B&&((s.contains(e.bounds,P)||s.contains(e.bounds,B))&&h.push(S))}o.startViewTransform(e),e.mouse&&(d.setScale(e.mouse,{x:(e.bounds.max.x-e.bounds.min.x)/e.canvas.width,y:(e.bounds.max.y-e.bounds.min.y)/e.canvas.height}),d.setOffset(e.mouse,e.bounds.min))}else h=y,x=v;!m.wireframes||n.enableSleeping&&m.showSleeping?o.bodies(e,x,p):(m.showConvexHulls&&o.bodyConvexHulls(e,x,p),o.bodyWireframes(e,x,p)),m.showBounds&&o.bodyBounds(e,x,p),(m.showAxes||m.showAngleIndicator)&&o.bodyAxes(e,x,p),m.showPositions&&o.bodyPositions(e,x,p),m.showVelocity&&o.bodyVelocity(e,x,p),m.showIds&&o.bodyIds(e,x,p),m.showSeparations&&o.separations(e,n.pairs.list,p),m.showCollisions&&o.collisions(e,n.pairs.list,p),m.showVertexNumbers&&o.vertexNumbers(e,x,p),m.showMousePosition&&o.mousePosition(e,e.mouse,p),o.constraints(h,p),m.showBroadphase&&n.broadphase.controller===l&&o.grid(e,n.broadphase,p),m.showDebug&&o.debug(e,p),m.hasBounds&&o.endViewTransform(e),
a.trigger(e,"afterRender",b)},o.debug=function(e,t){var n=t,o=e.engine,i=o.world,s=o.metrics,a=e.options;r.allBodies(i);if(o.timing.timestamp-(e.debugTimestamp||0)>=500){var l="";s.timing&&(l+="fps: "+Math.round(s.timing.fps)+" "),e.debugString=l,e.debugTimestamp=o.timing.timestamp}if(e.debugString){n.font="12px Arial",a.wireframes?n.fillStyle="rgba(255,255,255,0.5)":n.fillStyle="rgba(0,0,0,0.5)";for(var c=e.debugString.split("\n"),d=0;d<c.length;d++)n.fillText(c[d],50,50+18*d)}},o.constraints=function(e,t){for(var n=t,o=0;o<e.length;o++){var r=e[o];if(r.render.visible&&r.pointA&&r.pointB){var s,a,l=r.bodyA,d=r.bodyB;if(s=l?c.add(l.position,r.pointA):r.pointA,"pin"===r.render.type)n.beginPath(),n.arc(s.x,s.y,3,0,2*Math.PI),n.closePath();else{if(a=d?c.add(d.position,r.pointB):r.pointB,n.beginPath(),n.moveTo(s.x,s.y),"spring"===r.render.type)for(var u,p=c.sub(a,s),f=c.perp(c.normalise(p)),m=Math.ceil(i.clamp(r.length/5,12,20)),v=1;v<m;v+=1)u=v%2==0?1:-1,
n.lineTo(s.x+p.x*(v/m)+f.x*u*4,s.y+p.y*(v/m)+f.y*u*4);n.lineTo(a.x,a.y)}r.render.lineWidth&&(n.lineWidth=r.render.lineWidth,n.strokeStyle=r.render.strokeStyle,n.stroke()),r.render.anchors&&(n.fillStyle=r.render.strokeStyle,n.beginPath(),n.arc(s.x,s.y,3,0,2*Math.PI),n.arc(a.x,a.y,3,0,2*Math.PI),n.closePath(),n.fill())}}},o.bodyShadows=function(e,t,n){for(var o=n,i=(e.engine,0);i<t.length;i++){var r=t[i];if(r.render.visible){if(r.circleRadius)o.beginPath(),o.arc(r.position.x,r.position.y,r.circleRadius,0,2*Math.PI),o.closePath();else{o.beginPath(),o.moveTo(r.vertices[0].x,r.vertices[0].y);for(var s=1;s<r.vertices.length;s++)o.lineTo(r.vertices[s].x,r.vertices[s].y);o.closePath()}var a=r.position.x-.5*e.options.width,l=r.position.y-.2*e.options.height,c=Math.abs(a)+Math.abs(l);o.shadowColor="rgba(0,0,0,0.15)",o.shadowOffsetX=.05*a,o.shadowOffsetY=.05*l,o.shadowBlur=1+12*Math.min(1,c/1e3),o.fill(),o.shadowColor=null,o.shadowOffsetX=null,o.shadowOffsetY=null,o.shadowBlur=null}}},
o.bodies=function(e,t,n){var o,i,r,s,a=n,l=(e.engine,e.options),c=l.showInternalEdges||!l.wireframes;for(r=0;r<t.length;r++)if(o=t[r],o.render.visible)for(s=o.parts.length>1?1:0;s<o.parts.length;s++)if(i=o.parts[s],i.render.visible){if(l.showSleeping&&o.isSleeping?a.globalAlpha=.5*i.render.opacity:1!==i.render.opacity&&(a.globalAlpha=i.render.opacity),i.render.sprite&&i.render.sprite.texture&&!l.wireframes){var d=i.render.sprite,u=p(e,d.texture);a.translate(i.position.x,i.position.y),a.rotate(i.angle),a.drawImage(u,u.width*-d.xOffset*d.xScale,u.height*-d.yOffset*d.yScale,u.width*d.xScale,u.height*d.yScale),a.rotate(-i.angle),a.translate(-i.position.x,-i.position.y)}else{if(i.circleRadius)a.beginPath(),a.arc(i.position.x,i.position.y,i.circleRadius,0,2*Math.PI);else{a.beginPath(),a.moveTo(i.vertices[0].x,i.vertices[0].y);for(var f=1;f<i.vertices.length;f++)!i.vertices[f-1].isInternal||c?a.lineTo(i.vertices[f].x,i.vertices[f].y):a.moveTo(i.vertices[f].x,i.vertices[f].y),
i.vertices[f].isInternal&&!c&&a.moveTo(i.vertices[(f+1)%i.vertices.length].x,i.vertices[(f+1)%i.vertices.length].y);a.lineTo(i.vertices[0].x,i.vertices[0].y),a.closePath()}l.wireframes?(a.lineWidth=1,a.strokeStyle="#bbb",a.stroke()):(a.fillStyle=i.render.fillStyle,i.render.lineWidth&&(a.lineWidth=i.render.lineWidth,a.strokeStyle=i.render.strokeStyle,a.stroke()),a.fill())}a.globalAlpha=1}},o.bodyWireframes=function(e,t,n){var o,i,r,s,a,l=n,c=e.options.showInternalEdges;for(l.beginPath(),r=0;r<t.length;r++)if(o=t[r],o.render.visible)for(a=o.parts.length>1?1:0;a<o.parts.length;a++){for(i=o.parts[a],l.moveTo(i.vertices[0].x,i.vertices[0].y),s=1;s<i.vertices.length;s++)!i.vertices[s-1].isInternal||c?l.lineTo(i.vertices[s].x,i.vertices[s].y):l.moveTo(i.vertices[s].x,i.vertices[s].y),i.vertices[s].isInternal&&!c&&l.moveTo(i.vertices[(s+1)%i.vertices.length].x,i.vertices[(s+1)%i.vertices.length].y);l.lineTo(i.vertices[0].x,i.vertices[0].y)}l.lineWidth=1,l.strokeStyle="#bbb",l.stroke()},
o.bodyConvexHulls=function(e,t,n){var o,i,r,s=n;for(s.beginPath(),i=0;i<t.length;i++)if(o=t[i],o.render.visible&&1!==o.parts.length){for(s.moveTo(o.vertices[0].x,o.vertices[0].y),r=1;r<o.vertices.length;r++)s.lineTo(o.vertices[r].x,o.vertices[r].y);s.lineTo(o.vertices[0].x,o.vertices[0].y)}s.lineWidth=1,s.strokeStyle="rgba(255,255,255,0.2)",s.stroke()},o.vertexNumbers=function(e,t,n){var o,i,r,s=n;for(o=0;o<t.length;o++){var a=t[o].parts;for(r=a.length>1?1:0;r<a.length;r++){var l=a[r];for(i=0;i<l.vertices.length;i++)s.fillStyle="rgba(255,255,255,0.2)",s.fillText(o+"_"+i,l.position.x+.8*(l.vertices[i].x-l.position.x),l.position.y+.8*(l.vertices[i].y-l.position.y))}}},o.mousePosition=function(e,t,n){var o=n;o.fillStyle="rgba(255,255,255,0.8)",o.fillText(t.position.x+" "+t.position.y,t.position.x+5,t.position.y-5)},o.bodyBounds=function(e,t,n){var o=n,i=(e.engine,e.options);o.beginPath();for(var r=0;r<t.length;r++){
if(t[r].render.visible)for(var s=t[r].parts,a=s.length>1?1:0;a<s.length;a++){var l=s[a];o.rect(l.bounds.min.x,l.bounds.min.y,l.bounds.max.x-l.bounds.min.x,l.bounds.max.y-l.bounds.min.y)}}i.wireframes?o.strokeStyle="rgba(255,255,255,0.08)":o.strokeStyle="rgba(0,0,0,0.1)",o.lineWidth=1,o.stroke()},o.bodyAxes=function(e,t,n){var o,i,r,s,a=n,l=(e.engine,e.options);for(a.beginPath(),i=0;i<t.length;i++){var c=t[i],d=c.parts;if(c.render.visible)if(l.showAxes)for(r=d.length>1?1:0;r<d.length;r++)for(o=d[r],s=0;s<o.axes.length;s++){var u=o.axes[s];a.moveTo(o.position.x,o.position.y),a.lineTo(o.position.x+20*u.x,o.position.y+20*u.y)}else for(r=d.length>1?1:0;r<d.length;r++)for(o=d[r],s=0;s<o.axes.length;s++)a.moveTo(o.position.x,o.position.y),a.lineTo((o.vertices[0].x+o.vertices[o.vertices.length-1].x)/2,(o.vertices[0].y+o.vertices[o.vertices.length-1].y)/2)}l.wireframes?(a.strokeStyle="indianred",a.lineWidth=1):(a.strokeStyle="rgba(255, 255, 255, 0.4)",a.globalCompositeOperation="overlay",
a.lineWidth=2),a.stroke(),a.globalCompositeOperation="source-over"},o.bodyPositions=function(e,t,n){var o,i,r,s,a=n,l=(e.engine,e.options);for(a.beginPath(),r=0;r<t.length;r++)if(o=t[r],o.render.visible)for(s=0;s<o.parts.length;s++)i=o.parts[s],a.arc(i.position.x,i.position.y,3,0,2*Math.PI,!1),a.closePath();for(l.wireframes?a.fillStyle="indianred":a.fillStyle="rgba(0,0,0,0.5)",a.fill(),a.beginPath(),r=0;r<t.length;r++)o=t[r],o.render.visible&&(a.arc(o.positionPrev.x,o.positionPrev.y,2,0,2*Math.PI,!1),a.closePath());a.fillStyle="rgba(255,165,0,0.8)",a.fill()},o.bodyVelocity=function(e,t,n){var o=n;o.beginPath();for(var i=0;i<t.length;i++){var r=t[i];r.render.visible&&(o.moveTo(r.position.x,r.position.y),o.lineTo(r.position.x+2*(r.position.x-r.positionPrev.x),r.position.y+2*(r.position.y-r.positionPrev.y)))}o.lineWidth=3,o.strokeStyle="cornflowerblue",o.stroke()},o.bodyIds=function(e,t,n){var o,i,r=n;for(o=0;o<t.length;o++)if(t[o].render.visible){var s=t[o].parts
;for(i=s.length>1?1:0;i<s.length;i++){var a=s[i];r.font="12px Arial",r.fillStyle="rgba(255,255,255,0.5)",r.fillText(a.id,a.position.x+10,a.position.y-10)}}},o.collisions=function(e,t,n){var o,i,r,s,a=n,l=e.options;for(a.beginPath(),r=0;r<t.length;r++)if(o=t[r],o.isActive)for(i=o.collision,s=0;s<o.activeContacts.length;s++){var c=o.activeContacts[s],d=c.vertex;a.rect(d.x-1.5,d.y-1.5,3.5,3.5)}for(l.wireframes?a.fillStyle="rgba(255,255,255,0.7)":a.fillStyle="orange",a.fill(),a.beginPath(),r=0;r<t.length;r++)if(o=t[r],o.isActive&&(i=o.collision,o.activeContacts.length>0)){var u=o.activeContacts[0].vertex.x,p=o.activeContacts[0].vertex.y;2===o.activeContacts.length&&(u=(o.activeContacts[0].vertex.x+o.activeContacts[1].vertex.x)/2,p=(o.activeContacts[0].vertex.y+o.activeContacts[1].vertex.y)/2),i.bodyB===i.supports[0].body||!0===i.bodyA.isStatic?a.moveTo(u-8*i.normal.x,p-8*i.normal.y):a.moveTo(u+8*i.normal.x,p+8*i.normal.y),a.lineTo(u,p)}
l.wireframes?a.strokeStyle="rgba(255,165,0,0.7)":a.strokeStyle="orange",a.lineWidth=1,a.stroke()},o.separations=function(e,t,n){var o,i,r,s,a,l=n,c=e.options;for(l.beginPath(),a=0;a<t.length;a++)if(o=t[a],o.isActive){i=o.collision,r=i.bodyA,s=i.bodyB;var d=1;s.isStatic||r.isStatic||(d=.5),s.isStatic&&(d=0),l.moveTo(s.position.x,s.position.y),l.lineTo(s.position.x-i.penetration.x*d,s.position.y-i.penetration.y*d),d=1,s.isStatic||r.isStatic||(d=.5),r.isStatic&&(d=0),l.moveTo(r.position.x,r.position.y),l.lineTo(r.position.x+i.penetration.x*d,r.position.y+i.penetration.y*d)}c.wireframes?l.strokeStyle="rgba(255,165,0,0.5)":l.strokeStyle="orange",l.stroke()},o.grid=function(e,t,n){var o=n;e.options.wireframes?o.strokeStyle="rgba(255,180,0,0.1)":o.strokeStyle="rgba(255,180,0,0.5)",o.beginPath();for(var r=i.keys(t.buckets),s=0;s<r.length;s++){var a=r[s];if(!(t.buckets[a].length<2)){var l=a.split(/C|R/)
;o.rect(.5+parseInt(l[1],10)*t.bucketWidth,.5+parseInt(l[2],10)*t.bucketHeight,t.bucketWidth,t.bucketHeight)}}o.lineWidth=1,o.stroke()},o.inspector=function(e,t){var n,o=(e.engine,e.selected),i=e.render,r=i.options;if(r.hasBounds){var s=i.bounds.max.x-i.bounds.min.x,a=i.bounds.max.y-i.bounds.min.y,l=s/i.options.width,c=a/i.options.height;t.scale(1/l,1/c),t.translate(-i.bounds.min.x,-i.bounds.min.y)}for(var d=0;d<o.length;d++){var u=o[d].data;switch(t.translate(.5,.5),t.lineWidth=1,t.strokeStyle="rgba(255,165,0,0.9)",t.setLineDash([1,2]),u.type){case"body":n=u.bounds,t.beginPath(),t.rect(Math.floor(n.min.x-3),Math.floor(n.min.y-3),Math.floor(n.max.x-n.min.x+6),Math.floor(n.max.y-n.min.y+6)),t.closePath(),t.stroke();break;case"constraint":var p=u.pointA;u.bodyA&&(p=u.pointB),t.beginPath(),t.arc(p.x,p.y,10,0,2*Math.PI),t.closePath(),t.stroke()}t.setLineDash([]),t.translate(-.5,-.5)}null!==e.selectStart&&(t.translate(.5,.5),t.lineWidth=1,t.strokeStyle="rgba(255,165,0,0.6)",
t.fillStyle="rgba(255,165,0,0.1)",n=e.selectBounds,t.beginPath(),t.rect(Math.floor(n.min.x),Math.floor(n.min.y),Math.floor(n.max.x-n.min.x),Math.floor(n.max.y-n.min.y)),t.closePath(),t.stroke(),t.fill(),t.translate(-.5,-.5)),r.hasBounds&&t.setTransform(1,0,0,1,0,0)};var n=function(e,t){var n=document.createElement("canvas");return n.width=e,n.height=t,n.oncontextmenu=function(){return!1},n.onselectstart=function(){return!1},n},u=function(e){var t=e.getContext("2d");return(window.devicePixelRatio||1)/(t.webkitBackingStorePixelRatio||t.mozBackingStorePixelRatio||t.msBackingStorePixelRatio||t.oBackingStorePixelRatio||t.backingStorePixelRatio||1)},p=function(e,t){var n=e.textures[t];return n||(n=e.textures[t]=new Image,n.src=t,n)},f=function(e,t){var n=t;/(jpg|gif|png)$/.test(t)&&(n="url("+t+")"),e.canvas.style.background=n,e.canvas.style.backgroundSize="contain",e.currentBackground=t}}()},{"../body/Composite":2,"../collision/Grid":6,"../core/Common":14,"../core/Events":16,
"../core/Mouse":19,"../geometry/Bounds":26,"../geometry/Vector":28}],32:[function(e,t,n){var o={};t.exports=o;var i=e("../geometry/Bounds"),r=e("../body/Composite"),s=e("../core/Common"),a=e("../core/Events"),l=e("../geometry/Vector");!function(){var e,t;"undefined"!=typeof window&&(e=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame||function(e){window.setTimeout(function(){e(s.now())},1e3/60)},t=window.cancelAnimationFrame||window.mozCancelAnimationFrame||window.webkitCancelAnimationFrame||window.msCancelAnimationFrame),o.create=function(e){s.warn("RenderPixi.create: Matter.RenderPixi is deprecated (see docs)");var t={controller:o,engine:null,element:null,frameRequestId:null,canvas:null,renderer:null,container:null,spriteContainer:null,pixiOptions:null,options:{width:800,height:600,background:"#fafafa",wireframeBackground:"#222",hasBounds:!1,enabled:!0,wireframes:!0,showSleeping:!0,showDebug:!1,
showBroadphase:!1,showBounds:!1,showVelocity:!1,showCollisions:!1,showAxes:!1,showPositions:!1,showAngleIndicator:!1,showIds:!1,showShadows:!1}},n=s.extend(t,e),i=!n.options.wireframes&&"transparent"===n.options.background;return n.pixiOptions=n.pixiOptions||{view:n.canvas,transparent:i,antialias:!0,backgroundColor:e.background},n.mouse=e.mouse,n.engine=e.engine,n.renderer=n.renderer||new PIXI.WebGLRenderer(n.options.width,n.options.height,n.pixiOptions),n.container=n.container||new PIXI.Container,n.spriteContainer=n.spriteContainer||new PIXI.Container,n.canvas=n.canvas||n.renderer.view,n.bounds=n.bounds||{min:{x:0,y:0},max:{x:n.options.width,y:n.options.height}},a.on(n.engine,"beforeUpdate",function(){o.clear(n)}),n.textures={},n.sprites={},n.primitives={},n.container.addChild(n.spriteContainer),s.isElement(n.element)?n.element.appendChild(n.canvas):s.warn('No "render.element" passed, "render.canvas" was not inserted into document.'),n.canvas.oncontextmenu=function(){return!1},
n.canvas.onselectstart=function(){return!1},n},o.run=function(t){!function n(i){t.frameRequestId=e(n),o.world(t)}()},o.stop=function(e){t(e.frameRequestId)},o.clear=function(e){for(var t=e.container,n=e.spriteContainer;t.children[0];)t.removeChild(t.children[0]);for(;n.children[0];)n.removeChild(n.children[0]);var o=e.sprites["bg-0"];e.textures={},e.sprites={},e.primitives={},e.sprites["bg-0"]=o,o&&t.addChildAt(o,0),e.container.addChild(e.spriteContainer),e.currentBackground=null,t.scale.set(1,1),t.position.set(0,0)},o.setBackground=function(e,t){if(e.currentBackground!==t){var n=t.indexOf&&-1!==t.indexOf("#"),o=e.sprites["bg-0"];if(n){var i=s.colorToNumber(t);e.renderer.backgroundColor=i,o&&e.container.removeChild(o)}else if(!o){var r=d(e,t);o=e.sprites["bg-0"]=new PIXI.Sprite(r),o.position.x=0,o.position.y=0,e.container.addChildAt(o,0)}e.currentBackground=t}},o.world=function(e){
var t,n=e.engine,s=n.world,a=e.renderer,c=e.container,d=e.options,u=r.allBodies(s),p=r.allConstraints(s),f=[];d.wireframes?o.setBackground(e,d.wireframeBackground):o.setBackground(e,d.background);var m=e.bounds.max.x-e.bounds.min.x,v=e.bounds.max.y-e.bounds.min.y,y=m/e.options.width,g=v/e.options.height;if(d.hasBounds){for(t=0;t<u.length;t++){var x=u[t];x.render.sprite.visible=i.overlaps(x.bounds,e.bounds)}for(t=0;t<p.length;t++){var h=p[t],b=h.bodyA,w=h.bodyB,S=h.pointA,C=h.pointB;b&&(S=l.add(b.position,h.pointA)),w&&(C=l.add(w.position,h.pointB)),S&&C&&((i.contains(e.bounds,S)||i.contains(e.bounds,C))&&f.push(h))}c.scale.set(1/y,1/g),c.position.set(-e.bounds.min.x*(1/y),-e.bounds.min.y*(1/g))}else f=p;for(t=0;t<u.length;t++)o.body(e,u[t]);for(t=0;t<f.length;t++)o.constraint(e,f[t]);a.render(c)},o.constraint=function(e,t){var n=(e.engine,t.bodyA),o=t.bodyB,i=t.pointA,r=t.pointB,a=e.container,l=t.render,c="c-"+t.id,d=e.primitives[c];if(d||(d=e.primitives[c]=new PIXI.Graphics),
!l.visible||!t.pointA||!t.pointB)return void d.clear();-1===s.indexOf(a.children,d)&&a.addChild(d),d.clear(),d.beginFill(0,0),d.lineStyle(l.lineWidth,s.colorToNumber(l.strokeStyle),1),n?d.moveTo(n.position.x+i.x,n.position.y+i.y):d.moveTo(i.x,i.y),o?d.lineTo(o.position.x+r.x,o.position.y+r.y):d.lineTo(r.x,r.y),d.endFill()},o.body=function(e,t){var o=(e.engine,t.render);if(o.visible)if(o.sprite&&o.sprite.texture){var i="b-"+t.id,r=e.sprites[i],a=e.spriteContainer;r||(r=e.sprites[i]=n(e,t)),-1===s.indexOf(a.children,r)&&a.addChild(r),r.position.x=t.position.x,r.position.y=t.position.y,r.rotation=t.angle,r.scale.x=o.sprite.xScale||1,r.scale.y=o.sprite.yScale||1}else{var l="b-"+t.id,d=e.primitives[l],u=e.container;d||(d=e.primitives[l]=c(e,t),d.initialAngle=t.angle),-1===s.indexOf(u.children,d)&&u.addChild(d),d.position.x=t.position.x,d.position.y=t.position.y,d.rotation=t.angle-d.initialAngle}};var n=function(e,t){var n=t.render,o=n.sprite.texture,i=d(e,o),r=new PIXI.Sprite(i)
;return r.anchor.x=t.render.sprite.xOffset,r.anchor.y=t.render.sprite.yOffset,r},c=function(e,t){var n,o=t.render,i=e.options,r=new PIXI.Graphics,a=s.colorToNumber(o.fillStyle),l=s.colorToNumber(o.strokeStyle),c=s.colorToNumber(o.strokeStyle),d=s.colorToNumber("#bbb"),u=s.colorToNumber("#CD5C5C");r.clear();for(var p=t.parts.length>1?1:0;p<t.parts.length;p++){n=t.parts[p],i.wireframes?(r.beginFill(0,0),r.lineStyle(1,d,1)):(r.beginFill(a,1),r.lineStyle(o.lineWidth,l,1)),r.moveTo(n.vertices[0].x-t.position.x,n.vertices[0].y-t.position.y);for(var f=1;f<n.vertices.length;f++)r.lineTo(n.vertices[f].x-t.position.x,n.vertices[f].y-t.position.y);r.lineTo(n.vertices[0].x-t.position.x,n.vertices[0].y-t.position.y),r.endFill(),(i.showAngleIndicator||i.showAxes)&&(r.beginFill(0,0),i.wireframes?r.lineStyle(1,u,1):r.lineStyle(1,c),r.moveTo(n.position.x-t.position.x,n.position.y-t.position.y),
r.lineTo((n.vertices[0].x+n.vertices[n.vertices.length-1].x)/2-t.position.x,(n.vertices[0].y+n.vertices[n.vertices.length-1].y)/2-t.position.y),r.endFill())}return r},d=function(e,t){var n=e.textures[t];return n||(n=e.textures[t]=PIXI.Texture.fromImage(t)),n}}()},{"../body/Composite":2,"../core/Common":14,"../core/Events":16,"../geometry/Bounds":26,"../geometry/Vector":28}]},{},[30])(30)});
\ No newline at end of file
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.decomp=e()}}(function(){return function e(f,o,n){function d(t,l){if(!o[t]){if(!f[t]){var u="function"==typeof require&&require;if(!l&&u)return u(t,!0);if(i)return i(t,!0);throw new Error("Cannot find module '"+t+"'")}var p=o[t]={exports:{}};f[t][0].call(p.exports,function(e){var o=f[t][1][e];return d(o?o:e)},p,p.exports,e,f,o,n)}return o[t].exports}for(var i="function"==typeof require&&require,t=0;t<n.length;t++)d(n[t]);return d}({1:[function(e,f,o){function n(e,f,o){o=o||0;var n,d,i,t,l,u,p,s=[0,0];return n=e[1][1]-e[0][1],d=e[0][0]-e[1][0],i=n*e[0][0]+d*e[0][1],t=f[1][1]-f[0][1],l=f[0][0]-f[1][0],u=t*f[0][0]+l*f[0][1],p=n*l-t*d,B(p,0,o)||(s[0]=(l*i-d*u)/p,s[1]=(n*u-t*i)/p),s}function d(e,f,o,n){var d=f[0]-e[0],i=f[1]-e[1],t=n[0]-o[0],l=n[1]-o[1];if(t*i-l*d===0)return!1;var u=(d*(o[1]-e[1])+i*(e[0]-o[0]))/(t*i-l*d),p=(t*(e[1]-o[1])+l*(o[0]-e[0]))/(l*d-t*i);return u>=0&&1>=u&&p>=0&&1>=p}function i(e,f,o){return(f[0]-e[0])*(o[1]-e[1])-(o[0]-e[0])*(f[1]-e[1])}function t(e,f,o){return i(e,f,o)>0}function l(e,f,o){return i(e,f,o)>=0}function u(e,f,o){return i(e,f,o)<0}function p(e,f,o){return i(e,f,o)<=0}function s(e,f,o,n){if(n){var d=C,t=D;d[0]=f[0]-e[0],d[1]=f[1]-e[1],t[0]=o[0]-f[0],t[1]=o[1]-f[1];var l=d[0]*t[0]+d[1]*t[1],u=Math.sqrt(d[0]*d[0]+d[1]*d[1]),p=Math.sqrt(t[0]*t[0]+t[1]*t[1]),s=Math.acos(l/(u*p));return n>s}return 0===i(e,f,o)}function c(e,f){var o=f[0]-e[0],n=f[1]-e[1];return o*o+n*n}function y(e,f){var o=e.length;return e[0>f?f%o+o:f%o]}function a(e){e.length=0}function m(e,f,o,n){for(var d=o;n>d;d++)e.push(f[d])}function r(e){for(var f=0,o=e,n=1;n<e.length;++n)(o[n][1]<o[f][1]||o[n][1]===o[f][1]&&o[n][0]>o[f][0])&&(f=n);t(y(e,f-1),y(e,f),y(e,f+1))||w(e)}function w(e){for(var f=[],o=e.length,n=0;n!==o;n++)f.push(e.pop());for(var n=0;n!==o;n++)e[n]=f[n]}function b(e,f){return u(y(e,f-1),y(e,f),y(e,f+1))}function g(e,f,o){var d,i,t=E,u=F;if(l(y(e,f+1),y(e,f),y(e,o))&&p(y(e,f-1),y(e,f),y(e,o)))return!1;i=c(y(e,f),y(e,o));for(var s=0;s!==e.length;++s)if((s+1)%e.length!==f&&s!==f&&l(y(e,f),y(e,o),y(e,s+1))&&p(y(e,f),y(e,o),y(e,s))&&(t[0]=y(e,f),t[1]=y(e,o),u[0]=y(e,s),u[1]=y(e,s+1),d=n(t,u),c(y(e,f),d)<i))return!1;return!0}function x(e,f,o,n){var d=n||[];if(a(d),o>f)for(var i=f;o>=i;i++)d.push(e[i]);else{for(var i=0;o>=i;i++)d.push(e[i]);for(var i=f;i<e.length;i++)d.push(e[i])}return d}function j(e){for(var f=[],o=[],n=[],d=[],i=Number.MAX_VALUE,t=0;t<e.length;++t)if(b(e,t))for(var l=0;l<e.length;++l)if(g(e,t,l)){o=j(x(e,t,l,d)),n=j(x(e,l,t,d));for(var u=0;u<n.length;u++)o.push(n[u]);o.length<i&&(f=o,i=o.length,f.push([y(e,t),y(e,l)]))}return f}function v(e){var f=j(e);return f.length>0?h(e,f):[e]}function h(e,f){if(0===f.length)return[e];if(f instanceof Array&&f.length&&f[0]instanceof Array&&2===f[0].length&&f[0][0]instanceof Array){for(var o=[e],n=0;n<f.length;n++)for(var d=f[n],i=0;i<o.length;i++){var t=o[i],l=h(t,d);if(l){o.splice(i,1),o.push(l[0],l[1]);break}}return o}var d=f,n=e.indexOf(d[0]),i=e.indexOf(d[1]);return-1!==n&&-1!==i?[x(e,n,i),x(e,i,n)]:!1}function k(e){var f,o=e;for(f=0;f<o.length-1;f++)for(var n=0;f-1>n;n++)if(d(o[f],o[f+1],o[n],o[n+1]))return!1;for(f=1;f<o.length-2;f++)if(d(o[0],o[o.length-1],o[f],o[f+1]))return!1;return!0}function q(e,f,o,n,d){d=d||0;var i=f[1]-e[1],t=e[0]-f[0],l=i*e[0]+t*e[1],u=n[1]-o[1],p=o[0]-n[0],s=u*o[0]+p*o[1],c=i*p-u*t;return B(c,0,d)?[0,0]:[(p*l-t*s)/c,(i*s-u*l)/c]}function z(e,f,o,n,d,i,s){i=i||100,s=s||0,d=d||25,f="undefined"!=typeof f?f:[],o=o||[],n=n||[];var a=[0,0],r=[0,0],w=[0,0],g=0,x=0,j=0,v=0,h=0,k=0,A=0,B=[],C=[],D=e,E=e;if(E.length<3)return f;if(s++,s>i)return console.warn("quickDecomp: max level ("+i+") reached."),f;for(var F=0;F<e.length;++F)if(b(D,F)){o.push(D[F]),g=x=Number.MAX_VALUE;for(var G=0;G<e.length;++G)t(y(D,F-1),y(D,F),y(D,G))&&p(y(D,F-1),y(D,F),y(D,G-1))&&(w=q(y(D,F-1),y(D,F),y(D,G),y(D,G-1)),u(y(D,F+1),y(D,F),w)&&(j=c(D[F],w),x>j&&(x=j,r=w,k=G))),t(y(D,F+1),y(D,F),y(D,G+1))&&p(y(D,F+1),y(D,F),y(D,G))&&(w=q(y(D,F+1),y(D,F),y(D,G),y(D,G+1)),t(y(D,F-1),y(D,F),w)&&(j=c(D[F],w),g>j&&(g=j,a=w,h=G)));if(k===(h+1)%e.length)w[0]=(r[0]+a[0])/2,w[1]=(r[1]+a[1])/2,n.push(w),h>F?(m(B,D,F,h+1),B.push(w),C.push(w),0!==k&&m(C,D,k,D.length),m(C,D,0,F+1)):(0!==F&&m(B,D,F,D.length),m(B,D,0,h+1),B.push(w),C.push(w),m(C,D,k,F+1));else{if(k>h&&(h+=e.length),v=Number.MAX_VALUE,k>h)return f;for(var G=k;h>=G;++G)l(y(D,F-1),y(D,F),y(D,G))&&p(y(D,F+1),y(D,F),y(D,G))&&(j=c(y(D,F),y(D,G)),v>j&&(v=j,A=G%e.length));A>F?(m(B,D,F,A+1),0!==A&&m(C,D,A,E.length),m(C,D,0,F+1)):(0!==F&&m(B,D,F,E.length),m(B,D,0,A+1),m(C,D,A,F+1))}return B.length<C.length?(z(B,f,o,n,d,i,s),z(C,f,o,n,d,i,s)):(z(C,f,o,n,d,i,s),z(B,f,o,n,d,i,s)),f}return f.push(e),f}function A(e,f){for(var o=0,n=e.length-1;e.length>3&&n>=0;--n)s(y(e,n-1),y(e,n),y(e,n+1),f)&&(e.splice(n%e.length,1),o++);return o}function B(e,f,o){return o=o||0,Math.abs(e-f)<o}f.exports={decomp:v,quickDecomp:z,isSimple:k,removeCollinearPoints:A,makeCCW:r};var C=[],D=[],E=[],F=[]},{}]},{},[1])(1)});
/**
* matter-js 0.14.2 by @liabru 2018-06-11
* http://brm.io/matter-js/
* License MIT
*/
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.Matter=e()}}(function(){return function(){function e(t,n,o){function i(s,a){if(!n[s]){if(!t[s]){var l="function"==typeof require&&require;if(!a&&l)return l(s,!0);if(r)return r(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var d=n[s]={exports:{}};t[s][0].call(d.exports,function(e){return i(t[s][1][e]||e)},d,d.exports,e,t,n,o)}return n[s].exports}for(var r="function"==typeof require&&require,s=0;s<o.length;s++)i(o[s]);return i}return e}()({1:[function(e,t,n){var o={};t.exports=o;var i=e("../geometry/Vertices"),r=e("../geometry/Vector"),s=e("../core/Sleeping"),a=(e("../render/Render"),e("../core/Common")),l=e("../geometry/Bounds"),c=e("../geometry/Axes");!function(){o._inertiaScale=4,
o._nextCollidingGroupId=1,o._nextNonCollidingGroupId=-1,o._nextCategory=1,o.create=function(t){var n={id:a.nextId(),type:"body",label:"Body",parts:[],plugin:{},angle:0,vertices:i.fromPath("L 0 0 L 40 0 L 40 40 L 0 40"),position:{x:0,y:0},force:{x:0,y:0},torque:0,positionImpulse:{x:0,y:0},constraintImpulse:{x:0,y:0,angle:0},totalContacts:0,speed:0,angularSpeed:0,velocity:{x:0,y:0},angularVelocity:0,isSensor:!1,isStatic:!1,isSleeping:!1,motion:0,sleepThreshold:60,density:.001,restitution:0,friction:.1,frictionStatic:.5,frictionAir:.01,collisionFilter:{category:1,mask:4294967295,group:0},slop:.05,timeScale:1,render:{visible:!0,opacity:1,sprite:{xScale:1,yScale:1,xOffset:0,yOffset:0},lineWidth:0}},o=a.extend(n,t);return e(o,t),o},o.nextGroup=function(e){return e?o._nextNonCollidingGroupId--:o._nextCollidingGroupId++},o.nextCategory=function(){return o._nextCategory=o._nextCategory<<1,o._nextCategory};var e=function(e,t){t=t||{},o.set(e,{bounds:e.bounds||l.create(e.vertices),
positionPrev:e.positionPrev||r.clone(e.position),anglePrev:e.anglePrev||e.angle,vertices:e.vertices,parts:e.parts||[e],isStatic:e.isStatic,isSleeping:e.isSleeping,parent:e.parent||e}),i.rotate(e.vertices,e.angle,e.position),c.rotate(e.axes,e.angle),l.update(e.bounds,e.vertices,e.velocity),o.set(e,{axes:t.axes||e.axes,area:t.area||e.area,mass:t.mass||e.mass,inertia:t.inertia||e.inertia});var n=e.isStatic?"#2e2b44":a.choose(["#006BA6","#0496FF","#FFBC42","#D81159","#8F2D56"]);e.render.fillStyle=e.render.fillStyle||n,e.render.strokeStyle=e.render.strokeStyle||"#000",e.render.sprite.xOffset+=-(e.bounds.min.x-e.position.x)/(e.bounds.max.x-e.bounds.min.x),e.render.sprite.yOffset+=-(e.bounds.min.y-e.position.y)/(e.bounds.max.y-e.bounds.min.y)};o.set=function(e,t,n){var i;"string"==typeof t&&(i=t,t={},t[i]=n);for(i in t)if(n=t[i],t.hasOwnProperty(i))switch(i){case"isStatic":o.setStatic(e,n);break;case"isSleeping":s.set(e,n);break;case"mass":o.setMass(e,n);break;case"density":o.setDensity(e,n)
;break;case"inertia":o.setInertia(e,n);break;case"vertices":o.setVertices(e,n);break;case"position":o.setPosition(e,n);break;case"angle":o.setAngle(e,n);break;case"velocity":o.setVelocity(e,n);break;case"angularVelocity":o.setAngularVelocity(e,n);break;case"parts":o.setParts(e,n);break;default:e[i]=n}},o.setStatic=function(e,t){for(var n=0;n<e.parts.length;n++){var o=e.parts[n];o.isStatic=t,t?(o._original={restitution:o.restitution,friction:o.friction,mass:o.mass,inertia:o.inertia,density:o.density,inverseMass:o.inverseMass,inverseInertia:o.inverseInertia},o.restitution=0,o.friction=1,o.mass=o.inertia=o.density=1/0,o.inverseMass=o.inverseInertia=0,o.positionPrev.x=o.position.x,o.positionPrev.y=o.position.y,o.anglePrev=o.angle,o.angularVelocity=0,o.speed=0,o.angularSpeed=0,o.motion=0):o._original&&(o.restitution=o._original.restitution,o.friction=o._original.friction,o.mass=o._original.mass,o.inertia=o._original.inertia,o.density=o._original.density,
o.inverseMass=o._original.inverseMass,o.inverseInertia=o._original.inverseInertia,delete o._original)}},o.setMass=function(e,t){var n=e.inertia/(e.mass/6);e.inertia=n*(t/6),e.inverseInertia=1/e.inertia,e.mass=t,e.inverseMass=1/e.mass,e.density=e.mass/e.area},o.setDensity=function(e,t){o.setMass(e,t*e.area),e.density=t},o.setInertia=function(e,t){e.inertia=t,e.inverseInertia=1/e.inertia},o.setVertices=function(e,t){t[0].body===e?e.vertices=t:e.vertices=i.create(t,e),e.axes=c.fromVertices(e.vertices),e.area=i.area(e.vertices),o.setMass(e,e.density*e.area);var n=i.centre(e.vertices);i.translate(e.vertices,n,-1),o.setInertia(e,o._inertiaScale*i.inertia(e.vertices,e.mass)),i.translate(e.vertices,e.position),l.update(e.bounds,e.vertices,e.velocity)},o.setParts=function(e,t,n){var r;for(t=t.slice(0),e.parts.length=0,e.parts.push(e),e.parent=e,r=0;r<t.length;r++){var s=t[r];s!==e&&(s.parent=e,e.parts.push(s))}if(1!==e.parts.length){if(n=void 0===n||n){var a=[]
;for(r=0;r<t.length;r++)a=a.concat(t[r].vertices);i.clockwiseSort(a);var l=i.hull(a),c=i.centre(l);o.setVertices(e,l),i.translate(e.vertices,c)}var d=o._totalProperties(e);e.area=d.area,e.parent=e,e.position.x=d.centre.x,e.position.y=d.centre.y,e.positionPrev.x=d.centre.x,e.positionPrev.y=d.centre.y,o.setMass(e,d.mass),o.setInertia(e,d.inertia),o.setPosition(e,d.centre)}},o.setPosition=function(e,t){var n=r.sub(t,e.position);e.positionPrev.x+=n.x,e.positionPrev.y+=n.y;for(var o=0;o<e.parts.length;o++){var s=e.parts[o];s.position.x+=n.x,s.position.y+=n.y,i.translate(s.vertices,n),l.update(s.bounds,s.vertices,e.velocity)}},o.setAngle=function(e,t){var n=t-e.angle;e.anglePrev+=n;for(var o=0;o<e.parts.length;o++){var s=e.parts[o];s.angle+=n,i.rotate(s.vertices,n,e.position),c.rotate(s.axes,n),l.update(s.bounds,s.vertices,e.velocity),o>0&&r.rotateAbout(s.position,n,e.position,s.position)}},o.setVelocity=function(e,t){e.positionPrev.x=e.position.x-t.x,e.positionPrev.y=e.position.y-t.y,
e.velocity.x=t.x,e.velocity.y=t.y,e.speed=r.magnitude(e.velocity)},o.setAngularVelocity=function(e,t){e.anglePrev=e.angle-t,e.angularVelocity=t,e.angularSpeed=Math.abs(e.angularVelocity)},o.translate=function(e,t){o.setPosition(e,r.add(e.position,t))},o.rotate=function(e,t,n){if(n){var i=Math.cos(t),r=Math.sin(t),s=e.position.x-n.x,a=e.position.y-n.y;o.setPosition(e,{x:n.x+(s*i-a*r),y:n.y+(s*r+a*i)}),o.setAngle(e,e.angle+t)}else o.setAngle(e,e.angle+t)},o.scale=function(e,t,n,r){var s=0,a=0;r=r||e.position;for(var d=0;d<e.parts.length;d++){var u=e.parts[d];i.scale(u.vertices,t,n,r),u.axes=c.fromVertices(u.vertices),u.area=i.area(u.vertices),o.setMass(u,e.density*u.area),i.translate(u.vertices,{x:-u.position.x,y:-u.position.y}),o.setInertia(u,o._inertiaScale*i.inertia(u.vertices,u.mass)),i.translate(u.vertices,{x:u.position.x,y:u.position.y}),d>0&&(s+=u.area,a+=u.inertia),u.position.x=r.x+(u.position.x-r.x)*t,u.position.y=r.y+(u.position.y-r.y)*n,l.update(u.bounds,u.vertices,e.velocity)
}e.parts.length>1&&(e.area=s,e.isStatic||(o.setMass(e,e.density*s),o.setInertia(e,a))),e.circleRadius&&(t===n?e.circleRadius*=t:e.circleRadius=null)},o.update=function(e,t,n,o){var s=Math.pow(t*n*e.timeScale,2),a=1-e.frictionAir*n*e.timeScale,d=e.position.x-e.positionPrev.x,u=e.position.y-e.positionPrev.y;e.velocity.x=d*a*o+e.force.x/e.mass*s,e.velocity.y=u*a*o+e.force.y/e.mass*s,e.positionPrev.x=e.position.x,e.positionPrev.y=e.position.y,e.position.x+=e.velocity.x,e.position.y+=e.velocity.y,e.angularVelocity=(e.angle-e.anglePrev)*a*o+e.torque/e.inertia*s,e.anglePrev=e.angle,e.angle+=e.angularVelocity,e.speed=r.magnitude(e.velocity),e.angularSpeed=Math.abs(e.angularVelocity);for(var p=0;p<e.parts.length;p++){var f=e.parts[p];i.translate(f.vertices,e.velocity),p>0&&(f.position.x+=e.velocity.x,f.position.y+=e.velocity.y),0!==e.angularVelocity&&(i.rotate(f.vertices,e.angularVelocity,e.position),c.rotate(f.axes,e.angularVelocity),
p>0&&r.rotateAbout(f.position,e.angularVelocity,e.position,f.position)),l.update(f.bounds,f.vertices,e.velocity)}},o.applyForce=function(e,t,n){e.force.x+=n.x,e.force.y+=n.y;var o={x:t.x-e.position.x,y:t.y-e.position.y};e.torque+=o.x*n.y-o.y*n.x},o._totalProperties=function(e){for(var t={mass:0,area:0,inertia:0,centre:{x:0,y:0}},n=1===e.parts.length?0:1;n<e.parts.length;n++){var o=e.parts[n],i=o.mass!==1/0?o.mass:1;t.mass+=i,t.area+=o.area,t.inertia+=o.inertia,t.centre=r.add(t.centre,r.mult(o.position,i))}return t.centre=r.div(t.centre,t.mass),t}}()},{"../core/Common":14,"../core/Sleeping":22,"../geometry/Axes":25,"../geometry/Bounds":26,"../geometry/Vector":28,"../geometry/Vertices":29,"../render/Render":31}],2:[function(e,t,n){var o={};t.exports=o;var i=e("../core/Events"),r=e("../core/Common"),s=e("../geometry/Bounds"),a=e("./Body");!function(){o.create=function(e){return r.extend({id:r.nextId(),type:"composite",parent:null,isModified:!1,bodies:[],constraints:[],composites:[],
label:"Composite",plugin:{}},e)},o.setModified=function(e,t,n,i){if(e.isModified=t,n&&e.parent&&o.setModified(e.parent,t,n,i),i)for(var r=0;r<e.composites.length;r++){var s=e.composites[r];o.setModified(s,t,n,i)}},o.add=function(e,t){var n=[].concat(t);i.trigger(e,"beforeAdd",{object:t});for(var s=0;s<n.length;s++){var a=n[s];switch(a.type){case"body":if(a.parent!==a){r.warn("Composite.add: skipped adding a compound body part (you must add its parent instead)");break}o.addBody(e,a);break;case"constraint":o.addConstraint(e,a);break;case"composite":o.addComposite(e,a);break;case"mouseConstraint":o.addConstraint(e,a.constraint)}}return i.trigger(e,"afterAdd",{object:t}),e},o.remove=function(e,t,n){var r=[].concat(t);i.trigger(e,"beforeRemove",{object:t});for(var s=0;s<r.length;s++){var a=r[s];switch(a.type){case"body":o.removeBody(e,a,n);break;case"constraint":o.removeConstraint(e,a,n);break;case"composite":o.removeComposite(e,a,n);break;case"mouseConstraint":
o.removeConstraint(e,a.constraint)}}return i.trigger(e,"afterRemove",{object:t}),e},o.addComposite=function(e,t){return e.composites.push(t),t.parent=e,o.setModified(e,!0,!0,!1),e},o.removeComposite=function(e,t,n){var i=r.indexOf(e.composites,t);if(-1!==i&&(o.removeCompositeAt(e,i),o.setModified(e,!0,!0,!1)),n)for(var s=0;s<e.composites.length;s++)o.removeComposite(e.composites[s],t,!0);return e},o.removeCompositeAt=function(e,t){return e.composites.splice(t,1),o.setModified(e,!0,!0,!1),e},o.addBody=function(e,t){return e.bodies.push(t),o.setModified(e,!0,!0,!1),e},o.removeBody=function(e,t,n){var i=r.indexOf(e.bodies,t);if(-1!==i&&(o.removeBodyAt(e,i),o.setModified(e,!0,!0,!1)),n)for(var s=0;s<e.composites.length;s++)o.removeBody(e.composites[s],t,!0);return e},o.removeBodyAt=function(e,t){return e.bodies.splice(t,1),o.setModified(e,!0,!0,!1),e},o.addConstraint=function(e,t){return e.constraints.push(t),o.setModified(e,!0,!0,!1),e},o.removeConstraint=function(e,t,n){
var i=r.indexOf(e.constraints,t);if(-1!==i&&o.removeConstraintAt(e,i),n)for(var s=0;s<e.composites.length;s++)o.removeConstraint(e.composites[s],t,!0);return e},o.removeConstraintAt=function(e,t){return e.constraints.splice(t,1),o.setModified(e,!0,!0,!1),e},o.clear=function(e,t,n){if(n)for(var i=0;i<e.composites.length;i++)o.clear(e.composites[i],t,!0);return t?e.bodies=e.bodies.filter(function(e){return e.isStatic}):e.bodies.length=0,e.constraints.length=0,e.composites.length=0,o.setModified(e,!0,!0,!1),e},o.allBodies=function(e){for(var t=[].concat(e.bodies),n=0;n<e.composites.length;n++)t=t.concat(o.allBodies(e.composites[n]));return t},o.allConstraints=function(e){for(var t=[].concat(e.constraints),n=0;n<e.composites.length;n++)t=t.concat(o.allConstraints(e.composites[n]));return t},o.allComposites=function(e){for(var t=[].concat(e.composites),n=0;n<e.composites.length;n++)t=t.concat(o.allComposites(e.composites[n]));return t},o.get=function(e,t,n){var i,r;switch(n){case"body":
i=o.allBodies(e);break;case"constraint":i=o.allConstraints(e);break;case"composite":i=o.allComposites(e).concat(e)}return i?(r=i.filter(function(e){return e.id.toString()===t.toString()}),0===r.length?null:r[0]):null},o.move=function(e,t,n){return o.remove(e,t),o.add(n,t),e},o.rebase=function(e){for(var t=o.allBodies(e).concat(o.allConstraints(e)).concat(o.allComposites(e)),n=0;n<t.length;n++)t[n].id=r.nextId();return o.setModified(e,!0,!0,!1),e},o.translate=function(e,t,n){for(var i=n?o.allBodies(e):e.bodies,r=0;r<i.length;r++)a.translate(i[r],t);return o.setModified(e,!0,!0,!1),e},o.rotate=function(e,t,n,i){for(var r=Math.cos(t),s=Math.sin(t),l=i?o.allBodies(e):e.bodies,c=0;c<l.length;c++){var d=l[c],u=d.position.x-n.x,p=d.position.y-n.y;a.setPosition(d,{x:n.x+(u*r-p*s),y:n.y+(u*s+p*r)}),a.rotate(d,t)}return o.setModified(e,!0,!0,!1),e},o.scale=function(e,t,n,i,r){for(var s=r?o.allBodies(e):e.bodies,l=0;l<s.length;l++){var c=s[l],d=c.position.x-i.x,u=c.position.y-i.y
;a.setPosition(c,{x:i.x+d*t,y:i.y+u*n}),a.scale(c,t,n)}return o.setModified(e,!0,!0,!1),e},o.bounds=function(e){for(var t=o.allBodies(e),n=[],i=0;i<t.length;i+=1){var r=t[i];n.push(r.bounds.min,r.bounds.max)}return s.create(n)}}()},{"../core/Common":14,"../core/Events":16,"../geometry/Bounds":26,"./Body":1}],3:[function(e,t,n){var o={};t.exports=o;var i=e("./Composite"),r=(e("../constraint/Constraint"),e("../core/Common"));!function(){o.create=function(e){var t=i.create(),n={label:"World",gravity:{x:0,y:1,scale:.001},bounds:{min:{x:-1/0,y:-1/0},max:{x:1/0,y:1/0}}};return r.extend(t,n,e)}}()},{"../constraint/Constraint":12,"../core/Common":14,"./Composite":2}],4:[function(e,t,n){var o={};t.exports=o,function(){o.create=function(e){return{id:o.id(e),vertex:e,normalImpulse:0,tangentImpulse:0}},o.id=function(e){return e.body.id+"_"+e.index}}()},{}],5:[function(e,t,n){var o={};t.exports=o;var i=e("./SAT"),r=e("./Pair"),s=e("../geometry/Bounds");!function(){o.collisions=function(e,t){
for(var n=[],a=t.pairs.table,l=0;l<e.length;l++){var c=e[l][0],d=e[l][1];if((!c.isStatic&&!c.isSleeping||!d.isStatic&&!d.isSleeping)&&(o.canCollide(c.collisionFilter,d.collisionFilter)&&s.overlaps(c.bounds,d.bounds)))for(var u=c.parts.length>1?1:0;u<c.parts.length;u++)for(var p=c.parts[u],f=d.parts.length>1?1:0;f<d.parts.length;f++){var m=d.parts[f];if(p===c&&m===d||s.overlaps(p.bounds,m.bounds)){var v,y=r.id(p,m),g=a[y];v=g&&g.isActive?g.collision:null;var x=i.collides(p,m,v);x.collided&&n.push(x)}}}return n},o.canCollide=function(e,t){return e.group===t.group&&0!==e.group?e.group>0:0!=(e.mask&t.category)&&0!=(t.mask&e.category)}}()},{"../geometry/Bounds":26,"./Pair":7,"./SAT":11}],6:[function(e,t,n){var o={};t.exports=o;var i=e("./Pair"),r=e("./Detector"),s=e("../core/Common");!function(){o.create=function(e){var t={controller:o,detector:r.collisions,buckets:{},pairs:{},pairsList:[],bucketWidth:48,bucketHeight:48};return s.extend(t,e)},o.update=function(e,t,n,i){
var r,s,a,l,c,d=n.world,u=e.buckets,p=!1;for(r=0;r<t.length;r++){var f=t[r];if((!f.isSleeping||i)&&!(f.bounds.max.x<d.bounds.min.x||f.bounds.min.x>d.bounds.max.x||f.bounds.max.y<d.bounds.min.y||f.bounds.min.y>d.bounds.max.y)){var m=o._getRegion(e,f);if(!f.region||m.id!==f.region.id||i){f.region&&!i||(f.region=m);var v=o._regionUnion(m,f.region);for(s=v.startCol;s<=v.endCol;s++)for(a=v.startRow;a<=v.endRow;a++){c=o._getBucketId(s,a),l=u[c];var y=s>=m.startCol&&s<=m.endCol&&a>=m.startRow&&a<=m.endRow,g=s>=f.region.startCol&&s<=f.region.endCol&&a>=f.region.startRow&&a<=f.region.endRow;!y&&g&&g&&l&&o._bucketRemoveBody(e,l,f),(f.region===m||y&&!g||i)&&(l||(l=o._createBucket(u,c)),o._bucketAddBody(e,l,f))}f.region=m,p=!0}}}p&&(e.pairsList=o._createActivePairsList(e))},o.clear=function(e){e.buckets={},e.pairs={},e.pairsList=[]},o._regionUnion=function(e,t){var n=Math.min(e.startCol,t.startCol),i=Math.max(e.endCol,t.endCol),r=Math.min(e.startRow,t.startRow),s=Math.max(e.endRow,t.endRow)
;return o._createRegion(n,i,r,s)},o._getRegion=function(e,t){var n=t.bounds,i=Math.floor(n.min.x/e.bucketWidth),r=Math.floor(n.max.x/e.bucketWidth),s=Math.floor(n.min.y/e.bucketHeight),a=Math.floor(n.max.y/e.bucketHeight);return o._createRegion(i,r,s,a)},o._createRegion=function(e,t,n,o){return{id:e+","+t+","+n+","+o,startCol:e,endCol:t,startRow:n,endRow:o}},o._getBucketId=function(e,t){return"C"+e+"R"+t},o._createBucket=function(e,t){return e[t]=[]},o._bucketAddBody=function(e,t,n){for(var o=0;o<t.length;o++){var r=t[o];if(!(n.id===r.id||n.isStatic&&r.isStatic)){var s=i.id(n,r),a=e.pairs[s];a?a[2]+=1:e.pairs[s]=[n,r,1]}}t.push(n)},o._bucketRemoveBody=function(e,t,n){t.splice(s.indexOf(t,n),1);for(var o=0;o<t.length;o++){var r=t[o],a=i.id(n,r),l=e.pairs[a];l&&(l[2]-=1)}},o._createActivePairsList=function(e){var t,n,o=[];t=s.keys(e.pairs);for(var i=0;i<t.length;i++)n=e.pairs[t[i]],n[2]>0?o.push(n):delete e.pairs[t[i]];return o}}()},{"../core/Common":14,"./Detector":5,"./Pair":7}],
7:[function(e,t,n){var o={};t.exports=o;var i=e("./Contact");!function(){o.create=function(e,t){var n=e.bodyA,i=e.bodyB,r=e.parentA,s=e.parentB,a={id:o.id(n,i),bodyA:n,bodyB:i,contacts:{},activeContacts:[],separation:0,isActive:!0,isSensor:n.isSensor||i.isSensor,timeCreated:t,timeUpdated:t,inverseMass:r.inverseMass+s.inverseMass,friction:Math.min(r.friction,s.friction),frictionStatic:Math.max(r.frictionStatic,s.frictionStatic),restitution:Math.max(r.restitution,s.restitution),slop:Math.max(r.slop,s.slop)};return o.update(a,e,t),a},o.update=function(e,t,n){var r=e.contacts,s=t.supports,a=e.activeContacts,l=t.parentA,c=t.parentB;if(e.collision=t,e.inverseMass=l.inverseMass+c.inverseMass,e.friction=Math.min(l.friction,c.friction),e.frictionStatic=Math.max(l.frictionStatic,c.frictionStatic),e.restitution=Math.max(l.restitution,c.restitution),e.slop=Math.max(l.slop,c.slop),a.length=0,t.collided){for(var d=0;d<s.length;d++){var u=s[d],p=i.id(u),f=r[p];f?a.push(f):a.push(r[p]=i.create(u))}
e.separation=t.depth,o.setActive(e,!0,n)}else!0===e.isActive&&o.setActive(e,!1,n)},o.setActive=function(e,t,n){t?(e.isActive=!0,e.timeUpdated=n):(e.isActive=!1,e.activeContacts.length=0)},o.id=function(e,t){return e.id<t.id?"A"+e.id+"B"+t.id:"A"+t.id+"B"+e.id}}()},{"./Contact":4}],8:[function(e,t,n){var o={};t.exports=o;var i=e("./Pair"),r=e("../core/Common");!function(){o._pairMaxIdleLife=1e3,o.create=function(e){return r.extend({table:{},list:[],collisionStart:[],collisionActive:[],collisionEnd:[]},e)},o.update=function(e,t,n){var o,s,a,l,c=e.list,d=e.table,u=e.collisionStart,p=e.collisionEnd,f=e.collisionActive,m=[];for(u.length=0,p.length=0,f.length=0,l=0;l<t.length;l++)o=t[l],o.collided&&(s=i.id(o.bodyA,o.bodyB),m.push(s),a=d[s],a?(a.isActive?f.push(a):u.push(a),i.update(a,o,n)):(a=i.create(o,n),d[s]=a,u.push(a),c.push(a)));for(l=0;l<c.length;l++)a=c[l],a.isActive&&-1===r.indexOf(m,a.id)&&(i.setActive(a,!1,n),p.push(a))},o.removeOld=function(e,t){
var n,i,r,s,a=e.list,l=e.table,c=[];for(s=0;s<a.length;s++)n=a[s],i=n.collision,i.bodyA.isSleeping||i.bodyB.isSleeping?n.timeUpdated=t:t-n.timeUpdated>o._pairMaxIdleLife&&c.push(s);for(s=0;s<c.length;s++)r=c[s]-s,n=a[r],delete l[n.id],a.splice(r,1)},o.clear=function(e){return e.table={},e.list.length=0,e.collisionStart.length=0,e.collisionActive.length=0,e.collisionEnd.length=0,e}}()},{"../core/Common":14,"./Pair":7}],9:[function(e,t,n){var o={};t.exports=o;var i=e("../geometry/Vector"),r=e("./SAT"),s=e("../geometry/Bounds"),a=e("../factory/Bodies"),l=e("../geometry/Vertices");!function(){o.collides=function(e,t){for(var n=[],o=0;o<t.length;o++){var i=t[o];if(s.overlaps(i.bounds,e.bounds))for(var a=1===i.parts.length?0:1;a<i.parts.length;a++){var l=i.parts[a];if(s.overlaps(l.bounds,e.bounds)){var c=r.collides(l,e);if(c.collided){n.push(c);break}}}}return n},o.ray=function(e,t,n,r){r=r||1e-100
;for(var s=i.angle(t,n),l=i.magnitude(i.sub(t,n)),c=.5*(n.x+t.x),d=.5*(n.y+t.y),u=a.rectangle(c,d,l,r,{angle:s}),p=o.collides(u,e),f=0;f<p.length;f+=1){var m=p[f];m.body=m.bodyB=m.bodyA}return p},o.region=function(e,t,n){for(var o=[],i=0;i<e.length;i++){var r=e[i],a=s.overlaps(r.bounds,t);(a&&!n||!a&&n)&&o.push(r)}return o},o.point=function(e,t){for(var n=[],o=0;o<e.length;o++){var i=e[o];if(s.contains(i.bounds,t))for(var r=1===i.parts.length?0:1;r<i.parts.length;r++){var a=i.parts[r];if(s.contains(a.bounds,t)&&l.contains(a.vertices,t)){n.push(i);break}}}return n}}()},{"../factory/Bodies":23,"../geometry/Bounds":26,"../geometry/Vector":28,"../geometry/Vertices":29,"./SAT":11}],10:[function(e,t,n){var o={};t.exports=o;var i=e("../geometry/Vertices"),r=e("../geometry/Vector"),s=e("../core/Common"),a=e("../geometry/Bounds");!function(){o._restingThresh=4,o._restingThreshTangent=6,o._positionDampen=.9,o._positionWarming=.8,o._frictionNormalMultiplier=5,o.preSolvePosition=function(e){
var t,n,o;for(t=0;t<e.length;t++)n=e[t],n.isActive&&(o=n.activeContacts.length,n.collision.parentA.totalContacts+=o,n.collision.parentB.totalContacts+=o)},o.solvePosition=function(e,t){var n,i,s,a,l,c,d,u,p,f=r._temp[0],m=r._temp[1],v=r._temp[2],y=r._temp[3];for(n=0;n<e.length;n++)i=e[n],i.isActive&&!i.isSensor&&(s=i.collision,a=s.parentA,l=s.parentB,c=s.normal,d=r.sub(r.add(l.positionImpulse,l.position,f),r.add(a.positionImpulse,r.sub(l.position,s.penetration,m),v),y),i.separation=r.dot(c,d));for(n=0;n<e.length;n++)i=e[n],i.isActive&&!i.isSensor&&(s=i.collision,a=s.parentA,l=s.parentB,c=s.normal,p=(i.separation-i.slop)*t,(a.isStatic||l.isStatic)&&(p*=2),a.isStatic||a.isSleeping||(u=o._positionDampen/a.totalContacts,a.positionImpulse.x+=c.x*p*u,a.positionImpulse.y+=c.y*p*u),l.isStatic||l.isSleeping||(u=o._positionDampen/l.totalContacts,l.positionImpulse.x-=c.x*p*u,l.positionImpulse.y-=c.y*p*u))},o.postSolvePosition=function(e){for(var t=0;t<e.length;t++){var n=e[t]
;if(n.totalContacts=0,0!==n.positionImpulse.x||0!==n.positionImpulse.y){for(var s=0;s<n.parts.length;s++){var l=n.parts[s];i.translate(l.vertices,n.positionImpulse),a.update(l.bounds,l.vertices,n.velocity),l.position.x+=n.positionImpulse.x,l.position.y+=n.positionImpulse.y}n.positionPrev.x+=n.positionImpulse.x,n.positionPrev.y+=n.positionImpulse.y,r.dot(n.positionImpulse,n.velocity)<0?(n.positionImpulse.x=0,n.positionImpulse.y=0):(n.positionImpulse.x*=o._positionWarming,n.positionImpulse.y*=o._positionWarming)}}},o.preSolveVelocity=function(e){var t,n,o,i,s,a,l,c,d,u,p,f,m,v,y=r._temp[0],g=r._temp[1];for(t=0;t<e.length;t++)if(o=e[t],o.isActive&&!o.isSensor)for(i=o.activeContacts,s=o.collision,a=s.parentA,l=s.parentB,c=s.normal,d=s.tangent,n=0;n<i.length;n++)u=i[n],p=u.vertex,f=u.normalImpulse,m=u.tangentImpulse,0===f&&0===m||(y.x=c.x*f+d.x*m,y.y=c.y*f+d.y*m,a.isStatic||a.isSleeping||(v=r.sub(p,a.position,g),a.positionPrev.x+=y.x*a.inverseMass,a.positionPrev.y+=y.y*a.inverseMass,
a.anglePrev+=r.cross(v,y)*a.inverseInertia),l.isStatic||l.isSleeping||(v=r.sub(p,l.position,g),l.positionPrev.x-=y.x*l.inverseMass,l.positionPrev.y-=y.y*l.inverseMass,l.anglePrev-=r.cross(v,y)*l.inverseInertia))},o.solveVelocity=function(e,t){for(var n=t*t,i=r._temp[0],a=r._temp[1],l=r._temp[2],c=r._temp[3],d=r._temp[4],u=r._temp[5],p=0;p<e.length;p++){var f=e[p];if(f.isActive&&!f.isSensor){var m=f.collision,v=m.parentA,y=m.parentB,g=m.normal,x=m.tangent,h=f.activeContacts,b=1/h.length;v.velocity.x=v.position.x-v.positionPrev.x,v.velocity.y=v.position.y-v.positionPrev.y,y.velocity.x=y.position.x-y.positionPrev.x,y.velocity.y=y.position.y-y.positionPrev.y,v.angularVelocity=v.angle-v.anglePrev,y.angularVelocity=y.angle-y.anglePrev;for(var w=0;w<h.length;w++){
var S=h[w],C=S.vertex,A=r.sub(C,v.position,a),P=r.sub(C,y.position,l),B=r.add(v.velocity,r.mult(r.perp(A),v.angularVelocity),c),M=r.add(y.velocity,r.mult(r.perp(P),y.angularVelocity),d),k=r.sub(B,M,u),I=r.dot(g,k),_=r.dot(x,k),T=Math.abs(_),R=s.sign(_),V=(1+f.restitution)*I,E=s.clamp(f.separation+I,0,1)*o._frictionNormalMultiplier,L=_,F=1/0;T>f.friction*f.frictionStatic*E*n&&(F=T,L=s.clamp(f.friction*R*n,-F,F));var O=r.cross(A,g),q=r.cross(P,g),W=b/(v.inverseMass+y.inverseMass+v.inverseInertia*O*O+y.inverseInertia*q*q);if(V*=W,L*=W,I<0&&I*I>o._restingThresh*n)S.normalImpulse=0;else{var D=S.normalImpulse;S.normalImpulse=Math.min(S.normalImpulse+V,0),V=S.normalImpulse-D}if(_*_>o._restingThreshTangent*n)S.tangentImpulse=0;else{var N=S.tangentImpulse;S.tangentImpulse=s.clamp(S.tangentImpulse+L,-F,F),L=S.tangentImpulse-N}i.x=g.x*V+x.x*L,i.y=g.y*V+x.y*L,v.isStatic||v.isSleeping||(v.positionPrev.x+=i.x*v.inverseMass,v.positionPrev.y+=i.y*v.inverseMass,
v.anglePrev+=r.cross(A,i)*v.inverseInertia),y.isStatic||y.isSleeping||(y.positionPrev.x-=i.x*y.inverseMass,y.positionPrev.y-=i.y*y.inverseMass,y.anglePrev-=r.cross(P,i)*y.inverseInertia)}}}}}()},{"../core/Common":14,"../geometry/Bounds":26,"../geometry/Vector":28,"../geometry/Vertices":29}],11:[function(e,t,n){var o={};t.exports=o;var i=e("../geometry/Vertices"),r=e("../geometry/Vector");!function(){o.collides=function(e,t,n){var s,a,l,c,d=!1;if(n){var u=e.parent,p=t.parent,f=u.speed*u.speed+u.angularSpeed*u.angularSpeed+p.speed*p.speed+p.angularSpeed*p.angularSpeed;d=n&&n.collided&&f<.2,c=n}else c={collided:!1,bodyA:e,bodyB:t};if(n&&d){var m=c.axisBody,v=m===e?t:e,y=[m.axes[n.axisNumber]];if(l=o._overlapAxes(m.vertices,v.vertices,y),c.reused=!0,l.overlap<=0)return c.collided=!1,c}else{if(s=o._overlapAxes(e.vertices,t.vertices,e.axes),s.overlap<=0)return c.collided=!1,c;if(a=o._overlapAxes(t.vertices,e.vertices,t.axes),a.overlap<=0)return c.collided=!1,c;s.overlap<a.overlap?(l=s,
c.axisBody=e):(l=a,c.axisBody=t),c.axisNumber=l.axisNumber}c.bodyA=e.id<t.id?e:t,c.bodyB=e.id<t.id?t:e,c.collided=!0,c.depth=l.overlap,c.parentA=c.bodyA.parent,c.parentB=c.bodyB.parent,e=c.bodyA,t=c.bodyB,r.dot(l.axis,r.sub(t.position,e.position))<0?c.normal={x:l.axis.x,y:l.axis.y}:c.normal={x:-l.axis.x,y:-l.axis.y},c.tangent=r.perp(c.normal),c.penetration=c.penetration||{},c.penetration.x=c.normal.x*c.depth,c.penetration.y=c.normal.y*c.depth;var g=o._findSupports(e,t,c.normal),x=[];if(i.contains(e.vertices,g[0])&&x.push(g[0]),i.contains(e.vertices,g[1])&&x.push(g[1]),x.length<2){var h=o._findSupports(t,e,r.neg(c.normal));i.contains(t.vertices,h[0])&&x.push(h[0]),x.length<2&&i.contains(t.vertices,h[1])&&x.push(h[1])}return x.length<1&&(x=[g[0]]),c.supports=x,c},o._overlapAxes=function(e,t,n){for(var i,s,a=r._temp[0],l=r._temp[1],c={overlap:Number.MAX_VALUE},d=0;d<n.length;d++){if(s=n[d],o._projectToAxis(a,e,s),o._projectToAxis(l,t,s),
(i=Math.min(a.max-l.min,l.max-a.min))<=0)return c.overlap=i,c;i<c.overlap&&(c.overlap=i,c.axis=s,c.axisNumber=d)}return c},o._projectToAxis=function(e,t,n){for(var o=r.dot(t[0],n),i=o,s=1;s<t.length;s+=1){var a=r.dot(t[s],n);a>i?i=a:a<o&&(o=a)}e.min=o,e.max=i},o._findSupports=function(e,t,n){for(var o,i,s,a,l=Number.MAX_VALUE,c=r._temp[0],d=t.vertices,u=e.position,p=0;p<d.length;p++)i=d[p],c.x=i.x-u.x,c.y=i.y-u.y,(o=-r.dot(n,c))<l&&(l=o,s=i);return i=d[s.index-1>=0?s.index-1:d.length-1],c.x=i.x-u.x,c.y=i.y-u.y,l=-r.dot(n,c),a=i,i=d[(s.index+1)%d.length],c.x=i.x-u.x,c.y=i.y-u.y,o=-r.dot(n,c),o<l&&(a=i),[s,a]}}()},{"../geometry/Vector":28,"../geometry/Vertices":29}],12:[function(e,t,n){var o={};t.exports=o;var i=e("../geometry/Vertices"),r=e("../geometry/Vector"),s=e("../core/Sleeping"),a=e("../geometry/Bounds"),l=e("../geometry/Axes"),c=e("../core/Common");!function(){o._warming=.4,o._torqueDampen=1,o._minLength=1e-6,o.create=function(e){var t=e;t.bodyA&&!t.pointA&&(t.pointA={x:0,y:0}),
t.bodyB&&!t.pointB&&(t.pointB={x:0,y:0});var n=t.bodyA?r.add(t.bodyA.position,t.pointA):t.pointA,o=t.bodyB?r.add(t.bodyB.position,t.pointB):t.pointB,i=r.magnitude(r.sub(n,o));t.length=void 0!==t.length?t.length:i,t.id=t.id||c.nextId(),t.label=t.label||"Constraint",t.type="constraint",t.stiffness=t.stiffness||(t.length>0?1:.7),t.damping=t.damping||0,t.angularStiffness=t.angularStiffness||0,t.angleA=t.bodyA?t.bodyA.angle:t.angleA,t.angleB=t.bodyB?t.bodyB.angle:t.angleB,t.plugin={};var s={visible:!0,lineWidth:2,strokeStyle:"#ffffff",type:"line",anchors:!0};return 0===t.length&&t.stiffness>.1?(s.type="pin",s.anchors=!1):t.stiffness<.9&&(s.type="spring"),t.render=c.extend(s,t.render),t},o.preSolveAll=function(e){for(var t=0;t<e.length;t+=1){var n=e[t],o=n.constraintImpulse;n.isStatic||0===o.x&&0===o.y&&0===o.angle||(n.position.x+=o.x,n.position.y+=o.y,n.angle+=o.angle)}},o.solveAll=function(e,t){for(var n=0;n<e.length;n+=1){
var i=e[n],r=!i.bodyA||i.bodyA&&i.bodyA.isStatic,s=!i.bodyB||i.bodyB&&i.bodyB.isStatic;(r||s)&&o.solve(e[n],t)}for(n=0;n<e.length;n+=1)i=e[n],r=!i.bodyA||i.bodyA&&i.bodyA.isStatic,s=!i.bodyB||i.bodyB&&i.bodyB.isStatic,r||s||o.solve(e[n],t)},o.solve=function(e,t){var n=e.bodyA,i=e.bodyB,s=e.pointA,a=e.pointB;if(n||i){n&&!n.isStatic&&(r.rotate(s,n.angle-e.angleA,s),e.angleA=n.angle),i&&!i.isStatic&&(r.rotate(a,i.angle-e.angleB,a),e.angleB=i.angle);var l=s,c=a;if(n&&(l=r.add(n.position,s)),i&&(c=r.add(i.position,a)),l&&c){var d=r.sub(l,c),u=r.magnitude(d);u<o._minLength&&(u=o._minLength);var p,f,m,v,y,g=(u-e.length)/u,x=e.stiffness<1?e.stiffness*t:e.stiffness,h=r.mult(d,g*x),b=(n?n.inverseMass:0)+(i?i.inverseMass:0),w=(n?n.inverseInertia:0)+(i?i.inverseInertia:0),S=b+w;if(e.damping){var C=r.create();m=r.div(d,u),y=r.sub(i&&r.sub(i.position,i.positionPrev)||C,n&&r.sub(n.position,n.positionPrev)||C),v=r.dot(m,y)}n&&!n.isStatic&&(f=n.inverseMass/b,n.constraintImpulse.x-=h.x*f,
n.constraintImpulse.y-=h.y*f,n.position.x-=h.x*f,n.position.y-=h.y*f,e.damping&&(n.positionPrev.x-=e.damping*m.x*v*f,n.positionPrev.y-=e.damping*m.y*v*f),p=r.cross(s,h)/S*o._torqueDampen*n.inverseInertia*(1-e.angularStiffness),n.constraintImpulse.angle-=p,n.angle-=p),i&&!i.isStatic&&(f=i.inverseMass/b,i.constraintImpulse.x+=h.x*f,i.constraintImpulse.y+=h.y*f,i.position.x+=h.x*f,i.position.y+=h.y*f,e.damping&&(i.positionPrev.x+=e.damping*m.x*v*f,i.positionPrev.y+=e.damping*m.y*v*f),p=r.cross(a,h)/S*o._torqueDampen*i.inverseInertia*(1-e.angularStiffness),i.constraintImpulse.angle+=p,i.angle+=p)}}},o.postSolveAll=function(e){for(var t=0;t<e.length;t++){var n=e[t],c=n.constraintImpulse;if(!(n.isStatic||0===c.x&&0===c.y&&0===c.angle)){s.set(n,!1);for(var d=0;d<n.parts.length;d++){var u=n.parts[d];i.translate(u.vertices,c),d>0&&(u.position.x+=c.x,u.position.y+=c.y),0!==c.angle&&(i.rotate(u.vertices,c.angle,n.position),l.rotate(u.axes,c.angle),
d>0&&r.rotateAbout(u.position,c.angle,n.position,u.position)),a.update(u.bounds,u.vertices,n.velocity)}c.angle*=o._warming,c.x*=o._warming,c.y*=o._warming}}}}()},{"../core/Common":14,"../core/Sleeping":22,"../geometry/Axes":25,"../geometry/Bounds":26,"../geometry/Vector":28,"../geometry/Vertices":29}],13:[function(e,t,n){var o={};t.exports=o;var i=e("../geometry/Vertices"),r=e("../core/Sleeping"),s=e("../core/Mouse"),a=e("../core/Events"),l=e("../collision/Detector"),c=e("./Constraint"),d=e("../body/Composite"),u=e("../core/Common"),p=e("../geometry/Bounds");!function(){o.create=function(e,t){var n=(e?e.mouse:null)||(t?t.mouse:null);n||(e&&e.render&&e.render.canvas?n=s.create(e.render.canvas):t&&t.element?n=s.create(t.element):(n=s.create(),u.warn("MouseConstraint.create: options.mouse was undefined, options.element was undefined, may not function as expected")));var i=c.create({label:"Mouse Constraint",pointA:n.position,pointB:{x:0,y:0},length:.01,stiffness:.1,angularStiffness:1,
render:{strokeStyle:"#90EE90",lineWidth:3}}),r={type:"mouseConstraint",mouse:n,element:null,body:null,constraint:i,collisionFilter:{category:1,mask:4294967295,group:0}},l=u.extend(r,t);return a.on(e,"beforeUpdate",function(){var t=d.allBodies(e.world);o.update(l,t),o._triggerEvents(l)}),l},o.update=function(e,t){var n=e.mouse,o=e.constraint,s=e.body;if(0===n.button){if(o.bodyB)r.set(o.bodyB,!1),o.pointA=n.position;else for(var c=0;c<t.length;c++)if(s=t[c],p.contains(s.bounds,n.position)&&l.canCollide(s.collisionFilter,e.collisionFilter))for(var d=s.parts.length>1?1:0;d<s.parts.length;d++){var u=s.parts[d];if(i.contains(u.vertices,n.position)){o.pointA=n.position,o.bodyB=e.body=s,o.pointB={x:n.position.x-s.position.x,y:n.position.y-s.position.y},o.angleB=s.angle,r.set(s,!1),a.trigger(e,"startdrag",{mouse:n,body:s});break}}}else o.bodyB=e.body=null,o.pointB=null,s&&a.trigger(e,"enddrag",{mouse:n,body:s})},o._triggerEvents=function(e){var t=e.mouse,n=t.sourceEvents
;n.mousemove&&a.trigger(e,"mousemove",{mouse:t}),n.mousedown&&a.trigger(e,"mousedown",{mouse:t}),n.mouseup&&a.trigger(e,"mouseup",{mouse:t}),s.clearSourceEvents(t)}}()},{"../body/Composite":2,"../collision/Detector":5,"../core/Common":14,"../core/Events":16,"../core/Mouse":19,"../core/Sleeping":22,"../geometry/Bounds":26,"../geometry/Vertices":29,"./Constraint":12}],14:[function(e,t,n){(function(n){var o={};t.exports=o,function(){o._nextId=0,o._seed=0,o._nowStartTime=+new Date,o.extend=function(e,t){var n,i;"boolean"==typeof t?(n=2,i=t):(n=1,i=!0);for(var r=n;r<arguments.length;r++){var s=arguments[r];if(s)for(var a in s)i&&s[a]&&s[a].constructor===Object?e[a]&&e[a].constructor!==Object?e[a]=s[a]:(e[a]=e[a]||{},o.extend(e[a],i,s[a])):e[a]=s[a]}return e},o.clone=function(e,t){return o.extend({},t,e)},o.keys=function(e){if(Object.keys)return Object.keys(e);var t=[];for(var n in e)t.push(n);return t},o.values=function(e){var t=[];if(Object.keys){
for(var n=Object.keys(e),o=0;o<n.length;o++)t.push(e[n[o]]);return t}for(var i in e)t.push(e[i]);return t},o.get=function(e,t,n,o){t=t.split(".").slice(n,o);for(var i=0;i<t.length;i+=1)e=e[t[i]];return e},o.set=function(e,t,n,i,r){var s=t.split(".").slice(i,r);return o.get(e,t,0,-1)[s[s.length-1]]=n,n},o.shuffle=function(e){for(var t=e.length-1;t>0;t--){var n=Math.floor(o.random()*(t+1)),i=e[t];e[t]=e[n],e[n]=i}return e},o.choose=function(e){return e[Math.floor(o.random()*e.length)]},o.isElement=function(e){return"undefined"!=typeof HTMLElement?e instanceof HTMLElement:!!(e&&e.nodeType&&e.nodeName)},o.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)},o.isFunction=function(e){return"function"==typeof e},o.isPlainObject=function(e){return"object"==typeof e&&e.constructor===Object},o.isString=function(e){return"[object String]"===toString.call(e)},o.clamp=function(e,t,n){return e<t?t:e>n?n:e},o.sign=function(e){return e<0?-1:1},o.now=function(){
if(window.performance){if(window.performance.now)return window.performance.now();if(window.performance.webkitNow)return window.performance.webkitNow()}return new Date-o._nowStartTime},o.random=function(e,n){return e=void 0!==e?e:0,n=void 0!==n?n:1,e+t()*(n-e)};var t=function(){return o._seed=(9301*o._seed+49297)%233280,o._seed/233280};o.colorToNumber=function(e){return e=e.replace("#",""),3==e.length&&(e=e.charAt(0)+e.charAt(0)+e.charAt(1)+e.charAt(1)+e.charAt(2)+e.charAt(2)),parseInt(e,16)},o.logLevel=1,o.log=function(){console&&o.logLevel>0&&o.logLevel<=3&&console.log.apply(console,["matter-js:"].concat(Array.prototype.slice.call(arguments)))},o.info=function(){console&&o.logLevel>0&&o.logLevel<=2&&console.info.apply(console,["matter-js:"].concat(Array.prototype.slice.call(arguments)))},o.warn=function(){console&&o.logLevel>0&&o.logLevel<=3&&console.warn.apply(console,["matter-js:"].concat(Array.prototype.slice.call(arguments)))},o.nextId=function(){return o._nextId++},
o.indexOf=function(e,t){if(e.indexOf)return e.indexOf(t);for(var n=0;n<e.length;n++)if(e[n]===t)return n;return-1},o.map=function(e,t){if(e.map)return e.map(t);for(var n=[],o=0;o<e.length;o+=1)n.push(t(e[o]));return n},o.topologicalSort=function(e){var t=[],n=[],i=[];for(var r in e)n[r]||i[r]||o._topologicalSort(r,n,i,e,t);return t},o._topologicalSort=function(e,t,n,i,r){var s=i[e]||[];n[e]=!0;for(var a=0;a<s.length;a+=1){var l=s[a];n[l]||(t[l]||o._topologicalSort(l,t,n,i,r))}n[e]=!1,t[e]=!0,r.push(e)},o.chain=function(){for(var e=[],t=0;t<arguments.length;t+=1){var n=arguments[t];n._chained?e.push.apply(e,n._chained):e.push(n)}var o=function(){for(var t,n=new Array(arguments.length),o=0,i=arguments.length;o<i;o++)n[o]=arguments[o];for(o=0;o<e.length;o+=1){var r=e[o].apply(t,n);void 0!==r&&(t=r)}return t};return o._chained=e,o},o.chainPathBefore=function(e,t,n){return o.set(e,t,o.chain(n,o.get(e,t)))},o.chainPathAfter=function(e,t,n){return o.set(e,t,o.chain(o.get(e,t),n))},
o._requireGlobal=function(t,o){return("undefined"!=typeof window?window[t]:void 0!==n?n[t]:null)||e(o)}}()}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],15:[function(e,t,n){var o={};t.exports=o;var i=e("../body/World"),r=e("./Sleeping"),s=e("../collision/Resolver"),a=e("../render/Render"),l=e("../collision/Pairs"),c=(e("./Metrics"),e("../collision/Grid")),d=e("./Events"),u=e("../body/Composite"),p=e("../constraint/Constraint"),f=e("./Common"),m=e("../body/Body");!function(){o.create=function(e,t){t=f.isElement(e)?t:e,e=f.isElement(e)?e:null,t=t||{},(e||t.render)&&f.warn("Engine.create: engine.render is deprecated (see docs)");var n={positionIterations:6,velocityIterations:4,constraintIterations:2,enableSleeping:!1,events:[],plugin:{},timing:{timestamp:0,timeScale:1},broadphase:{controller:c}},o=f.extend(n,t);if(e||o.render){var r={element:e,controller:a};o.render=f.extend(r,o.render)}
return o.render&&o.render.controller&&(o.render=o.render.controller.create(o.render)),o.render&&(o.render.engine=o),o.world=t.world||i.create(o.world),o.pairs=l.create(),o.broadphase=o.broadphase.controller.create(o.broadphase),o.metrics=o.metrics||{extended:!1},o},o.update=function(e,t,n){t=t||1e3/60,n=n||1;var i,a=e.world,c=e.timing,f=e.broadphase,m=[];c.timestamp+=t*c.timeScale;var v={timestamp:c.timestamp};d.trigger(e,"beforeUpdate",v);var y=u.allBodies(a),g=u.allConstraints(a);for(e.enableSleeping&&r.update(y,c.timeScale),o._bodiesApplyGravity(y,a.gravity),o._bodiesUpdate(y,t,c.timeScale,n,a.bounds),p.preSolveAll(y),i=0;i<e.constraintIterations;i++)p.solveAll(g,c.timeScale);p.postSolveAll(y),f.controller?(a.isModified&&f.controller.clear(f),f.controller.update(f,y,e,a.isModified),m=f.pairsList):m=y,a.isModified&&u.setModified(a,!1,!1,!0);var x=f.detector(m,e),h=e.pairs,b=c.timestamp;for(l.update(h,x,b),l.removeOld(h,b),e.enableSleeping&&r.afterCollisions(h.list,c.timeScale),
h.collisionStart.length>0&&d.trigger(e,"collisionStart",{pairs:h.collisionStart}),s.preSolvePosition(h.list),i=0;i<e.positionIterations;i++)s.solvePosition(h.list,c.timeScale);for(s.postSolvePosition(y),p.preSolveAll(y),i=0;i<e.constraintIterations;i++)p.solveAll(g,c.timeScale);for(p.postSolveAll(y),s.preSolveVelocity(h.list),i=0;i<e.velocityIterations;i++)s.solveVelocity(h.list,c.timeScale);return h.collisionActive.length>0&&d.trigger(e,"collisionActive",{pairs:h.collisionActive}),h.collisionEnd.length>0&&d.trigger(e,"collisionEnd",{pairs:h.collisionEnd}),o._bodiesClearForces(y),d.trigger(e,"afterUpdate",v),e},o.merge=function(e,t){if(f.extend(e,t),t.world){e.world=t.world,o.clear(e);for(var n=u.allBodies(e.world),i=0;i<n.length;i++){var s=n[i];r.set(s,!1),s.id=f.nextId()}}},o.clear=function(e){var t=e.world;l.clear(e.pairs);var n=e.broadphase;if(n.controller){var o=u.allBodies(t);n.controller.clear(n),n.controller.update(n,o,e,!0)}},o._bodiesClearForces=function(e){
for(var t=0;t<e.length;t++){var n=e[t];n.force.x=0,n.force.y=0,n.torque=0}},o._bodiesApplyGravity=function(e,t){var n=void 0!==t.scale?t.scale:.001;if((0!==t.x||0!==t.y)&&0!==n)for(var o=0;o<e.length;o++){var i=e[o];i.isStatic||i.isSleeping||(i.force.y+=i.mass*t.y*n,i.force.x+=i.mass*t.x*n)}},o._bodiesUpdate=function(e,t,n,o,i){for(var r=0;r<e.length;r++){var s=e[r];s.isStatic||s.isSleeping||m.update(s,t,n,o)}}}()},{"../body/Body":1,"../body/Composite":2,"../body/World":3,"../collision/Grid":6,"../collision/Pairs":8,"../collision/Resolver":10,"../constraint/Constraint":12,"../render/Render":31,"./Common":14,"./Events":16,"./Metrics":18,"./Sleeping":22}],16:[function(e,t,n){var o={};t.exports=o;var i=e("./Common");!function(){o.on=function(e,t,n){for(var o,i=t.split(" "),r=0;r<i.length;r++)o=i[r],e.events=e.events||{},e.events[o]=e.events[o]||[],e.events[o].push(n);return n},o.off=function(e,t,n){if(!t)return void(e.events={});"function"==typeof t&&(n=t,t=i.keys(e.events).join(" "))
;for(var o=t.split(" "),r=0;r<o.length;r++){var s=e.events[o[r]],a=[];if(n&&s)for(var l=0;l<s.length;l++)s[l]!==n&&a.push(s[l]);e.events[o[r]]=a}},o.trigger=function(e,t,n){var o,r,s,a;if(e.events){n||(n={}),o=t.split(" ");for(var l=0;l<o.length;l++)if(r=o[l],s=e.events[r]){a=i.clone(n,!1),a.name=r,a.source=e;for(var c=0;c<s.length;c++)s[c].apply(e,[a])}}}}()},{"./Common":14}],17:[function(e,t,n){var o={};t.exports=o;var i=e("./Plugin"),r=e("./Common");!function(){o.name="matter-js",o.version="0.14.2",o.uses=[],o.used=[],o.use=function(){i.use(o,Array.prototype.slice.call(arguments))},o.before=function(e,t){return e=e.replace(/^Matter./,""),r.chainPathBefore(o,e,t)},o.after=function(e,t){return e=e.replace(/^Matter./,""),r.chainPathAfter(o,e,t)}}()},{"./Common":14,"./Plugin":20}],18:[function(e,t,n){},{"../body/Composite":2,"./Common":14}],19:[function(e,t,n){var o={};t.exports=o;var i=e("../core/Common");!function(){o.create=function(e){var t={}
;return e||i.log("Mouse.create: element was undefined, defaulting to document.body","warn"),t.element=e||document.body,t.absolute={x:0,y:0},t.position={x:0,y:0},t.mousedownPosition={x:0,y:0},t.mouseupPosition={x:0,y:0},t.offset={x:0,y:0},t.scale={x:1,y:1},t.wheelDelta=0,t.button=-1,t.pixelRatio=t.element.getAttribute("data-pixel-ratio")||1,t.sourceEvents={mousemove:null,mousedown:null,mouseup:null,mousewheel:null},t.mousemove=function(e){var n=o._getRelativeMousePosition(e,t.element,t.pixelRatio);e.changedTouches&&(t.button=0,e.preventDefault()),t.absolute.x=n.x,t.absolute.y=n.y,t.position.x=t.absolute.x*t.scale.x+t.offset.x,t.position.y=t.absolute.y*t.scale.y+t.offset.y,t.sourceEvents.mousemove=e},t.mousedown=function(e){var n=o._getRelativeMousePosition(e,t.element,t.pixelRatio);e.changedTouches?(t.button=0,e.preventDefault()):t.button=e.button,t.absolute.x=n.x,t.absolute.y=n.y,t.position.x=t.absolute.x*t.scale.x+t.offset.x,t.position.y=t.absolute.y*t.scale.y+t.offset.y,
t.mousedownPosition.x=t.position.x,t.mousedownPosition.y=t.position.y,t.sourceEvents.mousedown=e},t.mouseup=function(e){var n=o._getRelativeMousePosition(e,t.element,t.pixelRatio);e.changedTouches&&e.preventDefault(),t.button=-1,t.absolute.x=n.x,t.absolute.y=n.y,t.position.x=t.absolute.x*t.scale.x+t.offset.x,t.position.y=t.absolute.y*t.scale.y+t.offset.y,t.mouseupPosition.x=t.position.x,t.mouseupPosition.y=t.position.y,t.sourceEvents.mouseup=e},t.mousewheel=function(e){t.wheelDelta=Math.max(-1,Math.min(1,e.wheelDelta||-e.detail)),e.preventDefault()},o.setElement(t,t.element),t},o.setElement=function(e,t){e.element=t,t.addEventListener("mousemove",e.mousemove),t.addEventListener("mousedown",e.mousedown),t.addEventListener("mouseup",e.mouseup),t.addEventListener("mousewheel",e.mousewheel),t.addEventListener("DOMMouseScroll",e.mousewheel),t.addEventListener("touchmove",e.mousemove),t.addEventListener("touchstart",e.mousedown),t.addEventListener("touchend",e.mouseup)},
o.clearSourceEvents=function(e){e.sourceEvents.mousemove=null,e.sourceEvents.mousedown=null,e.sourceEvents.mouseup=null,e.sourceEvents.mousewheel=null,e.wheelDelta=0},o.setOffset=function(e,t){e.offset.x=t.x,e.offset.y=t.y,e.position.x=e.absolute.x*e.scale.x+e.offset.x,e.position.y=e.absolute.y*e.scale.y+e.offset.y},o.setScale=function(e,t){e.scale.x=t.x,e.scale.y=t.y,e.position.x=e.absolute.x*e.scale.x+e.offset.x,e.position.y=e.absolute.y*e.scale.y+e.offset.y},o._getRelativeMousePosition=function(e,t,n){var o,i,r=t.getBoundingClientRect(),s=document.documentElement||document.body.parentNode||document.body,a=void 0!==window.pageXOffset?window.pageXOffset:s.scrollLeft,l=void 0!==window.pageYOffset?window.pageYOffset:s.scrollTop,c=e.changedTouches;return c?(o=c[0].pageX-r.left-a,i=c[0].pageY-r.top-l):(o=e.pageX-r.left-a,i=e.pageY-r.top-l),{x:o/(t.clientWidth/(t.width||t.clientWidth)*n),y:i/(t.clientHeight/(t.height||t.clientHeight)*n)}}}()},{"../core/Common":14}],20:[function(e,t,n){
var o={};t.exports=o;var i=e("./Common");!function(){o._registry={},o.register=function(e){if(o.isPlugin(e)||i.warn("Plugin.register:",o.toString(e),"does not implement all required fields."),e.name in o._registry){var t=o._registry[e.name],n=o.versionParse(e.version).number,r=o.versionParse(t.version).number;n>r?(i.warn("Plugin.register:",o.toString(t),"was upgraded to",o.toString(e)),o._registry[e.name]=e):n<r?i.warn("Plugin.register:",o.toString(t),"can not be downgraded to",o.toString(e)):e!==t&&i.warn("Plugin.register:",o.toString(e),"is already registered to different plugin object")}else o._registry[e.name]=e;return e},o.resolve=function(e){return o._registry[o.dependencyParse(e).name]},o.toString=function(e){return"string"==typeof e?e:(e.name||"anonymous")+"@"+(e.version||e.range||"0.0.0")},o.isPlugin=function(e){return e&&e.name&&e.version&&e.install},o.isUsed=function(e,t){return e.used.indexOf(t)>-1},o.isFor=function(e,t){var n=e.for&&o.dependencyParse(e.for)
;return!e.for||t.name===n.name&&o.versionSatisfies(t.version,n.range)},o.use=function(e,t){if(e.uses=(e.uses||[]).concat(t||[]),0===e.uses.length)return void i.warn("Plugin.use:",o.toString(e),"does not specify any dependencies to install.");for(var n=o.dependencies(e),r=i.topologicalSort(n),s=[],a=0;a<r.length;a+=1)if(r[a]!==e.name){var l=o.resolve(r[a]);l?o.isUsed(e,l.name)||(o.isFor(l,e)||(i.warn("Plugin.use:",o.toString(l),"is for",l.for,"but installed on",o.toString(e)+"."),l._warned=!0),l.install?l.install(e):(i.warn("Plugin.use:",o.toString(l),"does not specify an install function."),l._warned=!0),l._warned?(s.push("🔶 "+o.toString(l)),delete l._warned):s.push("✅ "+o.toString(l)),e.used.push(l.name)):s.push("❌ "+r[a])}s.length>0&&i.info(s.join(" "))},o.dependencies=function(e,t){var n=o.dependencyParse(e),r=n.name;if(t=t||{},!(r in t)){e=o.resolve(e)||e,t[r]=i.map(e.uses||[],function(t){o.isPlugin(t)&&o.register(t);var r=o.dependencyParse(t),s=o.resolve(t)
;return s&&!o.versionSatisfies(s.version,r.range)?(i.warn("Plugin.dependencies:",o.toString(s),"does not satisfy",o.toString(r),"used by",o.toString(n)+"."),s._warned=!0,e._warned=!0):s||(i.warn("Plugin.dependencies:",o.toString(t),"used by",o.toString(n),"could not be resolved."),e._warned=!0),r.name});for(var s=0;s<t[r].length;s+=1)o.dependencies(t[r][s],t);return t}},o.dependencyParse=function(e){if(i.isString(e)){return/^[\w-]+(@(\*|[\^~]?\d+\.\d+\.\d+(-[0-9A-Za-z-]+)?))?$/.test(e)||i.warn("Plugin.dependencyParse:",e,"is not a valid dependency string."),{name:e.split("@")[0],range:e.split("@")[1]||"*"}}return{name:e.name,range:e.range||e.version}},o.versionParse=function(e){/^\*|[\^~]?\d+\.\d+\.\d+(-[0-9A-Za-z-]+)?$/.test(e)||i.warn("Plugin.versionParse:",e,"is not a valid version or range.");var t=e.split("-");e=t[0];var n=isNaN(Number(e[0])),o=n?e.substr(1):e,r=i.map(o.split("."),function(e){return Number(e)});return{isRange:n,version:o,range:e,operator:n?e[0]:"",parts:r,
prerelease:t[1],number:1e8*r[0]+1e4*r[1]+r[2]}},o.versionSatisfies=function(e,t){t=t||"*";var n=o.versionParse(t),i=n.parts,r=o.versionParse(e),s=r.parts;if(n.isRange){if("*"===n.operator||"*"===e)return!0;if("~"===n.operator)return s[0]===i[0]&&s[1]===i[1]&&s[2]>=i[2];if("^"===n.operator)return i[0]>0?s[0]===i[0]&&r.number>=n.number:i[1]>0?s[1]===i[1]&&s[2]>=i[2]:s[2]===i[2]}return e===t||"*"===e}}()},{"./Common":14}],21:[function(e,t,n){var o={};t.exports=o;var i=e("./Events"),r=e("./Engine"),s=e("./Common");!function(){var e,t;if("undefined"!=typeof window&&(e=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame,t=window.cancelAnimationFrame||window.mozCancelAnimationFrame||window.webkitCancelAnimationFrame||window.msCancelAnimationFrame),!e){var n;e=function(e){n=setTimeout(function(){e(s.now())},1e3/60)},t=function(){clearTimeout(n)}}o.create=function(e){var t={fps:60,correction:1,deltaSampleSize:60,
counterTimestamp:0,frameCounter:0,deltaHistory:[],timePrev:null,timeScalePrev:1,frameRequestId:null,isFixed:!1,enabled:!0},n=s.extend(t,e);return n.delta=n.delta||1e3/n.fps,n.deltaMin=n.deltaMin||1e3/n.fps,n.deltaMax=n.deltaMax||1e3/(.5*n.fps),n.fps=1e3/n.delta,n},o.run=function(t,n){return void 0!==t.positionIterations&&(n=t,t=o.create()),function i(r){t.frameRequestId=e(i),r&&t.enabled&&o.tick(t,n,r)}(),t},o.tick=function(e,t,n){var o,s=t.timing,a=1,l={timestamp:s.timestamp};i.trigger(e,"beforeTick",l),i.trigger(t,"beforeTick",l),e.isFixed?o=e.delta:(o=n-e.timePrev||e.delta,e.timePrev=n,e.deltaHistory.push(o),e.deltaHistory=e.deltaHistory.slice(-e.deltaSampleSize),o=Math.min.apply(null,e.deltaHistory),o=o<e.deltaMin?e.deltaMin:o,o=o>e.deltaMax?e.deltaMax:o,a=o/e.delta,e.delta=o),0!==e.timeScalePrev&&(a*=s.timeScale/e.timeScalePrev),0===s.timeScale&&(a=0),e.timeScalePrev=s.timeScale,e.correction=a,e.frameCounter+=1,
n-e.counterTimestamp>=1e3&&(e.fps=e.frameCounter*((n-e.counterTimestamp)/1e3),e.counterTimestamp=n,e.frameCounter=0),i.trigger(e,"tick",l),i.trigger(t,"tick",l),t.world.isModified&&t.render&&t.render.controller&&t.render.controller.clear&&t.render.controller.clear(t.render),i.trigger(e,"beforeUpdate",l),r.update(t,o,a),i.trigger(e,"afterUpdate",l),t.render&&t.render.controller&&(i.trigger(e,"beforeRender",l),i.trigger(t,"beforeRender",l),t.render.controller.world(t.render),i.trigger(e,"afterRender",l),i.trigger(t,"afterRender",l)),i.trigger(e,"afterTick",l),i.trigger(t,"afterTick",l)},o.stop=function(e){t(e.frameRequestId)},o.start=function(e,t){o.run(e,t)}}()},{"./Common":14,"./Engine":15,"./Events":16}],22:[function(e,t,n){var o={};t.exports=o;var i=e("./Events");!function(){o._motionWakeThreshold=.18,o._motionSleepThreshold=.08,o._minBias=.9,o.update=function(e,t){for(var n=t*t*t,i=0;i<e.length;i++){var r=e[i],s=r.speed*r.speed+r.angularSpeed*r.angularSpeed
;if(0===r.force.x&&0===r.force.y){var a=Math.min(r.motion,s),l=Math.max(r.motion,s);r.motion=o._minBias*a+(1-o._minBias)*l,r.sleepThreshold>0&&r.motion<o._motionSleepThreshold*n?(r.sleepCounter+=1,r.sleepCounter>=r.sleepThreshold&&o.set(r,!0)):r.sleepCounter>0&&(r.sleepCounter-=1)}else o.set(r,!1)}},o.afterCollisions=function(e,t){for(var n=t*t*t,i=0;i<e.length;i++){var r=e[i];if(r.isActive){var s=r.collision,a=s.bodyA.parent,l=s.bodyB.parent;if(!(a.isSleeping&&l.isSleeping||a.isStatic||l.isStatic)&&(a.isSleeping||l.isSleeping)){var c=a.isSleeping&&!a.isStatic?a:l,d=c===a?l:a;!c.isStatic&&d.motion>o._motionWakeThreshold*n&&o.set(c,!1)}}}},o.set=function(e,t){var n=e.isSleeping;t?(e.isSleeping=!0,e.sleepCounter=e.sleepThreshold,e.positionImpulse.x=0,e.positionImpulse.y=0,e.positionPrev.x=e.position.x,e.positionPrev.y=e.position.y,e.anglePrev=e.angle,e.speed=0,e.angularSpeed=0,e.motion=0,n||i.trigger(e,"sleepStart")):(e.isSleeping=!1,e.sleepCounter=0,n&&i.trigger(e,"sleepEnd"))}}()},{
"./Events":16}],23:[function(e,t,n){var o={};t.exports=o;var i,r=e("../geometry/Vertices"),s=e("../core/Common"),a=e("../body/Body"),l=e("../geometry/Bounds"),c=e("../geometry/Vector");!function(){o.rectangle=function(e,t,n,o,i){i=i||{};var l={label:"Rectangle Body",position:{x:e,y:t},vertices:r.fromPath("L 0 0 L "+n+" 0 L "+n+" "+o+" L 0 "+o)};if(i.chamfer){var c=i.chamfer;l.vertices=r.chamfer(l.vertices,c.radius,c.quality,c.qualityMin,c.qualityMax),delete i.chamfer}return a.create(s.extend({},l,i))},o.trapezoid=function(e,t,n,o,i,l){l=l||{},i*=.5;var c,d=(1-2*i)*n,u=n*i,p=u+d,f=p+u;c=i<.5?"L 0 0 L "+u+" "+-o+" L "+p+" "+-o+" L "+f+" 0":"L 0 0 L "+p+" "+-o+" L "+f+" 0";var m={label:"Trapezoid Body",position:{x:e,y:t},vertices:r.fromPath(c)};if(l.chamfer){var v=l.chamfer;m.vertices=r.chamfer(m.vertices,v.radius,v.quality,v.qualityMin,v.qualityMax),delete l.chamfer}return a.create(s.extend({},m,l))},o.circle=function(e,t,n,i,r){i=i||{};var a={label:"Circle Body",circleRadius:n};r=r||25
;var l=Math.ceil(Math.max(10,Math.min(r,n)));return l%2==1&&(l+=1),o.polygon(e,t,l,n,s.extend({},a,i))},o.polygon=function(e,t,n,i,l){if(l=l||{},n<3)return o.circle(e,t,i,l);for(var c=2*Math.PI/n,d="",u=.5*c,p=0;p<n;p+=1){var f=u+p*c,m=Math.cos(f)*i,v=Math.sin(f)*i;d+="L "+m.toFixed(3)+" "+v.toFixed(3)+" "}var y={label:"Polygon Body",position:{x:e,y:t},vertices:r.fromPath(d)};if(l.chamfer){var g=l.chamfer;y.vertices=r.chamfer(y.vertices,g.radius,g.quality,g.qualityMin,g.qualityMax),delete l.chamfer}return a.create(s.extend({},y,l))},o.fromVertices=function(e,t,n,o,d,u,p){i||(i=s._requireGlobal("decomp","poly-decomp"));var f,m,v,y,g,x,h,b,w;for(o=o||{},m=[],d=void 0!==d&&d,u=void 0!==u?u:.01,p=void 0!==p?p:10,i||s.warn("Bodies.fromVertices: poly-decomp.js required. Could not decompose vertices. Fallback to convex hull."),s.isArray(n[0])||(n=[n]),b=0;b<n.length;b+=1)if(y=n[b],(v=r.isConvex(y))||!i)y=v?r.clockwiseSort(y):r.hull(y),m.push({position:{x:e,y:t},vertices:y});else{
var S=y.map(function(e){return[e.x,e.y]});i.makeCCW(S),!1!==u&&i.removeCollinearPoints(S,u);var C=i.quickDecomp(S);for(g=0;g<C.length;g++){var A=C[g],P=A.map(function(e){return{x:e[0],y:e[1]}});p>0&&r.area(P)<p||m.push({position:r.centre(P),vertices:P})}}for(g=0;g<m.length;g++)m[g]=a.create(s.extend(m[g],o));if(d){for(g=0;g<m.length;g++){var B=m[g];for(x=g+1;x<m.length;x++){var M=m[x];if(l.overlaps(B.bounds,M.bounds)){var k=B.vertices,I=M.vertices;for(h=0;h<B.vertices.length;h++)for(w=0;w<M.vertices.length;w++){var _=c.magnitudeSquared(c.sub(k[(h+1)%k.length],I[w])),T=c.magnitudeSquared(c.sub(k[h],I[(w+1)%I.length]));_<5&&T<5&&(k[h].isInternal=!0,I[w].isInternal=!0)}}}}}return m.length>1?(f=a.create(s.extend({parts:m.slice(0)},o)),a.setPosition(f,{x:e,y:t}),f):m[0]}}()},{"../body/Body":1,"../core/Common":14,"../geometry/Bounds":26,"../geometry/Vector":28,"../geometry/Vertices":29}],24:[function(e,t,n){var o={};t.exports=o
;var i=e("../body/Composite"),r=e("../constraint/Constraint"),s=e("../core/Common"),a=e("../body/Body"),l=e("./Bodies");!function(){o.stack=function(e,t,n,o,r,s,l){for(var c,d=i.create({label:"Stack"}),u=e,p=t,f=0,m=0;m<o;m++){for(var v=0,y=0;y<n;y++){var g=l(u,p,y,m,c,f);if(g){var x=g.bounds.max.y-g.bounds.min.y,h=g.bounds.max.x-g.bounds.min.x;x>v&&(v=x),a.translate(g,{x:.5*h,y:.5*x}),u=g.bounds.max.x+r,i.addBody(d,g),c=g,f+=1}else u+=r}p+=v+s,u=e}return d},o.chain=function(e,t,n,o,a,l){for(var c=e.bodies,d=1;d<c.length;d++){var u=c[d-1],p=c[d],f=u.bounds.max.y-u.bounds.min.y,m=u.bounds.max.x-u.bounds.min.x,v=p.bounds.max.y-p.bounds.min.y,y=p.bounds.max.x-p.bounds.min.x,g={bodyA:u,pointA:{x:m*t,y:f*n},bodyB:p,pointB:{x:y*o,y:v*a}},x=s.extend(g,l);i.addConstraint(e,r.create(x))}return e.label+=" Chain",e},o.mesh=function(e,t,n,o,a){var l,c,d,u,p,f=e.bodies;for(l=0;l<n;l++){for(c=1;c<t;c++)d=f[c-1+l*t],u=f[c+l*t],i.addConstraint(e,r.create(s.extend({bodyA:d,bodyB:u},a)))
;if(l>0)for(c=0;c<t;c++)d=f[c+(l-1)*t],u=f[c+l*t],i.addConstraint(e,r.create(s.extend({bodyA:d,bodyB:u},a))),o&&c>0&&(p=f[c-1+(l-1)*t],i.addConstraint(e,r.create(s.extend({bodyA:p,bodyB:u},a)))),o&&c<t-1&&(p=f[c+1+(l-1)*t],i.addConstraint(e,r.create(s.extend({bodyA:p,bodyB:u},a))))}return e.label+=" Mesh",e},o.pyramid=function(e,t,n,i,r,s,l){return o.stack(e,t,n,i,r,s,function(t,o,s,c,d,u){var p=Math.min(i,Math.ceil(n/2)),f=d?d.bounds.max.x-d.bounds.min.x:0;if(!(c>p)){c=p-c;var m=c,v=n-1-c;if(!(s<m||s>v)){1===u&&a.translate(d,{x:(s+(n%2==1?1:-1))*f,y:0});return l(e+(d?s*f:0)+s*r,o,s,c,d,u)}}})},o.newtonsCradle=function(e,t,n,o,s){for(var a=i.create({label:"Newtons Cradle"}),c=0;c<n;c++){var d=l.circle(e+c*(1.9*o),t+s,o,{inertia:1/0,restitution:1,friction:0,frictionAir:1e-4,slop:1}),u=r.create({pointA:{x:e+c*(1.9*o),y:t},bodyB:d});i.addBody(a,d),i.addConstraint(a,u)}return a},o.car=function(e,t,n,o,s){var c=a.nextGroup(!0),d=.5*-n+20,u=.5*n-20,p=i.create({label:"Car"
}),f=l.rectangle(e,t,n,o,{collisionFilter:{group:c},chamfer:{radius:.5*o},density:2e-4}),m=l.circle(e+d,t+0,s,{collisionFilter:{group:c},friction:.8}),v=l.circle(e+u,t+0,s,{collisionFilter:{group:c},friction:.8}),y=r.create({bodyB:f,pointB:{x:d,y:0},bodyA:m,stiffness:1,length:0}),g=r.create({bodyB:f,pointB:{x:u,y:0},bodyA:v,stiffness:1,length:0});return i.addBody(p,f),i.addBody(p,m),i.addBody(p,v),i.addConstraint(p,y),i.addConstraint(p,g),p},o.softBody=function(e,t,n,i,r,a,c,d,u,p){u=s.extend({inertia:1/0},u),p=s.extend({stiffness:.2,render:{type:"line",anchors:!1}},p);var f=o.stack(e,t,n,i,r,a,function(e,t){return l.circle(e,t,d,u)});return o.mesh(f,n,i,c,p),f.label="Soft Body",f}}()},{"../body/Body":1,"../body/Composite":2,"../constraint/Constraint":12,"../core/Common":14,"./Bodies":23}],25:[function(e,t,n){var o={};t.exports=o;var i=e("../geometry/Vector"),r=e("../core/Common");!function(){o.fromVertices=function(e){for(var t={},n=0;n<e.length;n++){
var o=(n+1)%e.length,s=i.normalise({x:e[o].y-e[n].y,y:e[n].x-e[o].x}),a=0===s.y?1/0:s.x/s.y;a=a.toFixed(3).toString(),t[a]=s}return r.values(t)},o.rotate=function(e,t){if(0!==t)for(var n=Math.cos(t),o=Math.sin(t),i=0;i<e.length;i++){var r,s=e[i];r=s.x*n-s.y*o,s.y=s.x*o+s.y*n,s.x=r}}}()},{"../core/Common":14,"../geometry/Vector":28}],26:[function(e,t,n){var o={};t.exports=o,function(){o.create=function(e){var t={min:{x:0,y:0},max:{x:0,y:0}};return e&&o.update(t,e),t},o.update=function(e,t,n){e.min.x=1/0,e.max.x=-1/0,e.min.y=1/0,e.max.y=-1/0;for(var o=0;o<t.length;o++){var i=t[o];i.x>e.max.x&&(e.max.x=i.x),i.x<e.min.x&&(e.min.x=i.x),i.y>e.max.y&&(e.max.y=i.y),i.y<e.min.y&&(e.min.y=i.y)}n&&(n.x>0?e.max.x+=n.x:e.min.x+=n.x,n.y>0?e.max.y+=n.y:e.min.y+=n.y)},o.contains=function(e,t){return t.x>=e.min.x&&t.x<=e.max.x&&t.y>=e.min.y&&t.y<=e.max.y},o.overlaps=function(e,t){return e.min.x<=t.max.x&&e.max.x>=t.min.x&&e.max.y>=t.min.y&&e.min.y<=t.max.y},o.translate=function(e,t){e.min.x+=t.x,
e.max.x+=t.x,e.min.y+=t.y,e.max.y+=t.y},o.shift=function(e,t){var n=e.max.x-e.min.x,o=e.max.y-e.min.y;e.min.x=t.x,e.max.x=t.x+n,e.min.y=t.y,e.max.y=t.y+o}}()},{}],27:[function(e,t,n){var o={};t.exports=o;var i=(e("../geometry/Bounds"),e("../core/Common"));!function(){o.pathToVertices=function(e,t){"undefined"==typeof window||"SVGPathSeg"in window||i.warn("Svg.pathToVertices: SVGPathSeg not defined, a polyfill is required.");var n,r,s,a,l,c,d,u,p,f,m,v,y=[],g=0,x=0,h=0;t=t||15;var b=function(e,t,n){var o=n%2==1&&n>1;if(!p||e!=p.x||t!=p.y){p&&o?(m=p.x,v=p.y):(m=0,v=0);var i={x:m+e,y:v+t};!o&&p||(p=i),y.push(i),x=m+e,h=v+t}},w=function(e){var t=e.pathSegTypeAsLetter.toUpperCase();if("Z"!==t){switch(t){case"M":case"L":case"T":case"C":case"S":case"Q":x=e.x,h=e.y;break;case"H":x=e.x;break;case"V":h=e.y}b(x,h,e.pathSegType)}};for(o._svgPathToAbsolute(e),s=e.getTotalLength(),c=[],n=0;n<e.pathSegList.numberOfItems;n+=1)c.push(e.pathSegList.getItem(n));for(d=c.concat();g<s;){
if(f=e.getPathSegAtLength(g),(l=c[f])!=u){for(;d.length&&d[0]!=l;)w(d.shift());u=l}switch(l.pathSegTypeAsLetter.toUpperCase()){case"C":case"T":case"S":case"Q":case"A":a=e.getPointAtLength(g),b(a.x,a.y,0)}g+=t}for(n=0,r=d.length;n<r;++n)w(d[n]);return y},o._svgPathToAbsolute=function(e){for(var t,n,o,i,r,s,a=e.pathSegList,l=0,c=0,d=a.numberOfItems,u=0;u<d;++u){var p=a.getItem(u),f=p.pathSegTypeAsLetter;if(/[MLHVCSQTA]/.test(f))"x"in p&&(l=p.x),"y"in p&&(c=p.y);else switch("x1"in p&&(o=l+p.x1),"x2"in p&&(r=l+p.x2),"y1"in p&&(i=c+p.y1),"y2"in p&&(s=c+p.y2),"x"in p&&(l+=p.x),"y"in p&&(c+=p.y),f){case"m":a.replaceItem(e.createSVGPathSegMovetoAbs(l,c),u);break;case"l":a.replaceItem(e.createSVGPathSegLinetoAbs(l,c),u);break;case"h":a.replaceItem(e.createSVGPathSegLinetoHorizontalAbs(l),u);break;case"v":a.replaceItem(e.createSVGPathSegLinetoVerticalAbs(c),u);break;case"c":a.replaceItem(e.createSVGPathSegCurvetoCubicAbs(l,c,o,i,r,s),u);break;case"s":
a.replaceItem(e.createSVGPathSegCurvetoCubicSmoothAbs(l,c,r,s),u);break;case"q":a.replaceItem(e.createSVGPathSegCurvetoQuadraticAbs(l,c,o,i),u);break;case"t":a.replaceItem(e.createSVGPathSegCurvetoQuadraticSmoothAbs(l,c),u);break;case"a":a.replaceItem(e.createSVGPathSegArcAbs(l,c,p.r1,p.r2,p.angle,p.largeArcFlag,p.sweepFlag),u);break;case"z":case"Z":l=t,c=n}"M"!=f&&"m"!=f||(t=l,n=c)}}}()},{"../core/Common":14,"../geometry/Bounds":26}],28:[function(e,t,n){var o={};t.exports=o,function(){o.create=function(e,t){return{x:e||0,y:t||0}},o.clone=function(e){return{x:e.x,y:e.y}},o.magnitude=function(e){return Math.sqrt(e.x*e.x+e.y*e.y)},o.magnitudeSquared=function(e){return e.x*e.x+e.y*e.y},o.rotate=function(e,t,n){var o=Math.cos(t),i=Math.sin(t);n||(n={});var r=e.x*o-e.y*i;return n.y=e.x*i+e.y*o,n.x=r,n},o.rotateAbout=function(e,t,n,o){var i=Math.cos(t),r=Math.sin(t);o||(o={});var s=n.x+((e.x-n.x)*i-(e.y-n.y)*r);return o.y=n.y+((e.x-n.x)*r+(e.y-n.y)*i),o.x=s,o},o.normalise=function(e){
var t=o.magnitude(e);return 0===t?{x:0,y:0}:{x:e.x/t,y:e.y/t}},o.dot=function(e,t){return e.x*t.x+e.y*t.y},o.cross=function(e,t){return e.x*t.y-e.y*t.x},o.cross3=function(e,t,n){return(t.x-e.x)*(n.y-e.y)-(t.y-e.y)*(n.x-e.x)},o.add=function(e,t,n){return n||(n={}),n.x=e.x+t.x,n.y=e.y+t.y,n},o.sub=function(e,t,n){return n||(n={}),n.x=e.x-t.x,n.y=e.y-t.y,n},o.mult=function(e,t){return{x:e.x*t,y:e.y*t}},o.div=function(e,t){return{x:e.x/t,y:e.y/t}},o.perp=function(e,t){return t=!0===t?-1:1,{x:t*-e.y,y:t*e.x}},o.neg=function(e){return{x:-e.x,y:-e.y}},o.angle=function(e,t){return Math.atan2(t.y-e.y,t.x-e.x)},o._temp=[o.create(),o.create(),o.create(),o.create(),o.create(),o.create()]}()},{}],29:[function(e,t,n){var o={};t.exports=o;var i=e("../geometry/Vector"),r=e("../core/Common");!function(){o.create=function(e,t){for(var n=[],o=0;o<e.length;o++){var i=e[o],r={x:i.x,y:i.y,index:o,body:t,isInternal:!1};n.push(r)}return n},o.fromPath=function(e,t){
var n=/L?\s*([\-\d\.e]+)[\s,]*([\-\d\.e]+)*/gi,i=[];return e.replace(n,function(e,t,n){i.push({x:parseFloat(t),y:parseFloat(n)})}),o.create(i,t)},o.centre=function(e){for(var t,n,r,s=o.area(e,!0),a={x:0,y:0},l=0;l<e.length;l++)r=(l+1)%e.length,t=i.cross(e[l],e[r]),n=i.mult(i.add(e[l],e[r]),t),a=i.add(a,n);return i.div(a,6*s)},o.mean=function(e){for(var t={x:0,y:0},n=0;n<e.length;n++)t.x+=e[n].x,t.y+=e[n].y;return i.div(t,e.length)},o.area=function(e,t){for(var n=0,o=e.length-1,i=0;i<e.length;i++)n+=(e[o].x-e[i].x)*(e[o].y+e[i].y),o=i;return t?n/2:Math.abs(n)/2},o.inertia=function(e,t){for(var n,o,r=0,s=0,a=e,l=0;l<a.length;l++)o=(l+1)%a.length,n=Math.abs(i.cross(a[o],a[l])),r+=n*(i.dot(a[o],a[o])+i.dot(a[o],a[l])+i.dot(a[l],a[l])),s+=n;return t/6*(r/s)},o.translate=function(e,t,n){var o;if(n)for(o=0;o<e.length;o++)e[o].x+=t.x*n,e[o].y+=t.y*n;else for(o=0;o<e.length;o++)e[o].x+=t.x,e[o].y+=t.y;return e},o.rotate=function(e,t,n){if(0!==t){
for(var o=Math.cos(t),i=Math.sin(t),r=0;r<e.length;r++){var s=e[r],a=s.x-n.x,l=s.y-n.y;s.x=n.x+(a*o-l*i),s.y=n.y+(a*i+l*o)}return e}},o.contains=function(e,t){for(var n=0;n<e.length;n++){var o=e[n],i=e[(n+1)%e.length];if((t.x-o.x)*(i.y-o.y)+(t.y-o.y)*(o.x-i.x)>0)return!1}return!0},o.scale=function(e,t,n,r){if(1===t&&1===n)return e;r=r||o.centre(e);for(var s,a,l=0;l<e.length;l++)s=e[l],a=i.sub(s,r),e[l].x=r.x+a.x*t,e[l].y=r.y+a.y*n;return e},o.chamfer=function(e,t,n,o,s){t="number"==typeof t?[t]:t||[8],n=void 0!==n?n:-1,o=o||2,s=s||14;for(var a=[],l=0;l<e.length;l++){var c=e[l-1>=0?l-1:e.length-1],d=e[l],u=e[(l+1)%e.length],p=t[l<t.length?l:t.length-1];if(0!==p){var f=i.normalise({x:d.y-c.y,y:c.x-d.x}),m=i.normalise({x:u.y-d.y,y:d.x-u.x}),v=Math.sqrt(2*Math.pow(p,2)),y=i.mult(r.clone(f),p),g=i.normalise(i.mult(i.add(f,m),.5)),x=i.sub(d,i.mult(g,v)),h=n;-1===n&&(h=1.75*Math.pow(p,.32)),h=r.clamp(h,o,s),h%2==1&&(h+=1)
;for(var b=Math.acos(i.dot(f,m)),w=b/h,S=0;S<h;S++)a.push(i.add(i.rotate(y,w*S),x))}else a.push(d)}return a},o.clockwiseSort=function(e){var t=o.mean(e);return e.sort(function(e,n){return i.angle(t,e)-i.angle(t,n)}),e},o.isConvex=function(e){var t,n,o,i,r=0,s=e.length;if(s<3)return null;for(t=0;t<s;t++)if(n=(t+1)%s,o=(t+2)%s,i=(e[n].x-e[t].x)*(e[o].y-e[n].y),i-=(e[n].y-e[t].y)*(e[o].x-e[n].x),i<0?r|=1:i>0&&(r|=2),3===r)return!1;return 0!==r||null},o.hull=function(e){var t,n,o=[],r=[];for(e=e.slice(0),e.sort(function(e,t){var n=e.x-t.x;return 0!==n?n:e.y-t.y}),n=0;n<e.length;n+=1){for(t=e[n];r.length>=2&&i.cross3(r[r.length-2],r[r.length-1],t)<=0;)r.pop();r.push(t)}for(n=e.length-1;n>=0;n-=1){for(t=e[n];o.length>=2&&i.cross3(o[o.length-2],o[o.length-1],t)<=0;)o.pop();o.push(t)}return o.pop(),r.pop(),o.concat(r)}}()},{"../core/Common":14,"../geometry/Vector":28}],30:[function(e,t,n){var o=t.exports=e("../core/Matter");o.Body=e("../body/Body"),o.Composite=e("../body/Composite"),
o.World=e("../body/World"),o.Contact=e("../collision/Contact"),o.Detector=e("../collision/Detector"),o.Grid=e("../collision/Grid"),o.Pairs=e("../collision/Pairs"),o.Pair=e("../collision/Pair"),o.Query=e("../collision/Query"),o.Resolver=e("../collision/Resolver"),o.SAT=e("../collision/SAT"),o.Constraint=e("../constraint/Constraint"),o.MouseConstraint=e("../constraint/MouseConstraint"),o.Common=e("../core/Common"),o.Engine=e("../core/Engine"),o.Events=e("../core/Events"),o.Mouse=e("../core/Mouse"),o.Runner=e("../core/Runner"),o.Sleeping=e("../core/Sleeping"),o.Plugin=e("../core/Plugin"),o.Bodies=e("../factory/Bodies"),o.Composites=e("../factory/Composites"),o.Axes=e("../geometry/Axes"),o.Bounds=e("../geometry/Bounds"),o.Svg=e("../geometry/Svg"),o.Vector=e("../geometry/Vector"),o.Vertices=e("../geometry/Vertices"),o.Render=e("../render/Render"),o.RenderPixi=e("../render/RenderPixi"),o.World.add=o.Composite.add,o.World.remove=o.Composite.remove,
o.World.addComposite=o.Composite.addComposite,o.World.addBody=o.Composite.addBody,o.World.addConstraint=o.Composite.addConstraint,o.World.clear=o.Composite.clear,o.Engine.run=o.Runner.run},{"../body/Body":1,"../body/Composite":2,"../body/World":3,"../collision/Contact":4,"../collision/Detector":5,"../collision/Grid":6,"../collision/Pair":7,"../collision/Pairs":8,"../collision/Query":9,"../collision/Resolver":10,"../collision/SAT":11,"../constraint/Constraint":12,"../constraint/MouseConstraint":13,"../core/Common":14,"../core/Engine":15,"../core/Events":16,"../core/Matter":17,"../core/Metrics":18,"../core/Mouse":19,"../core/Plugin":20,"../core/Runner":21,"../core/Sleeping":22,"../factory/Bodies":23,"../factory/Composites":24,"../geometry/Axes":25,"../geometry/Bounds":26,"../geometry/Svg":27,"../geometry/Vector":28,"../geometry/Vertices":29,"../render/Render":31,"../render/RenderPixi":32}],31:[function(e,t,n){var o={};t.exports=o
;var i=e("../core/Common"),r=e("../body/Composite"),s=e("../geometry/Bounds"),a=e("../core/Events"),l=e("../collision/Grid"),c=e("../geometry/Vector"),d=e("../core/Mouse");!function(){var e,t;"undefined"!=typeof window&&(e=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame||function(e){window.setTimeout(function(){e(i.now())},1e3/60)},t=window.cancelAnimationFrame||window.mozCancelAnimationFrame||window.webkitCancelAnimationFrame||window.msCancelAnimationFrame),o.create=function(e){var t={controller:o,engine:null,element:null,canvas:null,mouse:null,frameRequestId:null,options:{width:800,height:600,pixelRatio:1,background:"#18181d",wireframeBackground:"#0f0f13",hasBounds:!!e.bounds,enabled:!0,wireframes:!0,showSleeping:!0,showDebug:!1,showBroadphase:!1,showBounds:!1,showVelocity:!1,showCollisions:!1,showSeparations:!1,showAxes:!1,showPositions:!1,showAngleIndicator:!1,showIds:!1,showShadows:!1,
showVertexNumbers:!1,showConvexHulls:!1,showInternalEdges:!1,showMousePosition:!1}},r=i.extend(t,e);return r.canvas&&(r.canvas.width=r.options.width||r.canvas.width,r.canvas.height=r.options.height||r.canvas.height),r.mouse=e.mouse,r.engine=e.engine,r.canvas=r.canvas||n(r.options.width,r.options.height),r.context=r.canvas.getContext("2d"),r.textures={},r.bounds=r.bounds||{min:{x:0,y:0},max:{x:r.canvas.width,y:r.canvas.height}},1!==r.options.pixelRatio&&o.setPixelRatio(r,r.options.pixelRatio),i.isElement(r.element)?r.element.appendChild(r.canvas):r.canvas.parentNode||i.log("Render.create: options.element was undefined, render.canvas was created but not appended","warn"),r},o.run=function(t){!function n(i){t.frameRequestId=e(n),o.world(t)}()},o.stop=function(e){t(e.frameRequestId)},o.setPixelRatio=function(e,t){var n=e.options,o=e.canvas;"auto"===t&&(t=u(o)),n.pixelRatio=t,o.setAttribute("data-pixel-ratio",t),o.width=n.width*t,o.height=n.height*t,o.style.width=n.width+"px",
o.style.height=n.height+"px",e.context.scale(t,t)},o.lookAt=function(e,t,n,o){o=void 0===o||o,t=i.isArray(t)?t:[t],n=n||{x:0,y:0};for(var r={min:{x:1/0,y:1/0},max:{x:-1/0,y:-1/0}},s=0;s<t.length;s+=1){var a=t[s],l=a.bounds?a.bounds.min:a.min||a.position||a,c=a.bounds?a.bounds.max:a.max||a.position||a;l&&c&&(l.x<r.min.x&&(r.min.x=l.x),c.x>r.max.x&&(r.max.x=c.x),l.y<r.min.y&&(r.min.y=l.y),c.y>r.max.y&&(r.max.y=c.y))}var u=r.max.x-r.min.x+2*n.x,p=r.max.y-r.min.y+2*n.y,f=e.canvas.height,m=e.canvas.width,v=m/f,y=u/p,g=1,x=1;y>v?x=y/v:g=v/y,e.options.hasBounds=!0,e.bounds.min.x=r.min.x,e.bounds.max.x=r.min.x+u*g,e.bounds.min.y=r.min.y,e.bounds.max.y=r.min.y+p*x,o&&(e.bounds.min.x+=.5*u-u*g*.5,e.bounds.max.x+=.5*u-u*g*.5,e.bounds.min.y+=.5*p-p*x*.5,e.bounds.max.y+=.5*p-p*x*.5),e.bounds.min.x-=n.x,e.bounds.max.x-=n.x,e.bounds.min.y-=n.y,e.bounds.max.y-=n.y,e.mouse&&(d.setScale(e.mouse,{x:(e.bounds.max.x-e.bounds.min.x)/e.canvas.width,y:(e.bounds.max.y-e.bounds.min.y)/e.canvas.height}),
d.setOffset(e.mouse,e.bounds.min))},o.startViewTransform=function(e){var t=e.bounds.max.x-e.bounds.min.x,n=e.bounds.max.y-e.bounds.min.y,o=t/e.options.width,i=n/e.options.height;e.context.scale(1/o,1/i),e.context.translate(-e.bounds.min.x,-e.bounds.min.y)},o.endViewTransform=function(e){e.context.setTransform(e.options.pixelRatio,0,0,e.options.pixelRatio,0,0)},o.world=function(e){var t,n=e.engine,i=n.world,u=e.canvas,p=e.context,m=e.options,v=r.allBodies(i),y=r.allConstraints(i),g=m.wireframes?m.wireframeBackground:m.background,x=[],h=[],b={timestamp:n.timing.timestamp};if(a.trigger(e,"beforeRender",b),e.currentBackground!==g&&f(e,g),p.globalCompositeOperation="source-in",p.fillStyle="transparent",p.fillRect(0,0,u.width,u.height),p.globalCompositeOperation="source-over",m.hasBounds){for(t=0;t<v.length;t++){var w=v[t];s.overlaps(w.bounds,e.bounds)&&x.push(w)}for(t=0;t<y.length;t++){var S=y[t],C=S.bodyA,A=S.bodyB,P=S.pointA,B=S.pointB;C&&(P=c.add(C.position,S.pointA)),
A&&(B=c.add(A.position,S.pointB)),P&&B&&((s.contains(e.bounds,P)||s.contains(e.bounds,B))&&h.push(S))}o.startViewTransform(e),e.mouse&&(d.setScale(e.mouse,{x:(e.bounds.max.x-e.bounds.min.x)/e.canvas.width,y:(e.bounds.max.y-e.bounds.min.y)/e.canvas.height}),d.setOffset(e.mouse,e.bounds.min))}else h=y,x=v;!m.wireframes||n.enableSleeping&&m.showSleeping?o.bodies(e,x,p):(m.showConvexHulls&&o.bodyConvexHulls(e,x,p),o.bodyWireframes(e,x,p)),m.showBounds&&o.bodyBounds(e,x,p),(m.showAxes||m.showAngleIndicator)&&o.bodyAxes(e,x,p),m.showPositions&&o.bodyPositions(e,x,p),m.showVelocity&&o.bodyVelocity(e,x,p),m.showIds&&o.bodyIds(e,x,p),m.showSeparations&&o.separations(e,n.pairs.list,p),m.showCollisions&&o.collisions(e,n.pairs.list,p),m.showVertexNumbers&&o.vertexNumbers(e,x,p),m.showMousePosition&&o.mousePosition(e,e.mouse,p),o.constraints(h,p),m.showBroadphase&&n.broadphase.controller===l&&o.grid(e,n.broadphase,p),m.showDebug&&o.debug(e,p),m.hasBounds&&o.endViewTransform(e),
a.trigger(e,"afterRender",b)},o.debug=function(e,t){var n=t,o=e.engine,i=o.world,s=o.metrics,a=e.options;r.allBodies(i);if(o.timing.timestamp-(e.debugTimestamp||0)>=500){var l="";s.timing&&(l+="fps: "+Math.round(s.timing.fps)+" "),e.debugString=l,e.debugTimestamp=o.timing.timestamp}if(e.debugString){n.font="12px Arial",a.wireframes?n.fillStyle="rgba(255,255,255,0.5)":n.fillStyle="rgba(0,0,0,0.5)";for(var c=e.debugString.split("\n"),d=0;d<c.length;d++)n.fillText(c[d],50,50+18*d)}},o.constraints=function(e,t){for(var n=t,o=0;o<e.length;o++){var r=e[o];if(r.render.visible&&r.pointA&&r.pointB){var s,a,l=r.bodyA,d=r.bodyB;if(s=l?c.add(l.position,r.pointA):r.pointA,"pin"===r.render.type)n.beginPath(),n.arc(s.x,s.y,3,0,2*Math.PI),n.closePath();else{if(a=d?c.add(d.position,r.pointB):r.pointB,n.beginPath(),n.moveTo(s.x,s.y),"spring"===r.render.type)for(var u,p=c.sub(a,s),f=c.perp(c.normalise(p)),m=Math.ceil(i.clamp(r.length/5,12,20)),v=1;v<m;v+=1)u=v%2==0?1:-1,
n.lineTo(s.x+p.x*(v/m)+f.x*u*4,s.y+p.y*(v/m)+f.y*u*4);n.lineTo(a.x,a.y)}r.render.lineWidth&&(n.lineWidth=r.render.lineWidth,n.strokeStyle=r.render.strokeStyle,n.stroke()),r.render.anchors&&(n.fillStyle=r.render.strokeStyle,n.beginPath(),n.arc(s.x,s.y,3,0,2*Math.PI),n.arc(a.x,a.y,3,0,2*Math.PI),n.closePath(),n.fill())}}},o.bodyShadows=function(e,t,n){for(var o=n,i=(e.engine,0);i<t.length;i++){var r=t[i];if(r.render.visible){if(r.circleRadius)o.beginPath(),o.arc(r.position.x,r.position.y,r.circleRadius,0,2*Math.PI),o.closePath();else{o.beginPath(),o.moveTo(r.vertices[0].x,r.vertices[0].y);for(var s=1;s<r.vertices.length;s++)o.lineTo(r.vertices[s].x,r.vertices[s].y);o.closePath()}var a=r.position.x-.5*e.options.width,l=r.position.y-.2*e.options.height,c=Math.abs(a)+Math.abs(l);o.shadowColor="rgba(0,0,0,0.15)",o.shadowOffsetX=.05*a,o.shadowOffsetY=.05*l,o.shadowBlur=1+12*Math.min(1,c/1e3),o.fill(),o.shadowColor=null,o.shadowOffsetX=null,o.shadowOffsetY=null,o.shadowBlur=null}}},
o.bodies=function(e,t,n){var o,i,r,s,a=n,l=(e.engine,e.options),c=l.showInternalEdges||!l.wireframes;for(r=0;r<t.length;r++)if(o=t[r],o.render.visible)for(s=o.parts.length>1?1:0;s<o.parts.length;s++)if(i=o.parts[s],i.render.visible){if(l.showSleeping&&o.isSleeping?a.globalAlpha=.5*i.render.opacity:1!==i.render.opacity&&(a.globalAlpha=i.render.opacity),i.render.sprite&&i.render.sprite.texture&&!l.wireframes){var d=i.render.sprite,u=p(e,d.texture);a.translate(i.position.x,i.position.y),a.rotate(i.angle),a.drawImage(u,u.width*-d.xOffset*d.xScale,u.height*-d.yOffset*d.yScale,u.width*d.xScale,u.height*d.yScale),a.rotate(-i.angle),a.translate(-i.position.x,-i.position.y)}else{if(i.circleRadius)a.beginPath(),a.arc(i.position.x,i.position.y,i.circleRadius,0,2*Math.PI);else{a.beginPath(),a.moveTo(i.vertices[0].x,i.vertices[0].y);for(var f=1;f<i.vertices.length;f++)!i.vertices[f-1].isInternal||c?a.lineTo(i.vertices[f].x,i.vertices[f].y):a.moveTo(i.vertices[f].x,i.vertices[f].y),
i.vertices[f].isInternal&&!c&&a.moveTo(i.vertices[(f+1)%i.vertices.length].x,i.vertices[(f+1)%i.vertices.length].y);a.lineTo(i.vertices[0].x,i.vertices[0].y),a.closePath()}l.wireframes?(a.lineWidth=1,a.strokeStyle="#bbb",a.stroke()):(a.fillStyle=i.render.fillStyle,i.render.lineWidth&&(a.lineWidth=i.render.lineWidth,a.strokeStyle=i.render.strokeStyle,a.stroke()),a.fill())}a.globalAlpha=1}},o.bodyWireframes=function(e,t,n){var o,i,r,s,a,l=n,c=e.options.showInternalEdges;for(l.beginPath(),r=0;r<t.length;r++)if(o=t[r],o.render.visible)for(a=o.parts.length>1?1:0;a<o.parts.length;a++){for(i=o.parts[a],l.moveTo(i.vertices[0].x,i.vertices[0].y),s=1;s<i.vertices.length;s++)!i.vertices[s-1].isInternal||c?l.lineTo(i.vertices[s].x,i.vertices[s].y):l.moveTo(i.vertices[s].x,i.vertices[s].y),i.vertices[s].isInternal&&!c&&l.moveTo(i.vertices[(s+1)%i.vertices.length].x,i.vertices[(s+1)%i.vertices.length].y);l.lineTo(i.vertices[0].x,i.vertices[0].y)}l.lineWidth=1,l.strokeStyle="#bbb",l.stroke()},
o.bodyConvexHulls=function(e,t,n){var o,i,r,s=n;for(s.beginPath(),i=0;i<t.length;i++)if(o=t[i],o.render.visible&&1!==o.parts.length){for(s.moveTo(o.vertices[0].x,o.vertices[0].y),r=1;r<o.vertices.length;r++)s.lineTo(o.vertices[r].x,o.vertices[r].y);s.lineTo(o.vertices[0].x,o.vertices[0].y)}s.lineWidth=1,s.strokeStyle="rgba(255,255,255,0.2)",s.stroke()},o.vertexNumbers=function(e,t,n){var o,i,r,s=n;for(o=0;o<t.length;o++){var a=t[o].parts;for(r=a.length>1?1:0;r<a.length;r++){var l=a[r];for(i=0;i<l.vertices.length;i++)s.fillStyle="rgba(255,255,255,0.2)",s.fillText(o+"_"+i,l.position.x+.8*(l.vertices[i].x-l.position.x),l.position.y+.8*(l.vertices[i].y-l.position.y))}}},o.mousePosition=function(e,t,n){var o=n;o.fillStyle="rgba(255,255,255,0.8)",o.fillText(t.position.x+" "+t.position.y,t.position.x+5,t.position.y-5)},o.bodyBounds=function(e,t,n){var o=n,i=(e.engine,e.options);o.beginPath();for(var r=0;r<t.length;r++){
if(t[r].render.visible)for(var s=t[r].parts,a=s.length>1?1:0;a<s.length;a++){var l=s[a];o.rect(l.bounds.min.x,l.bounds.min.y,l.bounds.max.x-l.bounds.min.x,l.bounds.max.y-l.bounds.min.y)}}i.wireframes?o.strokeStyle="rgba(255,255,255,0.08)":o.strokeStyle="rgba(0,0,0,0.1)",o.lineWidth=1,o.stroke()},o.bodyAxes=function(e,t,n){var o,i,r,s,a=n,l=(e.engine,e.options);for(a.beginPath(),i=0;i<t.length;i++){var c=t[i],d=c.parts;if(c.render.visible)if(l.showAxes)for(r=d.length>1?1:0;r<d.length;r++)for(o=d[r],s=0;s<o.axes.length;s++){var u=o.axes[s];a.moveTo(o.position.x,o.position.y),a.lineTo(o.position.x+20*u.x,o.position.y+20*u.y)}else for(r=d.length>1?1:0;r<d.length;r++)for(o=d[r],s=0;s<o.axes.length;s++)a.moveTo(o.position.x,o.position.y),a.lineTo((o.vertices[0].x+o.vertices[o.vertices.length-1].x)/2,(o.vertices[0].y+o.vertices[o.vertices.length-1].y)/2)}l.wireframes?(a.strokeStyle="indianred",a.lineWidth=1):(a.strokeStyle="rgba(255, 255, 255, 0.4)",a.globalCompositeOperation="overlay",
a.lineWidth=2),a.stroke(),a.globalCompositeOperation="source-over"},o.bodyPositions=function(e,t,n){var o,i,r,s,a=n,l=(e.engine,e.options);for(a.beginPath(),r=0;r<t.length;r++)if(o=t[r],o.render.visible)for(s=0;s<o.parts.length;s++)i=o.parts[s],a.arc(i.position.x,i.position.y,3,0,2*Math.PI,!1),a.closePath();for(l.wireframes?a.fillStyle="indianred":a.fillStyle="rgba(0,0,0,0.5)",a.fill(),a.beginPath(),r=0;r<t.length;r++)o=t[r],o.render.visible&&(a.arc(o.positionPrev.x,o.positionPrev.y,2,0,2*Math.PI,!1),a.closePath());a.fillStyle="rgba(255,165,0,0.8)",a.fill()},o.bodyVelocity=function(e,t,n){var o=n;o.beginPath();for(var i=0;i<t.length;i++){var r=t[i];r.render.visible&&(o.moveTo(r.position.x,r.position.y),o.lineTo(r.position.x+2*(r.position.x-r.positionPrev.x),r.position.y+2*(r.position.y-r.positionPrev.y)))}o.lineWidth=3,o.strokeStyle="cornflowerblue",o.stroke()},o.bodyIds=function(e,t,n){var o,i,r=n;for(o=0;o<t.length;o++)if(t[o].render.visible){var s=t[o].parts
;for(i=s.length>1?1:0;i<s.length;i++){var a=s[i];r.font="12px Arial",r.fillStyle="rgba(255,255,255,0.5)",r.fillText(a.id,a.position.x+10,a.position.y-10)}}},o.collisions=function(e,t,n){var o,i,r,s,a=n,l=e.options;for(a.beginPath(),r=0;r<t.length;r++)if(o=t[r],o.isActive)for(i=o.collision,s=0;s<o.activeContacts.length;s++){var c=o.activeContacts[s],d=c.vertex;a.rect(d.x-1.5,d.y-1.5,3.5,3.5)}for(l.wireframes?a.fillStyle="rgba(255,255,255,0.7)":a.fillStyle="orange",a.fill(),a.beginPath(),r=0;r<t.length;r++)if(o=t[r],o.isActive&&(i=o.collision,o.activeContacts.length>0)){var u=o.activeContacts[0].vertex.x,p=o.activeContacts[0].vertex.y;2===o.activeContacts.length&&(u=(o.activeContacts[0].vertex.x+o.activeContacts[1].vertex.x)/2,p=(o.activeContacts[0].vertex.y+o.activeContacts[1].vertex.y)/2),i.bodyB===i.supports[0].body||!0===i.bodyA.isStatic?a.moveTo(u-8*i.normal.x,p-8*i.normal.y):a.moveTo(u+8*i.normal.x,p+8*i.normal.y),a.lineTo(u,p)}
l.wireframes?a.strokeStyle="rgba(255,165,0,0.7)":a.strokeStyle="orange",a.lineWidth=1,a.stroke()},o.separations=function(e,t,n){var o,i,r,s,a,l=n,c=e.options;for(l.beginPath(),a=0;a<t.length;a++)if(o=t[a],o.isActive){i=o.collision,r=i.bodyA,s=i.bodyB;var d=1;s.isStatic||r.isStatic||(d=.5),s.isStatic&&(d=0),l.moveTo(s.position.x,s.position.y),l.lineTo(s.position.x-i.penetration.x*d,s.position.y-i.penetration.y*d),d=1,s.isStatic||r.isStatic||(d=.5),r.isStatic&&(d=0),l.moveTo(r.position.x,r.position.y),l.lineTo(r.position.x+i.penetration.x*d,r.position.y+i.penetration.y*d)}c.wireframes?l.strokeStyle="rgba(255,165,0,0.5)":l.strokeStyle="orange",l.stroke()},o.grid=function(e,t,n){var o=n;e.options.wireframes?o.strokeStyle="rgba(255,180,0,0.1)":o.strokeStyle="rgba(255,180,0,0.5)",o.beginPath();for(var r=i.keys(t.buckets),s=0;s<r.length;s++){var a=r[s];if(!(t.buckets[a].length<2)){var l=a.split(/C|R/)
;o.rect(.5+parseInt(l[1],10)*t.bucketWidth,.5+parseInt(l[2],10)*t.bucketHeight,t.bucketWidth,t.bucketHeight)}}o.lineWidth=1,o.stroke()},o.inspector=function(e,t){var n,o=(e.engine,e.selected),i=e.render,r=i.options;if(r.hasBounds){var s=i.bounds.max.x-i.bounds.min.x,a=i.bounds.max.y-i.bounds.min.y,l=s/i.options.width,c=a/i.options.height;t.scale(1/l,1/c),t.translate(-i.bounds.min.x,-i.bounds.min.y)}for(var d=0;d<o.length;d++){var u=o[d].data;switch(t.translate(.5,.5),t.lineWidth=1,t.strokeStyle="rgba(255,165,0,0.9)",t.setLineDash([1,2]),u.type){case"body":n=u.bounds,t.beginPath(),t.rect(Math.floor(n.min.x-3),Math.floor(n.min.y-3),Math.floor(n.max.x-n.min.x+6),Math.floor(n.max.y-n.min.y+6)),t.closePath(),t.stroke();break;case"constraint":var p=u.pointA;u.bodyA&&(p=u.pointB),t.beginPath(),t.arc(p.x,p.y,10,0,2*Math.PI),t.closePath(),t.stroke()}t.setLineDash([]),t.translate(-.5,-.5)}null!==e.selectStart&&(t.translate(.5,.5),t.lineWidth=1,t.strokeStyle="rgba(255,165,0,0.6)",
t.fillStyle="rgba(255,165,0,0.1)",n=e.selectBounds,t.beginPath(),t.rect(Math.floor(n.min.x),Math.floor(n.min.y),Math.floor(n.max.x-n.min.x),Math.floor(n.max.y-n.min.y)),t.closePath(),t.stroke(),t.fill(),t.translate(-.5,-.5)),r.hasBounds&&t.setTransform(1,0,0,1,0,0)};var n=function(e,t){var n=document.createElement("canvas");return n.width=e,n.height=t,n.oncontextmenu=function(){return!1},n.onselectstart=function(){return!1},n},u=function(e){var t=e.getContext("2d");return(window.devicePixelRatio||1)/(t.webkitBackingStorePixelRatio||t.mozBackingStorePixelRatio||t.msBackingStorePixelRatio||t.oBackingStorePixelRatio||t.backingStorePixelRatio||1)},p=function(e,t){var n=e.textures[t];return n||(n=e.textures[t]=new Image,n.src=t,n)},f=function(e,t){var n=t;/(jpg|gif|png)$/.test(t)&&(n="url("+t+")"),e.canvas.style.background=n,e.canvas.style.backgroundSize="contain",e.currentBackground=t}}()},{"../body/Composite":2,"../collision/Grid":6,"../core/Common":14,"../core/Events":16,
"../core/Mouse":19,"../geometry/Bounds":26,"../geometry/Vector":28}],32:[function(e,t,n){var o={};t.exports=o;var i=e("../geometry/Bounds"),r=e("../body/Composite"),s=e("../core/Common"),a=e("../core/Events"),l=e("../geometry/Vector");!function(){var e,t;"undefined"!=typeof window&&(e=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame||function(e){window.setTimeout(function(){e(s.now())},1e3/60)},t=window.cancelAnimationFrame||window.mozCancelAnimationFrame||window.webkitCancelAnimationFrame||window.msCancelAnimationFrame),o.create=function(e){s.warn("RenderPixi.create: Matter.RenderPixi is deprecated (see docs)");var t={controller:o,engine:null,element:null,frameRequestId:null,canvas:null,renderer:null,container:null,spriteContainer:null,pixiOptions:null,options:{width:800,height:600,background:"#fafafa",wireframeBackground:"#222",hasBounds:!1,enabled:!0,wireframes:!0,showSleeping:!0,showDebug:!1,
showBroadphase:!1,showBounds:!1,showVelocity:!1,showCollisions:!1,showAxes:!1,showPositions:!1,showAngleIndicator:!1,showIds:!1,showShadows:!1}},n=s.extend(t,e),i=!n.options.wireframes&&"transparent"===n.options.background;return n.pixiOptions=n.pixiOptions||{view:n.canvas,transparent:i,antialias:!0,backgroundColor:e.background},n.mouse=e.mouse,n.engine=e.engine,n.renderer=n.renderer||new PIXI.WebGLRenderer(n.options.width,n.options.height,n.pixiOptions),n.container=n.container||new PIXI.Container,n.spriteContainer=n.spriteContainer||new PIXI.Container,n.canvas=n.canvas||n.renderer.view,n.bounds=n.bounds||{min:{x:0,y:0},max:{x:n.options.width,y:n.options.height}},a.on(n.engine,"beforeUpdate",function(){o.clear(n)}),n.textures={},n.sprites={},n.primitives={},n.container.addChild(n.spriteContainer),s.isElement(n.element)?n.element.appendChild(n.canvas):s.warn('No "render.element" passed, "render.canvas" was not inserted into document.'),n.canvas.oncontextmenu=function(){return!1},
n.canvas.onselectstart=function(){return!1},n},o.run=function(t){!function n(i){t.frameRequestId=e(n),o.world(t)}()},o.stop=function(e){t(e.frameRequestId)},o.clear=function(e){for(var t=e.container,n=e.spriteContainer;t.children[0];)t.removeChild(t.children[0]);for(;n.children[0];)n.removeChild(n.children[0]);var o=e.sprites["bg-0"];e.textures={},e.sprites={},e.primitives={},e.sprites["bg-0"]=o,o&&t.addChildAt(o,0),e.container.addChild(e.spriteContainer),e.currentBackground=null,t.scale.set(1,1),t.position.set(0,0)},o.setBackground=function(e,t){if(e.currentBackground!==t){var n=t.indexOf&&-1!==t.indexOf("#"),o=e.sprites["bg-0"];if(n){var i=s.colorToNumber(t);e.renderer.backgroundColor=i,o&&e.container.removeChild(o)}else if(!o){var r=d(e,t);o=e.sprites["bg-0"]=new PIXI.Sprite(r),o.position.x=0,o.position.y=0,e.container.addChildAt(o,0)}e.currentBackground=t}},o.world=function(e){
var t,n=e.engine,s=n.world,a=e.renderer,c=e.container,d=e.options,u=r.allBodies(s),p=r.allConstraints(s),f=[];d.wireframes?o.setBackground(e,d.wireframeBackground):o.setBackground(e,d.background);var m=e.bounds.max.x-e.bounds.min.x,v=e.bounds.max.y-e.bounds.min.y,y=m/e.options.width,g=v/e.options.height;if(d.hasBounds){for(t=0;t<u.length;t++){var x=u[t];x.render.sprite.visible=i.overlaps(x.bounds,e.bounds)}for(t=0;t<p.length;t++){var h=p[t],b=h.bodyA,w=h.bodyB,S=h.pointA,C=h.pointB;b&&(S=l.add(b.position,h.pointA)),w&&(C=l.add(w.position,h.pointB)),S&&C&&((i.contains(e.bounds,S)||i.contains(e.bounds,C))&&f.push(h))}c.scale.set(1/y,1/g),c.position.set(-e.bounds.min.x*(1/y),-e.bounds.min.y*(1/g))}else f=p;for(t=0;t<u.length;t++)o.body(e,u[t]);for(t=0;t<f.length;t++)o.constraint(e,f[t]);a.render(c)},o.constraint=function(e,t){var n=(e.engine,t.bodyA),o=t.bodyB,i=t.pointA,r=t.pointB,a=e.container,l=t.render,c="c-"+t.id,d=e.primitives[c];if(d||(d=e.primitives[c]=new PIXI.Graphics),
!l.visible||!t.pointA||!t.pointB)return void d.clear();-1===s.indexOf(a.children,d)&&a.addChild(d),d.clear(),d.beginFill(0,0),d.lineStyle(l.lineWidth,s.colorToNumber(l.strokeStyle),1),n?d.moveTo(n.position.x+i.x,n.position.y+i.y):d.moveTo(i.x,i.y),o?d.lineTo(o.position.x+r.x,o.position.y+r.y):d.lineTo(r.x,r.y),d.endFill()},o.body=function(e,t){var o=(e.engine,t.render);if(o.visible)if(o.sprite&&o.sprite.texture){var i="b-"+t.id,r=e.sprites[i],a=e.spriteContainer;r||(r=e.sprites[i]=n(e,t)),-1===s.indexOf(a.children,r)&&a.addChild(r),r.position.x=t.position.x,r.position.y=t.position.y,r.rotation=t.angle,r.scale.x=o.sprite.xScale||1,r.scale.y=o.sprite.yScale||1}else{var l="b-"+t.id,d=e.primitives[l],u=e.container;d||(d=e.primitives[l]=c(e,t),d.initialAngle=t.angle),-1===s.indexOf(u.children,d)&&u.addChild(d),d.position.x=t.position.x,d.position.y=t.position.y,d.rotation=t.angle-d.initialAngle}};var n=function(e,t){var n=t.render,o=n.sprite.texture,i=d(e,o),r=new PIXI.Sprite(i)
;return r.anchor.x=t.render.sprite.xOffset,r.anchor.y=t.render.sprite.yOffset,r},c=function(e,t){var n,o=t.render,i=e.options,r=new PIXI.Graphics,a=s.colorToNumber(o.fillStyle),l=s.colorToNumber(o.strokeStyle),c=s.colorToNumber(o.strokeStyle),d=s.colorToNumber("#bbb"),u=s.colorToNumber("#CD5C5C");r.clear();for(var p=t.parts.length>1?1:0;p<t.parts.length;p++){n=t.parts[p],i.wireframes?(r.beginFill(0,0),r.lineStyle(1,d,1)):(r.beginFill(a,1),r.lineStyle(o.lineWidth,l,1)),r.moveTo(n.vertices[0].x-t.position.x,n.vertices[0].y-t.position.y);for(var f=1;f<n.vertices.length;f++)r.lineTo(n.vertices[f].x-t.position.x,n.vertices[f].y-t.position.y);r.lineTo(n.vertices[0].x-t.position.x,n.vertices[0].y-t.position.y),r.endFill(),(i.showAngleIndicator||i.showAxes)&&(r.beginFill(0,0),i.wireframes?r.lineStyle(1,u,1):r.lineStyle(1,c),r.moveTo(n.position.x-t.position.x,n.position.y-t.position.y),
r.lineTo((n.vertices[0].x+n.vertices[n.vertices.length-1].x)/2-t.position.x,(n.vertices[0].y+n.vertices[n.vertices.length-1].y)/2-t.position.y),r.endFill())}return r},d=function(e,t){var n=e.textures[t];return n||(n=e.textures[t]=PIXI.Texture.fromImage(t)),n}}()},{"../body/Composite":2,"../core/Common":14,"../core/Events":16,"../geometry/Bounds":26,"../geometry/Vector":28}]},{},[30])(30)});
\ No newline at end of file
/**
* Created by rockyl on 2020-01-21.
*/
let customModuleProps = {
};
This source diff could not be displayed because it is too large. You can view the blob instead.
{
"name": "海底",
"desc": "海底模块",
"props": {
"level_1": {
"alias": "第一关数据(第一个是当前关卡通过所需积分,第二个是炸弹个数,第三个是道具个数,第四个是关卡时间)",
"type": "array<number>",
"default": "5,1,9,60"
},
"level_2": {
"alias": "第一关数据(第一个是当前关卡通过所需积分,第二个是炸弹个数,第三个是道具个数,第四个是关卡时间)",
"type": "array<number>",
"default": "10,2,14,80"
},
"level_3": {
"alias": "第一关数据(第一个是当前关卡通过所需积分,第二个是炸弹个数,第三个是道具个数,第四个是关卡时间)",
"type": "array<number>",
"default": "15,3,19,110"
}
},
"assets": [
{
"name": "灯",
"url": "//yun.duiba.com.cn/aurora/assets/c0f7c4b4d650da31d9b23a9006bd0e58aaca95ad.png",
"uuid": "55a9e50c-c7bc-4bb1-8624-fdd7edb66f93",
"ext": ".png"
},
{
"name": "机子",
"url": "//yun.duiba.com.cn/aurora/assets/e07baecf71ed8ecd9429fbbebb064b3cd50658df.png",
"uuid": "dee8564f-e17a-4a78-87f7-bebeb83fd235",
"ext": ".png"
},
{
"name": "篮筐",
"url": "//yun.duiba.com.cn/aurora/assets/b6977968fa3cdefbe181adbe2a381df9e8402af5.png",
"uuid": "8b49fe91-f6b7-414c-81d1-a9689e473b29",
"ext": ".png"
},
{
"name": "右按钮",
"url": "//yun.duiba.com.cn/aurora/assets/e3b4d4c0e557529b8c383639acce3d2ac01bf9b3.png",
"uuid": "1b1acf4a-a1fb-427e-a8cd-48214f89ac46",
"ext": ".png"
},
{
"name": "左按钮",
"url": "//yun.duiba.com.cn/aurora/assets/4bc49a4477adbfcda25d348473504d4384ad3dd2.png",
"uuid": "d828d269-68e7-4801-a3b2-e4bb1c38592b",
"ext": ".png"
},
{
"name": "basket_bottom",
"url": "//yun.duiba.com.cn/aurora/assets/8003d15eda09a24c38fdf32d2b774fe9a16fcd81.png",
"uuid": "1bccf897-d37e-4dc7-814f-6b8caf27a03b",
"ext": ".png"
},
{
"name": "basket_top",
"url": "//yun.duiba.com.cn/aurora/assets/55596516d4d44685fe07be1fef2105c8186edcd7.png",
"uuid": "826c7811-2767-469f-bf6b-908f3d404a1d",
"ext": ".png"
},
{
"name": "coin_json",
"url": "//yun.duiba.com.cn/aurora/assets/4170985efa5fea693a27734d14250e3b5a49962b.json",
"uuid": "9a0265ec-d9e7-4d47-83c7-d775115df38e",
"ext": ".json"
},
{
"name": "coin",
"url": "//yun.duiba.com.cn/aurora/assets/d6a361f27ebb81dd444ac40e428dffd06a0aa4e3.png",
"uuid": "abe242de-cf82-46ec-8a40-fcd51b0ca13d",
"ext": ".png"
},
{
"name": "boom_json",
"url": "//yun.duiba.com.cn/aurora/assets/4da36db75239d5c4f7b89d5805429ad64f7a05d5.json",
"uuid": "b0f0ae6d-b7c7-4a35-8c5a-7c4249f011db",
"ext": ".json"
},
{
"name": "boom",
"url": "//yun.duiba.com.cn/aurora/assets/b4579f262046e16245df9982ef31c57e433b0ba7.png",
"uuid": "129aa5f7-e308-40ce-ba9b-3fdc733d4ecb",
"ext": ".png"
},
{
"name": "candy_json",
"url": "//yun.duiba.com.cn/aurora/assets/2512911b42641f570be929e686a17fa91582f411.json",
"uuid": "0f21fae8-08cb-4c41-bab5-993d98fd7070",
"ext": ".json"
},
{
"name": "candy",
"url": "//yun.duiba.com.cn/aurora/assets/a91c39b45b0aa042b112ac477bc5ab80f00e8816.png",
"uuid": "67c0717c-9b89-4b56-a61a-91c8c7a99e4c",
"ext": ".png"
},
{
"name": "egg_json",
"url": "//yun.duiba.com.cn/aurora/assets/d789e4167a136e889729dd97d4f8728517226c8a.json",
"uuid": "75ac3c28-f8a8-4609-b908-bb386a6ace2c",
"ext": ".json"
},
{
"name": "egg",
"url": "//yun.duiba.com.cn/aurora/assets/a9156427b733d959c473dc0e37c929f103f77174.png",
"uuid": "e2f61593-e082-405a-bf19-79c78e2c067a",
"ext": ".png"
},
{
"name": "fail_json",
"url": "//yun.duiba.com.cn/aurora/assets/be22c261821766b019138176658ea3857f7dc5c8.json",
"uuid": "96f6c48f-f01e-4d13-a058-0c082edc38fa",
"ext": ".json"
},
{
"name": "fail",
"url": "//yun.duiba.com.cn/aurora/assets/d5fff67caae5a86bc29969d1676b76b253eda701.png",
"uuid": "9473b143-bd58-4450-b7b9-cb18911f3ba3",
"ext": ".png"
},
{
"name": "gift_json",
"url": "//yun.duiba.com.cn/aurora/assets/9165343ca17a457133d227956c217e0a821a0cf3.json",
"uuid": "48347b92-7c99-4bf5-a67a-d535b4785b20",
"ext": ".json"
},
{
"name": "gift",
"url": "//yun.duiba.com.cn/aurora/assets/e47e2ebdbb9cc8fe1f9f0e941af3cbe92b08162b.png",
"uuid": "a3667116-4218-4b5f-a6ec-c1529ddb71cf",
"ext": ".png"
},
{
"name": "success_json",
"url": "//yun.duiba.com.cn/aurora/assets/a010032b62ec260b6ad0844b1eff530847954e10.json",
"uuid": "3a70f25d-03c0-483c-847b-88b6e4ed5dcf",
"ext": ".json"
},
{
"name": "success",
"url": "//yun.duiba.com.cn/aurora/assets/e6c6b8fff68fcbb2e30cbb50f5690d52be4d8c99.png",
"uuid": "0ec792be-6fcc-4c5b-bf8a-0e8406a5c34b",
"ext": ".png"
},
{
"name": "玻璃",
"url": "//yun.duiba.com.cn/aurora/assets/90edb55a1c5fb4b7baf689144b7c1f3508ecb7ff.png",
"uuid": "92d1a3d4-256b-467b-a9a2-4820c2c2c718",
"ext": ".png"
},
{
"name": "contPng",
"url": "//yun.duiba.com.cn/aurora/assets/a19ba2de0b7f11830700ed8122585a95ebef1757.png",
"uuid": "84e4f5dc-149d-4ace-a02c-8b2aaf6819b1",
"ext": ".png"
},
{
"name": "bubble",
"url": "//yun.duiba.com.cn/aurora/assets/f30c3b92eac79cdae679c48436eb4ef92b97ff6c.png",
"uuid": "28c4a8e4-9ff8-4962-842a-dd90d04a958c",
"ext": ".png"
},
{
"name": "倒计时",
"url": "//yun.duiba.com.cn/aurora/assets/a9b9490cd7ef4974c6ca5c34b3b4e4a2fdd1f8ca.png",
"uuid": "893a1116-1ddb-49e5-89bd-8f523ad56f81",
"ext": ".png"
},
{
"name": "awesome",
"url": "//yun.duiba.com.cn/aurora/assets/89de7d7785bb70a95b139fe444b90fbe5e802c80.png",
"uuid": "b7f19c22-22ea-419e-99d0-3b6959b59f88",
"ext": ".png"
},
{
"name": "cool",
"url": "//yun.duiba.com.cn/aurora/assets/5e1ce8651de0f67cf98220238db00ef6d46b1aeb.png",
"uuid": "585b11a0-8d5d-4265-8871-96d98c0a65cf",
"ext": ".png"
},
{
"name": "good",
"url": "//yun.duiba.com.cn/aurora/assets/49a5633dc8429fac1d59c7a55ba15f3386cdddc7.png",
"uuid": "bdbc7ff6-5b64-4878-bcb2-9b83a498206b",
"ext": ".png"
},
{
"name": "great",
"url": "//yun.duiba.com.cn/aurora/assets/ad47ea03239e36e09806a74cb4bd475a42edb00a.png",
"uuid": "bd1da4bb-1dbf-4b80-a6ea-eb4e50cf65aa",
"ext": ".png"
},
{
"name": "perfect",
"url": "//yun.duiba.com.cn/aurora/assets/b560b07e694a95ef6b40b6702cdfc8853eb73ec3.png",
"uuid": "63ce23dc-be8b-4222-a0a6-0fd5a27c0af6",
"ext": ".png"
},
{
"name": "unbelievable",
"url": "//yun.duiba.com.cn/aurora/assets/a436eb46836e45d8043721107e5f49a58367ac3f.png",
"uuid": "6f352da0-0522-4530-b064-9132b591b341",
"ext": ".png"
},
{
"name": "进度",
"url": "//yun.duiba.com.cn/aurora/assets/0a7f33bba28a882ea1ec436b73ecafbaed4542d5.png",
"uuid": "647dc81b-443d-446b-bcf6-8b95b8511470",
"ext": ".png"
},
{
"name": "点亮",
"url": "//yun.duiba.com.cn/aurora/assets/3e8ca3a3f044df467c76a7a0d5ebbd75520bda8e.png",
"uuid": "9808f74f-a474-4c10-a8c6-bb51663d1a8e",
"ext": ".png"
},
{
"name": "lv1",
"url": "//yun.duiba.com.cn/aurora/assets/76db0c80d7b8051d7de44e87cac763ce607d2c7a.png",
"uuid": "a9a91d6c-06b0-4fdf-bcb8-77abe9bc7d83",
"ext": ".png"
},
{
"name": "lv2",
"url": "//yun.duiba.com.cn/aurora/assets/c5f1c83c683c5703432cc615b2c206aee1c675e0.png",
"uuid": "de8b2a81-fb38-4128-b536-9ef03eb013df",
"ext": ".png"
},
{
"name": "lv3",
"url": "//yun.duiba.com.cn/aurora/assets/beed55701a29bfa9b49dca1d5a059b34d7702496.png",
"uuid": "710eed46-f371-4d85-9858-ad048c86fc74",
"ext": ".png"
},
{
"name": "lv_common",
"url": "//yun.duiba.com.cn/aurora/assets/0afe14fc04beb3c66ce9080502c7c381f4b658ea.png",
"uuid": "e53e80fd-80a6-4385-b296-a3f097eeb51a",
"ext": ".png"
},
{
"name": "dot",
"url": "//yun.duiba.com.cn/aurora/assets/b39a88200f27f65e9d8d3f2a98a671de979f3027.png",
"uuid": "b8acc117-7d3c-4bcb-aff9-b5f42b901edf",
"ext": ".png"
}
],
"events": {
"in": {
"seabed-game-start": {
"alias": "开始",
"data": {
}
},
"seabed-game-startNextLevel": {
"alias": "开始下一关",
"data": {
"level":"关卡"
}
},
"seabed-game-revive": {
"alias": "复活",
"data": {
}
},
"seabed-game-themeChange": {
"alias": "更换主题",
"data": {
"gameCountdownImage": "游戏页倒计时",
"leftButtonImage": "左按钮",
"rightButtonImage": "右按钮"
}
}
},
"out": {
"seabed-game-fail": {
"alias": "游戏结束",
"data": {
"score":"当前分数",
"level": "当前关卡"
}
},
"seabed-game-success": {
"alias": "游戏成功",
"data": {
"score":"当前分数",
"level": "当前关卡"
}
}
}
}
}
\ No newline at end of file
/**
* Created by rockyl on 2018/8/16.
*/
import { props } from "../props";
import { getIndexFromRC, getRandomArray, getTexture, getTextureByName } from "./utils";
import ObjectPool = engine.ObjectPool;
import { Tool } from "./Tools";
import { getScore, getCurLevel, getlevelMax } from "./goldData";
export default class GameData extends engine.Container {
private _scoreCount:engine.Label;
private _scorelabel:engine.Label;
private _levelLabel:engine.Label;
private _parentNode;
private starList = [];
private _progressMask;
private _color;
constructor(parentNode,color) {
super();
this._parentNode = parentNode;
this._color = color;
this.init();
}
init(){
//分数
let scoreCount = this._scoreCount = Tool.getLabel('',36,"#ffffff",true)
scoreCount.y = 48;
this.addChild(scoreCount);
let scorelabel = this._scorelabel = Tool.getLabel('分',22,"#ffffff")
scorelabel.y = 56;
this.addChild(scorelabel);
let progress = new engine.Sprite(getTextureByName('进度'));
progress.x = 212;
progress.y = 8;
this.addChild(progress);
let progressMask = this._progressMask = new engine.Rect()
progressMask.fillColor = 0x000000
progressMask.width = 245;
progressMask.height = 100;
progressMask.x = 213;
progressMask.y = 5;
//0.35 0.75 1
progressMask.scaleX = 0;
this.addChild(progressMask);
progress.mask = progressMask;
let star1 = new engine.Sprite(getTextureByName('点亮'));
star1.x = 270;
star1.y = 6;
star1.visible = false;
this.addChild(star1);
this.starList.push(star1);
let star2 = new engine.Sprite(getTextureByName('点亮'));
star2.x = 365;
star2.y = 6;
star2.visible = false;
this.addChild(star2);
this.starList.push(star2);
let star3 = new engine.Sprite(getTextureByName('点亮'));
star3.x = 435;
star3.y = 50;
star3.visible = false;
this.addChild(star3);
this.starList.push(star3);
this.scorePosUpdate();
//当前关卡数
let levelLabel = this._levelLabel = Tool.getLabel('',28,this._color||"#28c1ec",false)
levelLabel.y = 98;
this.addChild(levelLabel);
this.levelUpdate();
this.updateProgressMask();
}
scorePosUpdate(){
this._scoreCount.text = getScore()
this._scoreCount.x = (this._parentNode.width - this._scoreCount.width - this._scorelabel.width - 5)/2
this._scorelabel.x = this._scoreCount.x + this._scoreCount.width + 5;
this.updateProgressMask();
}
levelUpdate(color?){
this._levelLabel.text = `第${getCurLevel()}/3关`
this._levelLabel.x = (this._parentNode.width-this._levelLabel.width)/2;
}
updateProgressMask(){
let ratio = getScore()/getlevelMax()
this._progressMask.scaleX = ratio;
//0.35 0.75 1
if(ratio >= 0.35){
this.starList[0].visible = true;
}
if(ratio >= 0.75){
this.starList[1].visible = true;
}
if(ratio >= 1){
this.starList[2].visible = true;
}
}
resetMask(){
this.starList.forEach(element => {
element.visible = false;
});
}
}
\ No newline at end of file
import { setTouchEnabled, getTouchEnabled } from './GoldData';
/**
* Created by rockyl on 2018/8/16.
*/
import { props } from "../props";
import { getIndexFromRC, getRandomArray, getTexture, getTextureByName } from "./utils";
import ObjectPool = engine.ObjectPool;
import GameData from "./gameData";
import EgretRender from "../physics/EgretRender";
import check from "./check";
import { addScore, getlevelTime, getCurLevel, getScore, getlevelMax } from "./goldData";
import createBox from "./createBox";
import createItems from "./createItems";
import { stopStandbyBubblesLeft, startStandbyBubblesLeft, stopStandbyBubblesRight, startStandbyBubblesRight } from "./standbyBubbles";
import createBtns from "./createBtns";
import createBubblePic from "./createBubblePic";
import { bubbleGroup, bubble, bubbleMask, award } from "./collisionConfig";
import { Tool } from './Tools';
import { playBoom } from "./playMovieClip";
export default class GameView extends engine.Container {
private _bg;
private _gameNode;
public _leftBtn;
public _rightBtn;
private _light;
private _basket_top;
private _basket_bottom;
private _gameData:GameData;
public _engine: Matter.Engine;
public egretRenderContainer: engine.Sprite;
public _egretRender: EgretRender;
private _countDown:engine.Sprite;
private _countDownLabel:engine.Label;
public _startStandbyBubblesLeft;
public _startStandbyBubblesRight;
private _curLevelTime;
public gameHint:{[name: string]: any} = {};
private toastRect;
private toastLabel:engine.Label;
constructor() {
super();
}
async start(color) {
let a = new engine.Shape()
this.addChild(a)
engine.globalLoader.loadImage('//yun.duiba.com.cn/aurora/assets/66ab48ff49a741f0c93335d4eb0c9e50b7ab6e1e.png', 'bg_dot')
.then((img)=>{
a.beginBitmapFill(img,null)
a.drawRect(0,0,750,1624)
a.endFill()
});
let gameNode = this._gameNode = new engine.Sprite(getTextureByName('机子'));
gameNode.y = 260;
this.addChild(gameNode);
let contPng = new engine.Image(getTextureByName('contPng'));
contPng.x = (750-contPng.width)/2
contPng.y = 215;
this.addChild(contPng);
let leftBtn = this._leftBtn = new engine.Sprite(getTextureByName('左按钮'));
leftBtn.anchorY = leftBtn.height-50
leftBtn.x = 83;
leftBtn.y = 920;
gameNode.addChild(leftBtn);
let rightBtn = this._rightBtn = new engine.Sprite(getTextureByName('右按钮'));
rightBtn.anchorY = rightBtn.height-50
rightBtn.x = 400;
rightBtn.y = 920;
gameNode.addChild(rightBtn);
let light = this._light = new engine.Sprite(getTextureByName('灯'));
light.x = 12;
light.y = 44;
gameNode.addChild(light);
let basket_bottom = this._basket_bottom = new engine.Sprite(getTextureByName('basket_bottom'));
basket_bottom.x = (contPng.width - basket_bottom.width)/2;
basket_bottom.y = 85;
contPng.addChild(basket_bottom);
let tmpRect = new engine.Rect();
tmpRect.x = 230
tmpRect.y = 372
tmpRect.width = 300;
tmpRect.height = 300;
this.addChild(tmpRect);
basket_bottom.mask = tmpRect;
let basket_top = this._basket_top = new engine.Sprite(getTextureByName('basket_top'));
basket_top.x = 287;
basket_top.y = 485;
this.addChild(basket_top);
let glass = this._basket_top = new engine.Sprite(getTextureByName('玻璃'));
glass.x = (750-glass.width)/2;
glass.y = 340;
this.addChild(glass);
let gameData = this._gameData = new GameData(contPng,color);
contPng.addChild(gameData);
//倒计时
let countDown = this._countDown = new engine.Sprite(getTextureByName('倒计时'));
countDown.x = 5;
countDown.y = 180;
this.addChild(countDown);
this._curLevelTime = getlevelTime()
let countDownLabel = this._countDownLabel = Tool.getLabel(this._curLevelTime,48,"#ffffff")
countDownLabel.x = (countDown.width-countDownLabel.width)/2
countDownLabel.y = (countDown.height-countDownLabel.height)/2 - 5
countDown.addChild(countDownLabel);
this.initGameHint();
// let rect = this.toastRect = new engine.Rect();
// rect.fillColor = 0x000000;
// rect.width = 400;
// rect.height = 80;
// rect.x = (750-400) / 2;
// rect.y = 500;
// rect.alpha = 0;
// this.addChild(rect);
// let toast = this.toastLabel = Tool.getLabel(``,28,"#28c1ec",false)
// toast.x = (rect.width - toast.width) / 2;
// toast.y = (rect.height - toast.height) / 2;
// toast.fillColor = 0xffffff;
// rect.addChild(toast);
this.startHandle();
this.levelHint();
}
private _lvbg;
private _lv:engine.Sprite;
private _lv_common;
private _lv_label:engine.Label;
levelHint(){
let lvBg = this._lvbg = new engine.Rect();
lvBg.fillColor = 0x000000;
lvBg.alpha = 0.7;
lvBg.width = 750;
lvBg.height = 1624;
lvBg.x = lvBg.y = 0;
lvBg.visible = false;
this.addChild(lvBg);
let lv_common = this._lv_common = new engine.Sprite(getTextureByName('lv_common'));
lv_common.x = (750-lv_common.width)/2;
lv_common.y = 500;
lv_common.visible = false;
this.addChild(lv_common);
let lv1 = this._lv = new engine.Sprite(getTextureByName('lv1'));
lv1.anchorTexture.set(0.5,0.5)
lv1.x = lv_common.width/2;
lv1.y = 80;
lv_common.addChild(lv1);
let lv1_label = this._lv_label = Tool.getLabel(`5`,38,"#28c1ec",true,engine.TEXT_ALIGN.CENTER)
lv1_label.width = 100;
lv1_label.x = 205;
lv1_label.y = 205;
lv1_label.fillColor = 0xffffff;
lv_common.addChild(lv1_label);
//this.lvArray.push(lv_common);
}
initGameHint(){
//['great', 'cool', 'perfect', 'awesome', 'unbelievable']
let awesome = new engine.Sprite(getTextureByName('awesome'));
awesome.anchorTexture.set(0.5,0.5);
awesome.x = 520;
awesome.y = 490;
awesome.alpha = 0;
this.addChild(awesome);
this.gameHint['awesome'] = awesome;
let cool = new engine.Sprite(getTextureByName('cool'));
cool.anchorTexture.set(0.5,0.5);
cool.x = 520;
cool.y = 490;
cool.alpha = 0;
this.addChild(cool);
this.gameHint['cool'] = cool;
let good = new engine.Sprite(getTextureByName('good'));
good.anchorTexture.set(0.5,0.5);
good.x = 520;
good.y = 490;
good.alpha = 0;
this.addChild(good);
this.gameHint['good'] = good;
let great = new engine.Sprite(getTextureByName('great'));
great.anchorTexture.set(0.5,0.5);
great.x = 520;
great.y = 490;
great.alpha = 0;
this.addChild(great);
this.gameHint['great'] = great;
let perfect = new engine.Sprite(getTextureByName('perfect'));
perfect.anchorTexture.set(0.5,0.5);
perfect.x = 530;
perfect.y = 490;
perfect.alpha = 0;
this.addChild(perfect);
this.gameHint['perfect'] = perfect;
let unbelievable = new engine.Sprite(getTextureByName('unbelievable'));
unbelievable.anchorTexture.set(0.5,0.5);
unbelievable.x = 480;
unbelievable.y = 460;
unbelievable.alpha = 0;
this.addChild(unbelievable);
this.gameHint['unbelievable'] = unbelievable;
}
startNextLevel(){
this.clearAwardBody()
this.playLevelAni()
setTouchEnabled(true);
createItems(this);
this._gameData.scorePosUpdate();
this._gameData.resetMask();
this._gameData.levelUpdate();
this._curLevelTime = getlevelTime()
this._countDownLabel.text = this._curLevelTime;
this._countDownLabel.x = (this._countDown.width-this._countDownLabel.width)/2
this.runEngine();
}
themeChange(data){
this._countDown.texture = engine.Texture.fromImage(data.gameCountdownImage);
this._leftBtn.texture = engine.Texture.fromImage(data.leftButtonImage);
this._leftBtn.anchorY = this._leftBtn.height-50
this._leftBtn.x = 83;
this._leftBtn.y = 920;
this._rightBtn.texture = engine.Texture.fromImage(data.rightButtonImage);
this._rightBtn.anchorY = this._rightBtn.height-50
this._rightBtn.x = 400;
this._rightBtn.y = 920;
}
revive(){
setTouchEnabled(true);
this.runEngine();
}
startHandle(){
//创建引擎
const engineMatter = Matter.Engine.create();
this._engine = engineMatter;
this._engine.world.gravity.y = 0.2;
//创建egret渲染
this.egretRenderContainer = new engine.Sprite();
this.addChild(this.egretRenderContainer);
this._egretRender = new EgretRender(this.egretRenderContainer, this._engine);
const options: any = {
width: 750,
height: 1624,
wireframes: !1,
};
const render = Matter.Render.create({
element: document.getElementById('debugCanvas'),
engine: engineMatter,
options: options
});
Matter.Render.run(render);
this.runGame();
}
addForce = false;
stageX = 0;
stageY = 0;
runGame(){
createBox(this);
Matter.Events.on(this._engine, 'beforeUpdate', () => {
if (!this.addForce) return
this.addForce = false;
const isleft = this.stageX < 375;
const start = isleft ? { x: 180, y: 1050 } : { x: 560, y: 1050 };
const scale = 2.2;
for (let i = 0; i < 15; i++) {
setTimeout(() => {
const r = this.random(10, 14);
let bubblePic;
bubblePic = createBubblePic(r);//默认球的尺寸100
const basex = 0.02;
const xoffset = 0.007;
const fx = isleft ? this.random(-basex, basex) : this.random(-basex, basex);
const padding = 50;
const startx = this.random(start.x - padding, start.x + padding);
if (fx < -xoffset || fx > xoffset) bubblePic = null;
const body = this._egretRender.circle(startx, start.y, r, bubblePic,
{
density: 0.001 * 3,
restitution: 1,
force: { x: fx * scale, y: -0.02 * scale },
collisionFilter: { group: bubbleGroup, category: bubble, mask: bubbleMask }
}
);
setTimeout(() => {
this._egretRender.remove(body);
}, 1000);
}, Math.random() * 200);
}
for (let j = 0; j < 1; j++) {
const start = isleft ? { x: 180 + 50, y: 1050 + 30 } : { x: 560 - 50, y: 1050 + 30 };
const r = this.random(10, 14);
const body = this._egretRender.circle(start.x, start.y, r, null,
{
density: 0.001 * 3,
restitution: 1,
force: { x: (isleft ? 1 : -1) * 0.02 * 1.7, y: 0 },
collisionFilter: { group: bubbleGroup, category: bubble, mask: bubbleMask }
}
);
setTimeout(() => {
this._egretRender.remove(body);
}, 1000);
}
});
this._leftBtn.addEventListener(engine.MouseEvent.CLICK, (e: engine.MouseEvent) => {
if(!getTouchEnabled())return;
this.addForce = true;
this.stageX = e.stageX;
stopStandbyBubblesLeft();
clearTimeout(this._startStandbyBubblesLeft);
this._startStandbyBubblesLeft = setTimeout(() => {
startStandbyBubblesLeft(this._egretRender);
}, 1000);
}, this);
this._rightBtn.addEventListener(engine.MouseEvent.CLICK, (e: engine.MouseEvent) => {
if(!getTouchEnabled())return;
this.addForce = true;
this.stageX = e.stageX;
stopStandbyBubblesRight();
clearTimeout(this._startStandbyBubblesRight);
this._startStandbyBubblesRight = setTimeout(() => {
startStandbyBubblesRight(this._egretRender);
}, 1000);
}, this);
createBtns(this)
startStandbyBubblesLeft(this._egretRender);
startStandbyBubblesRight(this._egretRender);
}
//帧处理
private lastTime;
private _frameCount = 0;
enterFrame(){
var now = Date.now();
var deltaTime = this.lastTime ? now - this.lastTime : 16.7;
this.lastTime = now;
this._frameCount += deltaTime;
if(this._frameCount>=1000){
this._frameCount = 0;
this.updateCountDown();
}
if(deltaTime > 20)
deltaTime = 20
Matter.Engine.update(this._engine, deltaTime);
this._egretRender.run();
check(this);
return false;
}
random(start, end){
const n = end - start;
return Math.random() * n + start;
}
runEngine(){
engine.gameStage.addEventListener(engine.Event.ENTER_FRAME, this.enterFrame, this)
}
updateCountDown(){
this._curLevelTime --
this._countDownLabel.text = this._curLevelTime;
this._countDownLabel.x = (this._countDown.width-this._countDownLabel.width)/2
if(this._curLevelTime <= 0)
{
this.end();
console.log('时间结束');
}
}
onBoom(){
this.end();
}
addScore(): any {
addScore(1)
if(getScore() >= getlevelMax()){
setTouchEnabled(false);
engine.gameStage.removeEventListener(engine.Event.ENTER_FRAME, this.enterFrame, this)
engine.globalEvent.dispatchEvent('seabed-game-success',{level:getCurLevel(),score:getScore()})
}
this._gameData.scorePosUpdate();
}
playLevelAni(){
const lv = getCurLevel();
this._lv.texture = getTextureByName(`lv${lv}`)
this._lv_label.text = getlevelMax()+'';
this._lvbg.visible = true;
this._lv_common.visible = true;
engine.Tween.get(this._lv_common).set({ y: 500 - 1624 }).to({ y: 500 }, 700, engine.Ease.backOut)
.wait(1000).to({ y: 1624 + 500 }, 500, engine.Ease.backIn)
.call(()=>{
this._lvbg.visible = false;
});
//engine.Tween.get(this['lvbg']).wait(700 + 1000).to({ alpha: 0 }, 500);
}
clearAwardBody() {
const bodies = Matter.Composite.allBodies(this._engine.world);
const isAward = (i: Matter.Body) => { return i.collisionFilter.group == award }
bodies.forEach(i => {
if (isAward(i)) this._egretRender.remove(i);
})
}
end(){
engine.gameStage.removeEventListener(engine.Event.ENTER_FRAME, this.enterFrame, this)
engine.globalEvent.dispatchEvent('seabed-game-fail',{level:getCurLevel(),score:getScore(),time:this._curLevelTime})
setTouchEnabled(false);
}
}
\ No newline at end of file
import { setTouchEnabled, setlevelData } from './GoldData';
/**
* Created by rockyl on 2020-01-09.
*/
import GameView from "./GameView";
import { injectProps } from "../props";
import { setScore, setCurLevel } from "./goldData";
import { getJsonAsset } from "./JsonTools";
export class GameWrapper extends engine.Container {
// private _status;
private _gameView: GameView;
constructor() {
super();
engine.globalEvent.addEventListener('seabed-game-start', this.start, this);
engine.globalEvent.addEventListener('seabed-game-revive', this.revive, this);
engine.globalEvent.addEventListener('seabed-game-startNextLevel', this.startNextLevel, this);
engine.globalEvent.addEventListener('seabed-game-themeChange', this.themeChange, this);
//创建实例
let gameView = this._gameView = new GameView();
this.addChild(gameView);
//this.start(null);
// setTimeout(() => {
// engine.globalEvent.dispatchEvent('seabed-game-startNextLevel',{level:2});
// }, 300);
}
start(event: engine.Event) {
setlevelData();
this.initData();
this._gameView.start(event.data.color);
['coin','boom','fail','success'].forEach(element => {
getJsonAsset(element);
});
}
startNextLevel(event: engine.Event){
setScore(0);
setCurLevel(parseInt(event.data.level));
this._gameView.startNextLevel();
}
initData(){
setScore(0);
setCurLevel(1);
}
//复活
revive(){
this._gameView.revive();
}
themeChange(event: engine.Event){
this._gameView.themeChange(event.data.resData);
}
}
import LabelType from "./LabelType";
import { props } from "../props";
let curScore;
export function getScore(){
return curScore;
}
export function addScore(addCount:number){
curScore += addCount;
return curScore;
}
export function setScore(scoreCount:number){
curScore = scoreCount;
}
let curLevel;
export function getCurLevel(){
return curLevel;
}
export function setCurLevel(level){
curLevel = level
return curLevel;
}
//time-当前关卡时长
let levels;
export const setlevelData = () => {
levels = {
'1': { max: props.level_1[0], items: [[LabelType.boom, props.level_1[1]],[LabelType.coin, props.level_1[2]]],time:props.level_1[3]},
'2': { max: props.level_2[0], items: [[LabelType.boom, props.level_2[1]], [LabelType.coin, props.level_2[2]]] ,time:props.level_2[3]},
'3': { max: props.level_3[0], items: [[LabelType.boom, props.level_3[1]], [LabelType.coin, props.level_3[2]]] ,time:props.level_3[3]},
}
}
export const getLevelData = () => {
if(!levels){
setlevelData();
}
return levels[getCurLevel()]
}
export const getCurrentItems = () => {
if(!levels){
setlevelData();
}
return getLevelData().items
}
export const getlevelTime = () => {
if(!levels){
setlevelData();
}
return getLevelData().time
}
//当前关卡需要的最大通关数
export const getlevelMax = () => {
if(!levels){
setlevelData();
}
return getLevelData().max
}
let touchEnabled = false;
export const getTouchEnabled = () => {
return touchEnabled
}
export const setTouchEnabled = (b) => {
touchEnabled = b
}
\ No newline at end of file
let josnData: {
[name: string]: any
} = {};
export function getJsonAsset(name: string) {
let config = engine.getAssetByName(name+'_json');
let tmpJosnData = engine.globalLoader.get(config.uuid);
if(tmpJosnData){
josnData[name] = convert(tmpJosnData);
}
}
export function convert(data){
let frames = data.frames;
let jsonName = data.file.split('.')[0]
var obj = {};
for (var key in frames) {
let f = frames[key];
obj[jsonName + key + ".png"] = {
"x": f.x,
"y": f.y,
"w": f.w,
"h": f.h,
"ox": f.offX,
"oy": f.offY,
"sw": f.sourceW,
"sh": f.sourceH,
"ro": false,
}
}
return obj||null;
}
export function getJosnData(jsonName:string) {
return josnData[jsonName] || null;
}
\ No newline at end of file
enum LabelType {
boom='boom',candy='candy',coin='coin',gift='gift',egg='egg'
}
export default LabelType
\ No newline at end of file
export class Tool{
/**
*
* @param txt
* @param size
* @param color
* @param textWidth
* @param align
* @param x
* @param y
*/
public static getLabel(
txt: string,
size: number,
color: string = "#ffffff",
bold:boolean = false,
align: engine.TEXT_ALIGN = engine.TEXT_ALIGN.LEFT,
x: number = 0,
y: number = 0
):engine.Label{
var label = new engine.Label();
label.fillColor = color;
label.bold = bold;
label.size = size;
label.textAlign = align;
label.x = x;
label.y = y;
label.text = txt;
return label;
}
}
\ No newline at end of file
import GameView from "./GameView";
import LabelType from "./LabelType";
import { award } from "./collisionConfig";
import vibrate from "./vibrate";
import { playBoom, playSuccess } from "./playMovieClip";
import { getScore, getLevelData } from "./goldData";
import { createNewBubble } from "./createItems";
import { playTextAni } from "./playTextAni";
export function check (_this:GameView) {
const egretRenderContainer = _this.egretRenderContainer;
const center = 375;
const paddingX = 50;
const ypos = 570;
const h = 40;
// _this._egretRender._root.graphics.beginFill(0xff0000, 1);
// _this._egretRender._root.graphics.drawRect(center - paddingX, ypos, paddingX * 2, h);
// _this._egretRender._root.graphics.endFill();
const bodies = Matter.Composite.allBodies(_this._engine.world);
const isAward = (i: Matter.Body) => { return i.collisionFilter.group == award }
bodies.forEach(i => {
if (!isAward(i)) return;
if (i['timer']) {
const t0 = Date.now() - i['timer'];
if (t0 > 3000)//3s之内不可再用
{
delete i['timer'];
// console.log('重新可用', Date.now() / 1000)
}
}
const { x, y } = i.position;
const xResult = x > (center - paddingX) && x < (center + paddingX);
const yResult = y > ypos && y < (ypos + h);
if (xResult && yResult && i.velocity.y > 0 && !i['timer']) {
i['timer'] = Date.now();
if (i.label == LabelType.boom) {
_this._egretRender.remove(i);
vibrate(_this, 2);
playBoom(egretRenderContainer);
_this.onBoom();
}
else if (i.label == LabelType.egg) {
_this._egretRender.remove(i);
//PanelCtrl.instance.show(ModuleTypes.SLOT_PANEL);
}
else if (i.label == LabelType.candy) {
_this._egretRender.remove(i);
//PanelCtrl.instance.show(ModuleTypes.ROTATE_PANEL);
}
else if (i.label == LabelType.gift) {
_this._egretRender.remove(i);
//PanelCtrl.instance.show(ModuleTypes.TREASURE_PANEL);
}
else {
// console.log('不是boom,重用', Date.now() / 1000);
// playScoreAni(_this.egretRenderContainer, 1)
playSuccess(_this.egretRenderContainer);
_this._egretRender.remove(i);
_this.addScore();
//checkAdd(_this);
playTextAni(_this)
}
}
})
}
const checkAdd = (that: GameView) => {
const oldscore = getScore();
const awards = getLevelData().awards;
for (const award of awards) {
if (award[0] == oldscore) {
const type = award[1];
createNewBubble(that, type);
break;
}
}
}
export default check
\ No newline at end of file
export const wall = 1;
export const basket = 2;
export const award = 4;
export const bubble = 8;
export const bubbleStandby = 16;
export const bubbleGroup = -1;
export const bubbleStandbyGroup = -2;
export const wallMask = award + bubble + bubbleStandby;
export const basketMask = award + bubble + bubbleStandby;
export const awardMask = wall + basket + bubble;
export const bubbleMask = wall + basket + award;
export const bubbleStandbyMask = wall + basket;
import { wall, wallMask, basket, basketMask } from "./collisionConfig";
import GameView from "./GameView";
const createBox = (_this:GameView) => {
//202
//385 168 640 201 695 528 644 866 392 907 109 868 57 546 118 206 0 206 0 1624 750 1624 750 0
//385 370 630 380 670 728 620 1080 370 1100 109 1090 57 728 108 370 0 370 0 1624 750 1624 750 0
const path1 = Matter.Vertices.fromPath('385 370 630 380 670 728 620 1080 370 1100 109 1090 57 728 108 370 0 370 0 1624 750 1624 750 0', null);
//430, 717
//430,920
const body = Matter.Bodies.fromVertices(400, 880, [path1], { isStatic: true, collisionFilter: { group: wall, category: wall, mask: wallMask } }, true);
Matter.World.add(_this._engine.world, body);
//118 206 385 168 385 100
//108 370 385 370 385 300
const path2 = Matter.Vertices.fromPath('108 370 385 370 385 300', null);
//425 - 10 - 100 - 10 - 10 + 1, 30 + 100 + 10 + 10 + 6
//296, 365
const body2 = Matter.Bodies.fromVertices(296, 365, [path2], { isStatic: true, collisionFilter: { group: wall, category: wall, mask: wallMask } }, true);
Matter.World.add(_this._engine.world, body2);
//290 432 324 476 326 476 313 432
//290 560 324 600 326 600 313 565
const basketpath1 = Matter.Vertices.fromPath('290 560 324 600 326 600 313 565', null);
//311 - 3 - 8 + 2+3, 452 - 5
//305, 575
const basketbody1 = Matter.Bodies.fromVertices(305, 575, [basketpath1], { isStatic: true, friction: 0, collisionFilter: { group: basket, category: basket, mask: basketMask } }, true);
Matter.World.add(_this._engine.world, basketbody1);
//479 435 443 481 441 481 456 435
//465 563 443 605 441 605 456 560
const basketpath2 = Matter.Vertices.fromPath('465 563 443 605 441 605 456 560', null);
//449 + 3 + 8 - 2 - 2-3, 452 - 5
//453, 570
const basketbody2 = Matter.Bodies.fromVertices(453, 570, [basketpath2], { isStatic: true, friction: 0, collisionFilter: { group: basket, category: basket, mask: basketMask } }, true);
Matter.World.add(_this._engine.world, basketbody2);
//311 - 3 - 8 + 2 - 5, 427
//285, 560
const basketLeft = Matter.Bodies.circle(285, 560 , 12, { isStatic: true, friction: 0, collisionFilter: { group: basket, category: basket, mask: basketMask } })
Matter.World.add(_this._engine.world, basketLeft);
//456 + 5, 427
//461, 560
const basketRight = Matter.Bodies.circle(461, 560, 12, { isStatic: true, friction: 0, collisionFilter: { group: basket, category: basket, mask: basketMask } })
Matter.World.add(_this._engine.world, basketRight);
const w = 100;
const h = 50;
//153 + w / 2, 833 + h / 2
//180 1080
const rect = _this._egretRender.rectangle(180, 1080, w, h, null, { isStatic: true, collisionFilter: { group: wall, category: wall, mask: wallMask } });
//553 - 10 - 30 - 5 + w / 2, 833 + h / 2
//560 1080
const rect2 = _this._egretRender.rectangle(560, 1080, w, h, null, { isStatic: true, collisionFilter: { group: wall, category: wall, mask: wallMask } });
const w2 = 300;
const h2 = 10;
//375, 873 + h2 / 2
//375 1100
const rect3 = _this._egretRender.rectangle(375, 1100, w2, h2, null, { isStatic: true, collisionFilter: { group: wall, category: wall, mask: wallMask } });
}
export default createBox
\ No newline at end of file
import GameView from "./GameView";
export default (that: GameView) => {
const createShape = () => {
const shape = new engine.Shape();
shape.beginFill(0, .6);
shape.drawCircle(0, 0, that._leftBtn.width / 2);
shape.endFill();
return shape
}
[that._leftBtn, that._rightBtn].forEach(btn => {
btn.addEventListener(engine.MouseEvent.MOUSE_DOWN, (e: engine.MouseEvent) => {
const btn = e.target;
engine.Tween.removeTweens(btn);
engine.Tween.get(btn)
.to({scaleY:0.9},200)
}, that);
});
[that._leftBtn, that._rightBtn].forEach(btn => {
btn.addEventListener(engine.MouseEvent.MOUSE_UP, (e: engine.MouseEvent) => {
const btn = e.target;
engine.Tween.removeTweens(btn);
engine.Tween.get(btn)
.to({scaleX:1,scaleY:1},200)
}, that);
});
[that._leftBtn, that._rightBtn].forEach(btn => {
btn.addEventListener(engine.MouseEvent.MOUSE_OUT, (e: engine.MouseEvent) => {
const btn = e.target;
engine.Tween.removeTweens(btn);
engine.Tween.get(btn)
.to({scaleX:1,scaleY:1},200)
}, that);
});
// this['rightBtn'];
const shapeLeft = createShape();
shapeLeft.x = that._leftBtn.width/2
shapeLeft.y = that._leftBtn.height/2
that._leftBtn.addChild(shapeLeft);
//shapeLeft.x = that._leftBtn.x;
//shapeLeft.y = that._leftBtn.y;
//that._leftBtn.mask = shapeLeft;
const shapeR = createShape();
shapeR.x = that._rightBtn.width/2
shapeR.y = that._rightBtn.height/2
that._rightBtn.addChild(shapeR);
// shapeR.x = that._rightBtn.x;
// shapeR.y = that._rightBtn.y;
// that._rightBtn.mask = shapeR;
shapeLeft.alpha = shapeR.alpha = 0;
}
import { getTextureByName } from "./utils";
const createBubblePic = (r: number) => {
const bubbleTexture: engine.Texture = getTextureByName('bubble');
const bubblePic = new engine.Sprite(bubbleTexture);
//bubblePic.anchorX = 76;
//bubblePic.anchorY = 78;
//bubblePic.anchorTexture.set(0.5,0.5)
//bubblePic.x = bubblePic.x-76
//bubblePic.y = bubblePic.y-78
bubblePic.scaleX = bubblePic.scaleY = r * 2 / 100; //默认球的尺寸100
return bubblePic;
}
export default createBubblePic
\ No newline at end of file
import LabelType from "./LabelType";
import createCoin from "./item/createCoin";
import createBoom from "./item/createBoom";
import createGift from "./item/createGift";
import createCandy from "./item/createCandy";
import createEgg from "./item/createEgg";
const createItem = (scale, type: LabelType) => {
const funcs = {
'boom': createBoom,
'gift': createGift,
'candy': createCandy,
'egg': createEgg,
'coin': createCoin
};
const func = funcs[type];
return func(scale);
}
export default createItem
\ No newline at end of file
import GameView from "./GameView";
import LabelType from "./LabelType";
import createItem from "./createItem";
import { award, awardMask } from "./collisionConfig";
import { getCurrentItems, getScore } from "./goldData";
export const createNewBubble = (_this: GameView, type: LabelType) => {
createBubble(_this, type, 750 / 2, 450, { x: 0, y: 0 },0.001*10);
}
const createBubble = (_this: GameView, type: LabelType, x: number, y: number, force = { x: 0, y: 0 }, density = 0.001) => {
let scale;
const size = random(85, 100);
const maxsize = 100;
scale = size / maxsize;
const baseItem = createItem(scale, type);
let angle;
angle = 0;
//气泡纹理种气泡的尺寸默认100(总体还包含气泡周围的阴影效果)
//刚体和贴图尺寸比为1:1.12
_this._egretRender.circle(x, y, (size - 17) / 2, baseItem,
{
frictionAir: 0,
collisionFilter: { group: award, category: award, mask: awardMask },
angle: angle,
label: baseItem.type,
friction: 0,
force: force,
density: density
});
}
const random = (start, end) => {
const n = end - start;
return Math.random() * n + start;
}
export const rollbackIcon = (nums: number, _this:GameView) => {
const startY = 370;
const startX = Math.random() > .5 ? 150 : 750 - 150;
createBubble(_this, LabelType.boom, startX, startY);
let count = 0;
const coinsFall = setInterval(() => {
if (count <= nums - 1) {
const startX = Math.random() > .5 ? 150 : 750 - 150;
createBubble(_this, LabelType.coin, startX, startY)
count++;
} else {
//结束
}
}, 100);
}
export default (_this: GameView) => {
const score = getScore();
const items = getCurrentItems();//[[LabelType.boom, 1], [LabelType.coin, 5]]
const list = [];
for (const item of items) {
const type = item[0];
let nums = item[1];
if (type == LabelType.coin)
nums = nums - score;
for (let i = 0; i < nums; i++) {
list.push(type);
}
}
let count = 0;
const countMax = 1;
const coinsFall = setInterval(() => {
if (count <= list.length - 1) {
const type = list[count];
createBubble(_this, type,375 + Math.random() * 200-100 , 400 + 200 +200)
count++;
} else {
//结束
}
}, 100);
}
\ No newline at end of file
interface dataTm {
x: number, //x,y,w,h为图集上的切图位置数据
y: number,
w: number,
h: number,
ox: number, //ox,oy为偏移数据,trim裁剪的数据,在orig上的偏移{x:0,y:0,width:200,height:200}
oy: number,
sw: number, //sw,sh为原始宽高
sh: number,
ro: boolean, //是否旋转
}
//简化后的格式
var expData = {
"actOverTitle.png": { "x": 1, "y": 1, "w": 474, "h": 172, "ox": 0, "oy": 0, "sw": 474, "sh": 172, "ro": false },
"hasActOverLotBtn.png": { "x": 1, "y": 175, "w": 259, "h": 85, "ox": 0, "oy": 0, "sw": 259, "sh": 85, "ro": false }
}
/**
*
* @param baseTexture
* @param altaData
* @return 返回贴图集。不常用
*/
export function createTextureSheet(baseTexture:engine.BaseTexture, altaData) {
var frames = altaData;
var frameKeys = Object.keys(frames);
let frameIndex = 0;
//要返回的贴图集合
var textures = {};
while (frameIndex < frameKeys.length) {
//名字
const i = frameKeys[frameIndex];
//数据
const data: dataTm = frames[i];
//切图上的数据
let frame: engine.Rectangle = null;
//裁切的数据
let trim: engine.Rectangle = null;
//贴图原始尺寸
const orig = new engine.Rectangle(
0,
0,
Math.floor(data.sw),
Math.floor(data.sh)
);
//如果旋转过
if (data.ro) {
frame = new engine.Rectangle(
Math.floor(data.x),
Math.floor(data.y),
Math.floor(data.h),
Math.floor(data.w)
);
} else {
frame = new engine.Rectangle(
Math.floor(data.x),
Math.floor(data.y),
Math.floor(data.w),
Math.floor(data.h)
);
}
//如果是被截掉过透明边界的
if (data.ox || data.oy) {
//其实就是在orig上切图,偏移
trim = new engine.Rectangle(
Math.floor(data.ox),
Math.floor(data.oy),
Math.floor(data.w),
Math.floor(data.h)
);
}
var texture = new engine.Texture(
baseTexture,
frame,
orig,
trim,
data.ro ? 2 : 0,
// data.anchor
);
//缓存下
engine.Texture.addToCache(texture, i);
textures[i] = texture;
frameIndex++;
}
return textures;
}
\ No newline at end of file
import BaseItem from "../../physics/BaseItem";
import { getJosnData, getJsonAsset } from "../JsonTools";
import { createTextureSheet } from "../createTextureSheet";
import { getTextureByName } from "../utils";
import LabelType from "../LabelType";
import MovieClip from "../../physics/MovieClip";
const createBoom = (scale) => {
//气泡纹理种气泡的尺寸默认100(总体还包含气泡周围的阴影效果)
let josnData = getJosnData('boom');
if(!josnData){
getJsonAsset('boom');
josnData = getJosnData('boom');
}
const boomTexture = createTextureSheet(getTextureByName('boom').baseTexture,josnData);
//炸弹纹理种炸弹的尺寸默认58,不进行缩放
//气泡和炸弹的比例为100/58
const animation = createMovieClip(boomTexture);
const baseItem = new BaseItem(animation, LabelType.boom);
baseItem.scaleX = baseItem.scaleY = scale;
return baseItem
}
const createMovieClip = (spritesheet, scale = 1) => {
const list = ['boom1.png', 'boom2.png', 'boom3.png', 'boom4.png', 'boom5.png', 'boom6.png', 'boom7.png', 'boom8.png', 'boom9.png', 'boom10.png'];
const movieclip = new MovieClip({
spritesheet: spritesheet,
frameInterval: 5,
frames: list,
position: [0, 0],
scale: scale,
anchor: [.5, .5]
});
return movieclip
}
export default createBoom
\ No newline at end of file
import BaseItem from "../../physics/BaseItem";
import { getJosnData, getJsonAsset } from "../JsonTools";
import { createTextureSheet } from "../createTextureSheet";
import { getTextureByName } from "../utils";
import LabelType from "../LabelType";
import MovieClip from "../../physics/MovieClip";
const createCandy = (scale) => {
//气泡纹理种气泡的尺寸默认100(总体还包含气泡周围的阴影效果)
let josnData = getJosnData('candy');
if(!josnData){
getJsonAsset('candy');
josnData = getJosnData('candy');
}
const boomTexture = createTextureSheet(getTextureByName('candy').baseTexture,josnData);
//炸弹纹理种炸弹的尺寸默认58,不进行缩放
//气泡和炸弹的比例为100/58
const animation = createMovieClip(boomTexture);
const baseItem = new BaseItem(animation, LabelType.candy);
baseItem.scaleX = baseItem.scaleY = scale;
return baseItem
}
const createMovieClip = (spritesheet, scale = 1) => {
const list = ['candy1.png', 'candy2.png', 'candy3.png', 'candy4.png', 'candy5.png', 'candy6.png', 'candy7.png', 'candy8.png'];
const movieclip = new MovieClip({
spritesheet: spritesheet,
frameInterval: 6,
frames: list,
position: [0, 0],
scale: scale,
anchor: [.5, .5]
});
return movieclip
}
export default createCandy
\ No newline at end of file
import BaseItem from "../../physics/BaseItem";
import LabelType from "../LabelType";
import MovieClip from "../../physics/MovieClip";
import { getTextureByName } from "../utils";
import { getJosnData, getJsonAsset } from "../JsonTools";
import { createTextureSheet } from "../createTextureSheet";
const createCoin = (scale) => {
//气泡纹理种气泡的尺寸默认100(总体还包含气泡周围的阴影效果)
let josnData = getJosnData('coin');
if(!josnData){
getJsonAsset('coin');
josnData = getJosnData('coin');
}
const texture = createTextureSheet(getTextureByName('coin').baseTexture,josnData);
const animation = createMovieClip(texture, 0.6);
const baseItem = new BaseItem(animation,LabelType.coin);
baseItem.scaleX = baseItem.scaleY = scale;
return baseItem
}
const createMovieClip = (spritesheet, scale = 1) => {
const list = ['coin1.png', 'coin2.png', 'coin3.png', 'coin4.png', 'coin5.png', 'coin6.png', 'coin7.png', 'coin8.png'];
const movieclip = new MovieClip({
spritesheet: spritesheet,
frameInterval: 6,
frames: list,
position: [0, 0],
scale: scale,
anchor: [.5, .5]
});
return movieclip
}
export default createCoin
\ No newline at end of file
import BaseItem from "../../physics/BaseItem";
import LabelType from "../LabelType";
import MovieClip from "../../physics/MovieClip";
import { getTextureByName } from "../utils";
import { getJosnData, getJsonAsset } from "../JsonTools";
import { createTextureSheet } from "../createTextureSheet";
const createEgg = (scale) => {
//气泡纹理种气泡的尺寸默认100(总体还包含气泡周围的阴影效果)
let josnData = getJosnData('egg');
if(!josnData){
getJsonAsset('gift');
josnData = getJosnData('egg');
}
const texture = createTextureSheet(getTextureByName('egg').baseTexture,josnData);
const animation = createMovieClip(texture, 0.6);
const baseItem = new BaseItem(animation,LabelType.egg);
baseItem.scaleX = baseItem.scaleY = scale;
return baseItem
}
const createMovieClip = (spritesheet, scale = 1) => {
const list = ['egg1.png', 'egg2.png', 'egg3.png', 'egg4.png', 'egg5.png', 'egg6.png', 'egg7.png', 'egg8.png', 'egg9.png'];
const movieclip = new MovieClip({
spritesheet: spritesheet,
frameInterval: 5,
frames: list,
position: [0, 0],
scale: scale,
anchor: [.5, .5]
});
return movieclip
}
export default createEgg
\ No newline at end of file
import BaseItem from "../../physics/BaseItem";
import LabelType from "../LabelType";
import MovieClip from "../../physics/MovieClip";
import { getTextureByName } from "../utils";
import { getJosnData, getJsonAsset } from "../JsonTools";
import { createTextureSheet } from "../createTextureSheet";
const createGift = (scale) => {
//气泡纹理种气泡的尺寸默认100(总体还包含气泡周围的阴影效果)
let josnData = getJosnData('gift');
if(!josnData){
getJsonAsset('gift');
josnData = getJosnData('gift');
}
const texture = createTextureSheet(getTextureByName('gift').baseTexture,josnData);
const animation = createMovieClip(texture, 0.6);
const baseItem = new BaseItem(animation,LabelType.gift);
baseItem.scaleX = baseItem.scaleY = scale;
return baseItem
}
const createMovieClip = (spritesheet, scale = 1) => {
const list = ['gift1.png', 'gift2.png', 'gift3.png', 'gift4.png', 'gift5.png', 'gift6.png', 'gift7.png', 'gift8.png', 'gift9.png', 'gift10.png'];
const movieclip = new MovieClip({
spritesheet: spritesheet,
frameInterval: 5,
frames: list,
position: [0, 0],
scale: scale,
anchor: [.5, .5]
});
return movieclip
}
export default createGift
\ No newline at end of file
/**
* Created by rockyl on 2020-02-03.
*/
// import ObjectPool = engine.ObjectPool;
// export const PoolName: string = 'goods';
// ObjectPool.registerPool(PoolName, function () {
// return new Goods();
// }, function (item: Goods, data) {
// item.reset();
// });
import MovieClip from "../physics/MovieClip";
import wait from "./wait";
import { getJosnData, getJsonAsset } from "./JsonTools";
import { createTextureSheet } from "./createTextureSheet";
import { getTextureByName } from "./utils";
export async function playMovieClip (parent: engine.Container, key, frames, frameInterval = 5){
return new Promise(async (r) => {
let josnData = getJosnData(key);
if(!josnData){
getJsonAsset(key);
josnData = getJosnData(key);
}
let texture = createTextureSheet(getTextureByName(key).baseTexture,josnData);
if (texture) {
await createMc(parent, texture, frames, frameInterval);
r(1);
}
else {
//RES.getResAsync(key);
wait(300).then(async () => {
let josnData = getJosnData(key);
if(!josnData){
getJsonAsset(key);
josnData = getJosnData(key);
}
texture = createTextureSheet(getTextureByName(key).baseTexture,josnData);
if (texture) {
await createMc(parent, texture, frames, frameInterval);
r(1);
} else
r(0);
})
}
});
}
export function createMc(parent: engine.Container, spritesheet, frames: any[], frameInterval = 5) {
return new Promise((r) => {
const movieclip = new MovieClip({
spritesheet: spritesheet,
frameInterval: frameInterval,
frames: frames,
position: [0, 150],
scale: 1,
anchor: [0, 0],
loop: false,
callBack:()=>{
setTimeout(() => {
parent.removeChild(movieclip);
r(1)
}, 100);
}
});
parent.addChild(movieclip);
// setTimeout(() => {
// parent.removeChild(movieclip);
// r(1)
// }, 1000);
// movieclip.once('boomOver', () => {
// parent.removeChild(movieclip);
// r(1)
// }, this,true)
})
}
export const playBoom = (parent) => {
return playMovieClip(parent, 'fail', ['fail1.png', 'fail2.png', 'fail3.png', 'fail4.png', 'fail5.png', 'fail6.png', 'fail7.png', 'fail8.png'], 5);
}
export const playSuccess = (parent) => {
return playMovieClip(parent, 'success', ['success1.png', 'success2.png', 'success3.png', 'success4.png', 'success5.png', 'success6.png', 'success7.png', 'success8.png', 'success9.png'], 5);
}
\ No newline at end of file
const clear = (that) => {
TextList.forEach(i => {
engine.Tween.removeTweens(that.gameHint[i]);
that.gameHint[i].alpha = 0;
})
}
const playgood = (image: engine.Image) => {
engine.Tween.get(image).set({ x: 750, alpha: 1 }).to({ x: 530.5 }, 100).wait(500).to({ alpha: 0 }, 200)
}
const playgreat = (image: engine.Image) => {
engine.Tween.get(image).set({ x: 750, alpha: 1, scaleX: .9, scaleY: .9, rotation: 20 }).to({ x: 540.5, scaleX: 1, scaleY: 1, rotation: 0 }, 200, engine.Ease.getBackOut(2)).wait(500).to({ alpha: 0 }, 200)
}
const playcool = (image: engine.Image) => {
engine.Tween.get(image).set({ x: 750, alpha: 1, scaleX: .9, scaleY: .9, rotation: 60 }).to({ x: 526.09, scaleX: 1, scaleY: 1, rotation: 0 }, 200, engine.Ease.getBackOut(7)).wait(500).to({ alpha: 0 }, 200)
}
const playperfect = (image: engine.Image) => {
engine.Tween.get(image).set({ scaleX: 0, scaleY: 0, alpha: 1, }).to({ scaleX: 1, scaleY: 1 }, 200, engine.Ease.getBackOut(10)).wait(500).to({ alpha: 0 }, 200)
// egret.Tween.get(image).set({ x: 750, alpha: 1 }).to({ x: 530.5 }, 100).wait(500).to({ alpha: 0 }, 200)
}
const playawesome = (image: engine.Image) => {
engine.Tween.get(image).set({ scaleX: 0, scaleY: 0, alpha: 1, rotation: -20 }).to({ scaleX: 1, scaleY: 1, rotation: 0 }, 200, engine.Ease.getBackOut(20)).wait(500).to({ alpha: 0 }, 200)
// egret.Tween.get(image).set({ x: 750, alpha: 1 }).to({ x: 527 }, 100).wait(500).to({ alpha: 0 }, 200)
}
const playunbelievable = (image: engine.Image) => {
// egret.Tween.get(image).set({ x: 750, alpha: 1 }).to({ x: 482.5 }, 100).wait(500).to({ alpha: 0 }, 200)
engine.Tween.get(image).set({ scaleX: 0, scaleY: 0, alpha: 1, rotation: -60 }).to({ scaleX: 1, scaleY: 1, rotation: 0 }, 200, engine.Ease.getBackOut(40)).wait(500).to({ alpha: 0 }, 200)
}
const funcs = [playgreat, playcool, playperfect, playawesome, playunbelievable];
// const funcs = [playgood, playgreat, playcool, playperfect, playawesome, playunbelievable];
let cdtimer;
// let timer = 0;
let count = 0;
export const playTextAni = async (that) => {
clear(that);
count++;
if (count >= TextList.length) count = TextList.length;
console.log(count);
const image = that.gameHint[TextList[count - 1]];
image.visible = true;
funcs[count - 1](image);
if (cdtimer > 0) clearTimeout(cdtimer);
cdtimer = setTimeout(() => {
count = 0;
console.log('clear')
}, 5000);
}
export const TextList = ['great', 'cool', 'perfect', 'awesome', 'unbelievable']
// export const TextList = ['good', 'great', 'cool', 'perfect', 'awesome', 'unbelievable']
\ No newline at end of file
import { bubbleStandbyGroup, bubbleStandby, bubbleStandbyMask } from "./collisionConfig";
import createBubblePic from "./createBubblePic";
import EgretRender from "../physics/EgretRender";
let timerLeft;
let timerRight;
export const startStandbyBubblesLeft = (egretRender: EgretRender) => {
timerLeft = setInterval(() => {
const scale = 0.2;
const p1 = { x: 180, y: 1050 };
const r = random(8, 10);
const bubblePic = createBubblePic(r);
const body = egretRender.circle(p1.x, p1.y, r, bubblePic, {
restitution: 0,
frictionAir: 0,
force: { x: random(-0.005, 0.005) * scale, y: -0.02 * scale },
collisionFilter: { group: bubbleStandbyGroup, category: bubbleStandby, mask: bubbleStandbyMask }
});
setTimeout(() => {
egretRender.remove(body);
}, 1000);
}, 700);
}
export const startStandbyBubblesRight = (egretRender: EgretRender) => {
timerRight = setInterval(() => {
const scale = 0.2;
const p2 = { x: 560, y: 1050 };
const r2 = random(8, 10);
const bubblePic2 = createBubblePic(r2);
const body2 = egretRender.circle(p2.x, p2.y, r2, bubblePic2, {
restitution: 0,
frictionAir: 0,
force: { x: random(-0.005, 0.005) * scale, y: -0.02 * scale },
collisionFilter: { group: bubbleStandbyGroup, category: bubbleStandby, mask: bubbleStandbyMask }
});
setTimeout(() => {
egretRender.remove(body2);
}, 1000);
}, 700);
}
export const stopStandbyBubblesLeft = () => {
clearInterval(timerLeft)
}
export const stopStandbyBubblesRight = () => {
clearInterval(timerRight)
}
const random = (start, end) => {
const n = end - start;
return Math.random() * n + start;
}
\ No newline at end of file
/**
* Created by rockyl on 2020-01-21.
*/
import {props} from '../props'
export function getTexture(uuid) {
return engine.Texture.from(getAssetByUUID(uuid).uuid);
}
export function getTextureByName(name) {
return getTexture(engine.getAssetByName(name).uuid);
}
export function playSound(name) {
engine.playSound(engine.getAssetByName(name).uuid, { keep: true });
}
export function createSvga(name, anchorName?) {
let inst = new svga.Svga();
inst.source = "asset://" + engine.getAssetByName(name).uuid;
return inst;
}
export function getIndexFromRC(row, col, maxCol) {
let index;
index = row * maxCol + col;
return index;
}
export function getRandomArray(array) {
array.sort(function () {
return 0.5 - Math.random();
});
}
export default (view: engine.DisplayObject,count=2,strength=10) => {
return new Promise((r) => {
const pos = [
{ x: strength, y: 0 },
{ x: 0, y: -strength },
{ x: -strength, y: 0 },
{ x: 0, y: strength },
{ x: 0, y: 0 },
];
let list = [];
for (let i = 0; i < count; i++) {
list = list.concat(pos);
}
const x0 = view.x;
const y0 = view.y;
let counter = list.length;
for (let i = 0; i < list.length; i++) {
const element = list[i];
setTimeout(() => {
view.x = element.x + x0;
view.y = element.y + y0;
counter--;
if (counter == 0) {
view.x = x0;
view.y = y0;
r();
};
}, 1000 / 60 * i);
}
});
}
const wait = async (duration: number) =>
new Promise(
resolve => setTimeout(resolve, duration)
);
export default wait
\ No newline at end of file
/**
* Created by rockyl on 2019-11-20.
*/
import {GameWrapper} from "./game/GameWrapper";
import {injectProps, prepareProps} from "./props";
export default function (props) {
prepareProps();
injectProps(props);
let instance = new GameWrapper();
return instance;
}
{
"coin1.png": {
"x": 111,
"y": 113,
"w": 109,
"h": 110,
"ox": 3,
"oy": 2,
"sw": 115,
"sh": 115,
"ro": false
},
"coin2.png": {
"x": 111,
"y": 0,
"w": 109,
"h": 111,
"ox": 3,
"oy": 2,
"sw": 115,
"sh": 115,
"ro": false
},
"coin3.png": {
"x": 96,
"y": 225,
"w": 94,
"h": 113,
"ox": 10,
"oy": 1,
"sw": 115,
"sh": 115,
"ro": false
},
"coin4.png": {
"x": 67,
"y": 340,
"w": 65,
"h": 113,
"ox": 25,
"oy": 1,
"sw": 115,
"sh": 115,
"ro": false
},
"coin5.png": {
"x": 222,
"y": 0,
"w": 24,
"h": 108,
"ox": 45,
"oy": 3,
"sw": 115,
"sh": 115,
"ro": false
},
"coin6.png": {
"x": 0,
"y": 229,
"w": 65,
"h": 114,
"ox": 25,
"oy": 0,
"sw": 115,
"sh": 115,
"ro": false
},
"coin7.png": {
"x": 0,
"y": 114,
"w": 94,
"h": 113,
"ox": 10,
"oy": 1,
"sw": 115,
"sh": 115,
"ro": false
},
"coin8.png": {
"x": 0,
"y": 0,
"w": 109,
"h": 112,
"ox": 3,
"oy": 1,
"sw": 115,
"sh": 115,
"ro": false
}
}
\ No newline at end of file
import { getTextureByName } from "../game/utils";
import LabelType from "../game/LabelType";
import MovieClip from "./MovieClip";
export default class BaseItem extends engine.Sprite {
_mc: MovieClip;
type: LabelType;
constructor(mc: MovieClip, type?: LabelType) {
super();
this.type = type;
this._mc = mc;
const bubble: engine.Texture = getTextureByName('bubble');
const bubblePic = new engine.Sprite(bubble);
bubblePic.anchorTexture.set(0.5,0.5);
//bubblePic.anchorX = 76;
//bubblePic.anchorY = 78;
//bubblePic.x = bubblePic.x-76
//bubblePic.y = bubblePic.y-78
this._mc.anchorTexture.set(0.5,0.5)
this._mc.x = bubblePic.x/4;
this._mc.y = bubblePic.y/4;
this.addChild(bubblePic);
this.addChild(this._mc);
}
get mc() { return this._mc; }
}
\ No newline at end of file
import BaseItem from "./BaseItem";
export default class EgretRender {
_root: engine.Sprite;
private _engine: Matter.Engine;
constructor(root: engine.Sprite, engine: Matter.Engine) {
this._root = root;
this._engine = engine;
}
addBody(body: Matter.Body, display: engine.DisplayObject, x, y) {
if (display) {
body['display'] = display;
this._root.addChildAt(display, 0);
display.x = x;
display.y = y;
}
return body;
}
remove(body: Matter.Body): any {
this.removeBody(body);
this.removeDisplay(body);
}
removeBody(body: Matter.Body): any {
Matter.World.remove(this._engine.world, body);
}
removeDisplay(body: Matter.Body): any {
const display: engine.DisplayObject = body['display'];
if (display && display.parent)
display.parent.removeChild(display);
}
run() {
const bodies = Matter.Composite.allBodies(this._engine.world);
// tslint:disable-next-line:prefer-for-of
for (let i = 0; i < bodies.length; i++) {
const body = bodies[i];
const display = body['display'] as engine.DisplayObject;
if (!display) continue;
// 贴图与刚体位置的小数点后几位有点不一样,需要降低精度
const x1 = Math.round(display.x)
const x2 = Math.round(body.position.x)
const y1 = Math.round(display.y)
const y2 = Math.round(body.position.y)
const distanceX = Math.abs(x1 - x2);
const distanceY = Math.abs(y1 - y2);
const precision = 1;//精度
if (distanceX > precision || distanceY > precision) {
if (display instanceof BaseItem) display.mc.resume();
} else {
if (display instanceof BaseItem) display.mc.pause();
}
display.x = body.position.x;
display.y = body.position.y;
display.rotation = this.getRotation(body.angle);
}
}
//快速方法
rectangle(x: number, y: number, width: number, height: number, display: engine.DisplayObject, options?: Matter.IChamferableBodyDefinition) {
const body = this.rectangleToRender(x, y, width, height, display, options);
this.addBodyToWorld(body);
return body;
}
circle(x: number, y: number, radius: number, display: engine.DisplayObject, options?: Matter.IChamferableBodyDefinition) {
const body = this.circleToRender(x, y, radius, display, options);
this.addBodyToWorld(body);
return body;
}
//工具方法
private addBodyToWorld(body: Matter.Body) {
Matter.World.add(this._engine.world, body);
return body;
}
private rectangleToRender(x: number, y: number, width: number, height: number, display: engine.DisplayObject, options?: Matter.IChamferableBodyDefinition) {
const body = Matter.Bodies.rectangle(x, y, width, height, options);
this.addBody(body, display, x, y);
return body;
}
private circleToRender(x: number, y: number, radius: number, display: engine.DisplayObject, options?: Matter.IChamferableBodyDefinition) {
const body = Matter.Bodies.circle(x, y, radius, options);
this.addBody(body, display, x, y);
return body;
}
private getRotation(angle: number) {
return angle / Math.PI / 2 * 360;
}
}
\ No newline at end of file
export default class MovieClip extends engine.Image {
textures: engine.Texture[];
frames: string[];
keys: string[];
autoplay: boolean;
loop: boolean;
anchorXtmp: number;
anchorYtmp: number;
currentFrame: number;
frameInterval: number;
counter: number;
scale: number;
_callBack:any;
constructor({ spritesheet, frames, scale, position, keys = null, autoplay = true, loop = true, anchor, frameInterval = 1 ,callBack=null}) {
super();
this.frames = frames;
this.frameInterval = frameInterval;
this.keys = keys;
this.autoplay = autoplay;
this.loop = loop;
this.anchorXtmp = anchor;
this.anchorYtmp = anchor;
this._callBack = callBack;
if (Array.isArray(anchor)) {
this.anchorXtmp = anchor[0];
this.anchorYtmp = anchor[1];
}
this.x = position[0];
this.y = position[1];
this.spritesheet = spritesheet;
if (this.autoplay) {
this.play();
}
this.scaleX = this.scaleY = scale;
}
pause() {
//egret.stopTick(this.onTick, this);
this.removeEventListener(engine.Event.ENTER_FRAME, this.onTick, this)
}
resume() {
//egret.startTick(this.onTick, this);
this.addEventListener(engine.Event.ENTER_FRAME, this.onTick, this)
}
play(start = 0) {
this.goto(start);
this.currentFrame = 0;
this.counter = 0;
//egret.startTick(this.onTick, this);
this.addEventListener(engine.Event.ENTER_FRAME, this.onTick, this)
}
goto(frame: number) {
this.texture = this.textures[frame];
}
onTick() {
this.counter++;
if (this.counter == this.frameInterval) {
this.counter = 0;
this.currentFrame++;
this.goto(this.currentFrame);
if (this.currentFrame == this.frames.length - 1) {
if (this.loop) {
this.currentFrame = 0;
} else {
this.stop();
//true
if(this._callBack){
this._callBack();
this._callBack = null
}
//this.dispatchEvent('boomOver',null,true)
}
}
}
return false;
}
stop() {
this.currentFrame = 0;
this.removeEventListener(engine.Event.ENTER_FRAME, this.onTick, this)
//egret.stopTick(this.onTick, this);
}
set spritesheet(value) {
//this.frames.map(frame => value.getTexture(frame));
this.textures = this.frames.map(frame => value[frame]);
this.anchorTexture.set(this.anchorXtmp,this.anchorYtmp)
}
private get textureItemWidth() { return this.textures[0].width }
private get textureItemHeight() { return this.textures[0].height }
}
\ No newline at end of file
/**
* Created by rockyl on 2020-01-21.
*/
export let props: any = {};
export function prepareProps() {
let metaProps = getProps();
engine.injectProp(props, metaProps);
}
export function injectProps(p) {
engine.injectProp(props, p);
}
var fs = require("fs");
var readPath = "./src/json/";
var writePath = "./src/json/"
//取指令后的参数
let arg = process.argv.splice(2);
//json名字
var jsonName = arg[0];
var data = fs.readFileSync(readPath + jsonName + ".json");
//反序列化
data = JSON.parse(data);
let frames = data.frames;
var obj = {};
for (var key in frames) {
let f = frames[key];
obj[jsonName + key + ".png"] = {
"x": f.x,
"y": f.y,
"w": f.w,
"h": f.h,
"ox": f.offX,
"oy": f.offY,
"sw": f.sourceW,
"sh": f.sourceH,
"ro": false,
}
}
//写入
fs.writeFileSync(writePath + jsonName + ".json", JSON.stringify(obj, "", "\t"));
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
}, },
"include": [ "include": [
"libs", "libs",
"src" "src", "src/custom/seabed-game/debug/matter.min.js"
], ],
"exclude": [ "exclude": [
"node_modules" "node_modules"
......
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