Commit f3ed9fcd authored by lujinlei's avatar lujinlei

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

parents cc65c4f8 a5553149
This diff is collapsed.
{
"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"
}
This diff is collapsed.
/**
* 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('game-start', {
picUrl: "http://yun.duiba.com.cn/aurora/assets/e1593b97c27077b85b92f7eaaeae1ed64a1eb79a.png",
blockUrl: "888",
column:"2",
row:"2",
gameTime:"50"
});
const d = 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 GameTest = (function (_super) {
tslib.__extends(GameTest, _super);
function GameTest() {
var _this = _super.call(this) || this;
_this.isDebug = true;
_this.factor = 10;
_this.isRight = false;
_this.saleX = _this.isRight ? 1 : -1;
_this.ballAddSpeedX = -10;
_this.ballAddSpeedY = 30;
_this.addEventListener(engine.Event.ADDED_TO_STAGE, _this.setup, _this);
return _this;
}
GameTest.prototype.start = function () {
console.log("starting");
this.stage.addEventListener(engine.MouseEvent.CLICK, this.clickball, this);
};
GameTest.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() > 0.5) {
var boxShape = new p2.Box({
width: 200 / factor,
height: 100 / factor,
});
var boxBody = new p2.Body({
mass: 1,
position: [positionX, positionY],
angularVelocity: 1,
});
boxBody.addShape(boxShape);
world.addBody(boxBody);
{
display = this.createBox(boxShape.width * factor, boxShape.height * factor);
}
}
else {
var boxShape = new p2.Circle({
radius: 60 / factor,
});
var boxBody = new p2.Body({
mass: 1,
position: [positionX, positionY],
});
boxBody.addShape(boxShape);
world.addBody(boxBody);
{
display = this.createBitmapByName("篮球");
}
}
boxBody.displays = [display];
this.addChild(display);
};
GameTest.prototype.setup = function () {
console.log("setup");
var world = new p2.World({});
world.sleepMode = p2.World.BODY_SLEEPING;
world.defaultContactMaterial.friction = 0.3;
world.defaultContactMaterial.restitution = 0.7;
var planeShape = new p2.Plane();
var planeBody = new p2.Body({
type: p2.Body.STATIC
});
planeBody.addShape(planeShape);
planeBody.displays = [];
world.addBody(planeBody);
this.world = world;
this.stage.addEventListener(engine.Event.ENTER_FRAME, this.onEnterFrame, this);
var gameBg = new engine.Sprite(getTextureByName("背景"));
this.addChild(gameBg);
var boardShape = new p2.Box({
width: 20 / this.factor,
height: 200 / this.factor
});
var boardBody = new p2.Body({
position: [80 / this.factor, 1000 / this.factor]
});
boardBody.addShape(boardShape);
var board = this.createBitmapByName('篮板');
this.addChild(board);
boardBody.displays = [board];
this.world.addBody(boardBody);
var boardPoint = new p2.Circle({
radius: 1 / this.factor,
});
var boardPointBody = new p2.Body({
position: [100 / this.factor,]
});
var boxShape = new p2.Circle({ radius: 60 / this.factor });
this.boxBody = new p2.Body({
mass: 0.1,
position: [300 / this.factor, 900 / this.factor],
velocity: [-5, -10],
angularVelocity: -1
});
var balldisplay = this.createBitmapByName("篮球");
this.addChild(balldisplay);
this.boxBody.displays = [balldisplay];
this.boxBody.addShape(boxShape);
this.world.addBody(this.boxBody);
};
GameTest.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];
var stageHeight = engine.gameStage.stage.height;
if (display) {
display.x = body.position[0] * this.factor;
display.y = stageHeight - body.position[1] * this.factor;
display.rotation =
((body.angle + body.shapes[0].angle) * 180) / Math.PI;
if (body.sleepState == p2.Body.SLEEPING) {
display.alpha = 0.5;
}
else {
display.alpha = 1;
}
}
}
if (this.boxBody.position[0] < -120 / this.factor) {
this.boxBody.position[0] = (750 + 120) / this.factor;
}
if (this.boxBody.position[0] > (750 + 120) / this.factor) {
this.boxBody.position[0] = -120 / this.factor;
}
};
GameTest.prototype.clickball = function () {
var direction = this.isRight ? -1 : 1;
this.boxBody.velocity[0] = this.ballAddSpeedX * direction;
this.boxBody.velocity[1] = this.ballAddSpeedY;
this.boxBody.angularVelocity = -2 * direction;
};
GameTest.prototype.createPlane = function (x, y, w, h) {
var sp = new engine.Shape();
sp.beginFill(0x0000ff, 1);
sp.drawRect(x, y, w, h);
sp.endFill();
this.addChild(sp);
return sp;
};
GameTest.prototype.createBall = function (r) {
var sp = new engine.Shape();
sp.beginFill(0xff0000, 0.4);
sp.drawCircle(0, 0, r);
sp.endFill();
return sp;
};
GameTest.prototype.createBox = function (width, height) {
var sp = new engine.Shape();
sp.beginFill(0xf0f0f0, 1);
sp.drawRect(-width / 2, -height / 2, width, height);
sp.endFill();
return sp;
};
GameTest.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;
};
GameTest.prototype.stop = function () { };
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('game-start', _this.start, _this);
engine.globalEvent.addEventListener('game-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
This diff is collapsed.
/**
* 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";
export default class GameTest extends engine.Container {
world: p2.World;
planeBody: p2.Body;
isDebug = true;
private plane;
private boxBody: p2.Body;
factor = 10;
private isRight = false;
private saleX = this.isRight ? 1 : -1;
private ballAddSpeedX = -10;
private ballAddSpeedY = 30;
constructor() {
super();
this.addEventListener(engine.Event.ADDED_TO_STAGE, this.setup, this);
}
start() {
console.log("starting");
// this.stage.addEventListener(
// engine.MouseEvent.CLICK,
// this.onClick,
// this
// );
this.stage.addEventListener(
engine.MouseEvent.CLICK,
this.clickball,
this
);
}
onClick(e: engine.MouseEvent) {
const { world, factor } = this;
var positionX: number = e.stageX / factor;
var positionY: number =
(engine.gameStage.stage.height - e.stageY) / factor;
var display: engine.DisplayObject;
var self = this;
if (Math.random() > 0.5) {
//添加方形刚体
var boxShape: p2.Shape = new p2.Box({
width: 200 / factor,
height: 100 / factor,
});
var boxBody: p2.Body = new p2.Body({
mass: 1,
position: [positionX, positionY],
angularVelocity: 1,
});
boxBody.addShape(boxShape);
world.addBody(boxBody);
// if (this.isDebug) {
if (true) {
display = this.createBox(
(<p2.Box>boxShape).width * factor,
(<p2.Box>boxShape).height * factor
);
} else {
// display = self.createBitmapByName("rect");
// display.width = (<p2.Box>boxShape).width * factor;
// display.height = (<p2.Box>boxShape).height * factor;
}
} else {
//添加圆形刚体
var boxShape: p2.Shape = new p2.Circle({
radius: 60 / factor,
});
var boxBody: p2.Body = new p2.Body({
mass: 1,
position: [positionX, positionY],
});
boxBody.addShape(boxShape);
world.addBody(boxBody);
// if (this.isDebug) {
if (false) {
display = this.createBall(
(<p2.Circle>boxShape).radius * factor
);
} else {
display = this.createBitmapByName("篮球");
// display.width = (<p2.Circle>boxShape).radius * 2 * this.factor;
// display.height = (<p2.Circle>boxShape).radius * 2 * this.factor;
}
// 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() {
// // 创建地平面
// var plane: p2.Plane = new p2.Plane();
// this.planeBody = new p2.Body({
// position: [0, 100 / this.factor],
// type:p2.Body.STATIC
// });
// // this.planeBody.angle = Math.PI;
// this.planeBody.addShape(plane);
// this.world.addBody(this.planeBody);
// this.plane = this.createPlane(
// 0,
// 100,
// engine.gameStage.width,
// 20
// );
// this.planeBody.displays = [this.plane];
console.log("setup");
//创建world
var world: p2.World = new p2.World({
// gravity: [0, -1],
});
world.sleepMode = p2.World.BODY_SLEEPING;
world.defaultContactMaterial.friction = 0.3;
world.defaultContactMaterial.restitution = 0.7;
//创建plane
var planeShape: p2.Plane = new p2.Plane();
var planeBody: p2.Body = new p2.Body({
type:p2.Body.STATIC
});
planeBody.addShape(planeShape);
planeBody.displays = [];
world.addBody(planeBody);
this.world = world;
this.stage.addEventListener(
engine.Event.ENTER_FRAME,
this.onEnterFrame,
this
);
var display: engine.DisplayObject;
// 背景
let gameBg = new engine.Sprite(getTextureByName("背景"));
this.addChild(gameBg);
// 篮板
var boardShape:p2.Shape = new p2.Box({
width:20/this.factor,
height:200/this.factor
});
var boardBody = new p2.Body({
position:[80/this.factor,1000/this.factor]
})
boardBody.addShape(boardShape);
let board = this.createBitmapByName('篮板');
this.addChild(board)
boardBody.displays = [board];
this.world.addBody(boardBody)
// 框点
var boardPoint:p2.Shape = new p2.Circle({
radius:1/this.factor,
})
var boardPointBody:p2.Body = new p2.Body({
position:[100/this.factor,800/this.factor]
})
boardPointBody.addShape(boardPoint);
boardPointBody.displays = []
// 篮球
var boxShape: p2.Shape = new p2.Circle({radius: 60 / this.factor});
this.boxBody = new p2.Body({
mass: 0.1,
position: [300/this.factor, 900/this.factor],
velocity:[-5,-10],
angularVelocity:-1
});
let balldisplay = this.createBitmapByName("篮球");
this.addChild(balldisplay)
this.boxBody.displays = [balldisplay]
this.boxBody.addShape(boxShape);
this.world.addBody(this.boxBody);
}
onEnterFrame() {
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];
const stageHeight = engine.gameStage.stage.height;
if (display) {
display.x = body.position[0] * this.factor; //同步刚体和egret显示对象的位置和旋转角度
display.y = stageHeight - body.position[1] * this.factor;
display.rotation =
((body.angle + body.shapes[0].angle) * 180) / Math.PI;
if (body.sleepState == p2.Body.SLEEPING) {
display.alpha = 0.5;
} else {
display.alpha = 1;
}
}
// display.rotation = (body.angle * 180) / Math.PI;
}
if(this.boxBody.position[0] < -120/this.factor){
this.boxBody.position[0] = (750 + 120) / this.factor;
}
if(this.boxBody.position[0] > (750 +120) / this.factor){
this.boxBody.position[0] = -120 /this.factor
}
}
clickball(){
var direction = this.isRight ? -1 : 1;
this.boxBody.velocity[0] = this.ballAddSpeedX * direction;
this.boxBody.velocity[1] = this.ballAddSpeedY;
this.boxBody.angularVelocity = -2 * direction;
}
private createPlane(x, y, w, h) {
var sp = new engine.Shape();
sp.beginFill(0x0000ff, 1);
sp.drawRect(x, y, w, h);
sp.endFill();
// sp.anchorX = sp.width / 2;
// sp.anchorY = sp.height / 2;
this.addChild(sp);
return sp;
}
private createBall(r) {
var sp = new engine.Shape();
sp.beginFill(0xff0000, 0.4);
sp.drawCircle(0, 0, r);
sp.endFill();
// this.addChild(sp);
return sp;
}
private createBox(width, height) {
var sp = new engine.Shape();
sp.beginFill(0xf0f0f0, 1);
sp.drawRect(-width / 2, -height / 2, width, height);
sp.endFill();
// sp.anchorX = w / 2;
// sp.anchorY = h / 2;
return sp;
}
// 图片的中心点位置
private 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;
}
stop() {}
}
This diff is collapsed.
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('game-start', this.start, this);
engine.globalEvent.addEventListener('game-stop', this.stop, this);
//创建实例
// let gameView = this._gameView = new GameView();
// this.addChild(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();
}
// reset(event:engine.Event){
// this._gameView.reset();
// }
}
export class Particle {
public view;
private x;
private y;
private vx;
private vy;
private life;
private maxLife;
public dieMark = false;
public gravity = 1;
public alphaSpeed = 0.01
public scaleSpeed = 0;
constructor(x, y, vx, vy, maxLife, view) {
this.x = x;
this.y = y;
this.vx = vx;
this.vy = vy;
this.life = 0;
this.maxLife = maxLife;
this.view = view;
// this.view.alpha=this.randomT(0.5,1)
}
public update() {
if (this.dieMark) return
this.x += this.vx;
this.y += this.vy;
this.vy += this.gravity;
this.life++;
if (this.life >= this.maxLife) {
this.dieMark = true;
}
this.view.x = this.x;
this.view.y = this.y;
if (this.view.alpha > 0) this.view.alpha -= this.alphaSpeed;
if (this.view.scaleX > 0.2) {
this.view.scaleX -= this.scaleSpeed;
this.view.scaleY -= this.scaleSpeed;
}
};
public init(x, y, vx, vy, maxLife) {
this.dieMark = false;
this.life = 0;
// this.view.alpha=this.randomT(0.5,1);
this.x = x;
this.y = y;
this.vx = vx;
this.vy = vy;
this.maxLife = maxLife;
}
private randomT(e, n?) {
return e && "number" == typeof e.length && e.length ? e[Math.floor(Math.random() * e.length)] : ("number" != typeof n && (n = e || 1, e = 0), e + Math.random() * (n - e))
}
}
\ 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;
}
This diff is collapsed.
export let props: any = {};
export function prepareProps() {
let metaProps = getProps();
engine.injectProp(props, metaProps);
}
export function injectProps(p) {
engine.injectProp(props, p);
}
...@@ -46,6 +46,9 @@ function launchWithCustomModule(customModule) { ...@@ -46,6 +46,9 @@ function launchWithCustomModule(customModule) {
}, 100); }, 100);
setTimeout(() => { setTimeout(() => {
engine.globalEvent.dispatchEvent('cloud-game-reset', {
});
engine.globalEvent.dispatchEvent('pictures-start', { engine.globalEvent.dispatchEvent('pictures-start', {
}); });
...@@ -55,6 +58,15 @@ function launchWithCustomModule(customModule) { ...@@ -55,6 +58,15 @@ function launchWithCustomModule(customModule) {
// engine.gameStage.sceneContainer.getChildAt(0).y = (d.stage.height-props.H)/2; // engine.gameStage.sceneContainer.getChildAt(0).y = (d.stage.height-props.H)/2;
}, 1000); }, 1000);
setTimeout(() => {
engine.globalEvent.dispatchEvent('cloud-game-reset', {
});
engine.globalEvent.dispatchEvent('pictures-start', {
});
}, 20*1000);
// setTimeout(() => { // setTimeout(() => {
// 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",
...@@ -73,6 +85,9 @@ function launchWithCustomModule(customModule) { ...@@ -73,6 +85,9 @@ function launchWithCustomModule(customModule) {
engine.globalEvent.addEventListener('cloud-game-success', (e) => { engine.globalEvent.addEventListener('cloud-game-success', (e) => {
console.log(e.type, e.data); console.log(e.type, e.data);
}); });
engine.globalEvent.addEventListener('cloud-game-reset', (e) => {
console.log(e.type, e.data);
});
} }
function getAssetByUUID(uuid) { function getAssetByUUID(uuid) {
......
This diff is collapsed.
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
"GAME_TIME": { "GAME_TIME": {
"alias": "游戏时间", "alias": "游戏时间",
"type": "number", "type": "number",
"default": 30 "default": 20
}, },
"moistPercent": { "moistPercent": {
"alias": "湿润度", "alias": "湿润度",
...@@ -43,6 +43,12 @@ ...@@ -43,6 +43,12 @@
"uuid":"ed0e8931-2557-4527-bcfc-9071f90d5737", "uuid":"ed0e8931-2557-4527-bcfc-9071f90d5737",
"ext":".png" "ext":".png"
}, },
{
"name":"湿润度动效处理",
"url":"//yun.duiba.com.cn/aurora/assets/d02e290b34ca4b3254f705bd04f02d231003f05d.png",
"uuid":"9be94bf5-5dd9-470b-a251-705d9c0ff1b0",
"ext":".png"
},
{ {
"name":"wind", "name":"wind",
"url":"//yun.duiba.com.cn/aurora/assets/15fc1dabf22baedd8bf5e5b418e57cfc81686072.svga", "url":"//yun.duiba.com.cn/aurora/assets/15fc1dabf22baedd8bf5e5b418e57cfc81686072.svga",
...@@ -57,9 +63,9 @@ ...@@ -57,9 +63,9 @@
}, },
{ {
"name":"背景", "name":"背景",
"url":"//yun.duiba.com.cn/aurora/assets/d0e22ae58b6e8519b969ed207197a31820790349.png", "url":"//yun.duiba.com.cn/aurora/assets/ecc97b17c9865468e95709b8211d74d636e443d9.jpg",
"uuid":"5ab43bdc-a6ce-46fb-99c2-a806f57f7484", "uuid":"ad720818-ce72-48a1-9494-5bd2b64136da",
"ext":".png" "ext":".jpg"
}, },
{ {
"name":"倒计时", "name":"倒计时",
...@@ -110,17 +116,12 @@ ...@@ -110,17 +116,12 @@
"ext":".png" "ext":".png"
}, },
{ {
"name":"吃力1", "name":"手无问题的常态",
"url":"//yun.duiba.com.cn/aurora/assets/40f906478c4fe90f9b68392df0031d382502f8d9.png", "url":"//yun.duiba.com.cn/aurora/assets/7b0c9452e2cd4d9cb0d76b69b808642fd43a62f8.png",
"uuid":"b876771a-a5d1-47f4-bd45-5978519c521a", "uuid":"e55ba5c2-ddbc-4392-b507-c2e7df91076f",
"ext":".png"
},
{
"name":"沮丧1",
"url":"//yun.duiba.com.cn/aurora/assets/f76eb798d2ccff84f53780c37d802830c5f6071c.png",
"uuid":"ff43517a-27bb-4f73-948c-d7a4fa7b4c69",
"ext":".png" "ext":".png"
}, },
{ {
"name":"常态2", "name":"常态2",
"url":"//yun.duiba.com.cn/aurora/assets/875fd6ba38735682fe27d010338277238672f310.png", "url":"//yun.duiba.com.cn/aurora/assets/875fd6ba38735682fe27d010338277238672f310.png",
...@@ -158,28 +159,13 @@ ...@@ -158,28 +159,13 @@
"url":"//yun.duiba.com.cn/aurora/assets/a1bf1b1622759aabec29e857e325039c147bac54.png", "url":"//yun.duiba.com.cn/aurora/assets/a1bf1b1622759aabec29e857e325039c147bac54.png",
"uuid":"07f74bf6-416f-445e-98d5-021efe4c9fdc", "uuid":"07f74bf6-416f-445e-98d5-021efe4c9fdc",
"ext":".png" "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": { "events": {
"in": { "in": {
"cloud-game-reset":{
"alias": "重置"
},
"pictures-start": { "pictures-start": {
"alias": "开始", "alias": "开始",
"data": { "data": {
......
...@@ -28,6 +28,7 @@ export default class CloudRain extends engine.Container{ ...@@ -28,6 +28,7 @@ export default class CloudRain extends engine.Container{
let ld = Date.now(); let ld = Date.now();
this.addEventListener(engine.Event.ENTER_FRAME,()=>{ this.addEventListener(engine.Event.ENTER_FRAME,()=>{
let dt = Date.now() - ld; let dt = Date.now() - ld;
// console.log(111)
a += dt; a += dt;
if(a>100){ if(a>100){
this.clound1.x -= (800 * dt) / 1000; this.clound1.x -= (800 * dt) / 1000;
...@@ -49,8 +50,5 @@ export default class CloudRain extends engine.Container{ ...@@ -49,8 +50,5 @@ export default class CloudRain extends engine.Container{
} }
} }
\ No newline at end of file
...@@ -17,6 +17,7 @@ export class GameWrapper extends engine.Container { ...@@ -17,6 +17,7 @@ export class GameWrapper extends engine.Container {
constructor() { constructor() {
super(); super();
engine.globalEvent.addEventListener('cloud-game-reset', this.reset, this);
engine.globalEvent.addEventListener('pictures-start', this.start, this); engine.globalEvent.addEventListener('pictures-start', this.start, this);
engine.globalEvent.addEventListener('pictures-stop', this.stop, this); engine.globalEvent.addEventListener('pictures-stop', this.stop, this);
...@@ -40,4 +41,8 @@ export class GameWrapper extends engine.Container { ...@@ -40,4 +41,8 @@ export class GameWrapper extends engine.Container {
// this._gameView.stop(); // this._gameView.stop();
this._gameTest.stop(); this._gameTest.stop();
} }
reset(event:engine.Event){
this._gameTest.again();
}
} }
...@@ -29,25 +29,31 @@ export default class Human extends engine.Container{ ...@@ -29,25 +29,31 @@ export default class Human extends engine.Container{
} }
scaleEffect(){ scaleEffect(){
let aaa = 0; // let aaa = 0;
let pt = Date.now(); // let pt = Date.now();
this.addEventListener(engine.Event.ENTER_FRAME,()=>{ // this.addEventListener(engine.Event.ENTER_FRAME,()=>{
let dt = Date.now() -pt; // let dt = Date.now() -pt;
aaa += dt; // aaa += dt;
this.anchorX = this.width + this.width / 2 // this.anchorX = this.width + this.width / 2
this.anchorY = this.height; // this.anchorY = this.height;
if(aaa > 90 && aaa<=100 ){ // if(aaa > 90 && aaa<=100 ){
this.scaleY = 0.99; // this.scaleY = 0.99;
this.scaleX = 1.01; // this.scaleX = 1.01;
} // }
if(aaa >190 && aaa < 200){ // if(aaa >190 && aaa < 200){
this.scaleX = 1; // this.scaleX = 1;
this.scaleY = 1; // this.scaleY = 1;
aaa = 0; // aaa = 0;
} // }
pt = Date.now(); // pt = Date.now();
}) // })
this.anchorX = this.width + this.width / 2
this.anchorY = this.height;
engine.Tween.get(this)
.set({scaleX:1,scaleY:1})
.to({scaleX:1.01,scaleY:0.99},100)
.to({scaleX:1,scaleY:1},100)
} }
} }
\ No newline at end of file
...@@ -9,7 +9,12 @@ export default class Moist extends engine.Container{ ...@@ -9,7 +9,12 @@ export default class Moist extends engine.Container{
txt = new engine.TextInput(); txt = new engine.TextInput();
hintpic:engine.Sprite = new engine.Sprite(getTexture('ed0e8931-2557-4527-bcfc-9071f90d5737')) hintpic:engine.Sprite = new engine.Sprite(getTexture('ed0e8931-2557-4527-bcfc-9071f90d5737'))
moveImg1:any = new engine.Sprite(getTexture('9be94bf5-5dd9-470b-a251-705d9c0ff1b0'))
moveImg2:any = new engine.Sprite(getTexture('9be94bf5-5dd9-470b-a251-705d9c0ff1b0'))
addPercent:number addPercent:number
moveImgContainer:any = new engine.Container();
constructor(){ constructor(){
super(); super();
this.percent = 0; this.percent = 0;
...@@ -17,7 +22,6 @@ export default class Moist extends engine.Container{ ...@@ -17,7 +22,6 @@ export default class Moist extends engine.Container{
this.moistBg.addChild(this.moist) this.moistBg.addChild(this.moist)
this.moist.mask = this.moistCover; this.moist.mask = this.moistCover;
this.txt.text = this.percent*100+'%'; this.txt.text = this.percent*100+'%';
this.txt.size = 30; this.txt.size = 30;
this.txt.fillColor = '#7A83C5'; this.txt.fillColor = '#7A83C5';
...@@ -28,9 +32,24 @@ export default class Moist extends engine.Container{ ...@@ -28,9 +32,24 @@ export default class Moist extends engine.Container{
this.hintpic.x = -10; this.hintpic.x = -10;
this.hintpic.y = 440; this.hintpic.y = 440;
this.addChild(this.hintpic) this.addChild(this.hintpic)
} }
// move(x,y){
// engine.Tween.get(this.moveImg1)
// .set({x:x,y:80})
// .to({x:x-this.moveImg1.width * 2,y:80},500)
// engine.Tween.get(this.moveImg2)
// .set({x:x + this.moveImg1.width - 5,y:80})
// .to({x:(x - this.moveImg1.width*2 - 5),y:80},500)
// }
cover(percent){ cover(percent){
percent = percent.toPrecision(2);
this.moistCover.anchorY = 416; this.moistCover.anchorY = 416;
this.moistBg.addChild(this.moistCover) this.moistBg.addChild(this.moistCover)
this.moistCover.scaleY = percent; this.moistCover.scaleY = percent;
......
import {getTexture} from './utils' import {getTexture} from './utils'
import {props} from '../props'
export default class TimeCounter extends engine.Container{ export default class TimeCounter extends engine.Container{
timeCounter:engine.Sprite = new engine.Sprite(getTexture('b7d2a60a-9e60-4eca-be80-a991abea47c9')); timeCounter:engine.Sprite = new engine.Sprite(getTexture('b7d2a60a-9e60-4eca-be80-a991abea47c9'));
...@@ -8,7 +9,7 @@ export default class TimeCounter extends engine.Container{ ...@@ -8,7 +9,7 @@ export default class TimeCounter extends engine.Container{
constructor(){ constructor(){
super() super()
this.time = 20 this.time = props.GAME_TIME;
this.addChild(this.timeCounter) this.addChild(this.timeCounter)
this.timeCounter.x = 256; this.timeCounter.x = 256;
......
This diff is collapsed.
<!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
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/**
* Created by rockyl on 2020-01-21.
*/
let customModuleProps = {
};
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/**
* 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();
});
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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