Commit 2a1e1b52 authored by 汪欢's avatar 汪欢

11

parent 8d59419f
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": "遮罩",
"url": "//yun.duiba.com.cn/aurora/assets/5b3e30496b2d9fdafb0cf3835fd6704ce10e45b4.png",
"uuid": "888",
"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 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.p2demo = factory(global.tslib));\n}(this, (function (tslib) { 'use strict';\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.factor = 10;\r\n _this.isDebug = 1;\r\n _this.once(engine.Event.ADDED_TO_STAGE, _this.setup, _this);\r\n return _this;\r\n }\r\n GameView.prototype.createBall = function (r) {\r\n var shape = new engine.Shape();\r\n shape.beginFill(0xfff000);\r\n shape.drawCircle(0, 0, r);\r\n shape.endFill();\r\n return shape;\r\n };\r\n GameView.prototype.start = function () {\r\n console.log('start');\r\n this.stage.addEventListener(engine.MouseEvent.CLICK, this.onClick, this);\r\n };\r\n GameView.prototype.createBox = function (width, height) {\r\n var shape = new engine.Shape();\r\n shape.beginFill(0xfff000);\r\n shape.drawRect(-width / 2, -height / 2, width, height);\r\n shape.endFill();\r\n return shape;\r\n };\r\n GameView.prototype.onClick = function (e) {\r\n var _a = this, world = _a.world, factor = _a.factor;\r\n var positionX = (e.stageX / factor);\r\n var positionY = ((engine.gameStage.stage.height - e.stageY) / factor);\r\n var display;\r\n if (Math.random() > .5) {\r\n var boxShape = new p2.Box({ width: 200 / factor, height: 100 / factor });\r\n var boxBody = new p2.Body({ mass: 1, position: [positionX, positionY], angularVelocity: 1 });\r\n boxBody.addShape(boxShape);\r\n world.addBody(boxBody);\r\n if (this.isDebug) {\r\n display = this.createBox(boxShape.width * factor, boxShape.height * factor);\r\n }\r\n }\r\n else {\r\n var boxShape = new p2.Circle({ radius: 200 / 2 / factor });\r\n var boxBody = new p2.Body({ mass: 1, position: [positionX, positionY] });\r\n boxBody.addShape(boxShape);\r\n world.addBody(boxBody);\r\n if (this.isDebug) {\r\n display = this.createBall(boxShape.radius * factor);\r\n }\r\n }\r\n boxBody.displays = [display];\r\n this.addChild(display);\r\n };\r\n GameView.prototype.setup = function () {\r\n console.log('setup');\r\n var world = new p2.World({});\r\n world.sleepMode = p2.World.BODY_SLEEPING;\r\n var planeShape = new p2.Plane();\r\n var planeBody = new p2.Body();\r\n planeBody.addShape(planeShape);\r\n planeBody.displays = [];\r\n world.addBody(planeBody);\r\n this.world = world;\r\n this.stage.addEventListener(engine.Event.ENTER_FRAME, this.onEnterFrame, this);\r\n };\r\n GameView.prototype.onEnterFrame = function () {\r\n var _a = this, world = _a.world, factor = _a.factor;\r\n world.step(60 / 1000);\r\n var stageHeight = engine.gameStage.stage.height;\r\n var l = world.bodies.length;\r\n for (var i = 0; i < l; i++) {\r\n var boxBody = world.bodies[i];\r\n var box = boxBody.displays[0];\r\n if (box) {\r\n box.x = boxBody.position[0] * factor;\r\n box.y = stageHeight - boxBody.position[1] * factor;\r\n box.rotation = 360 - (boxBody.angle + boxBody.shapes[0].angle) * 180 / Math.PI;\r\n if (boxBody.sleepState == p2.Body.SLEEPING) {\r\n box.alpha = 0.5;\r\n }\r\n else {\r\n box.alpha = 1;\r\n }\r\n }\r\n }\r\n };\r\n return GameView;\r\n }(engine.Container));\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 }\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('pictures-start', _this.start, _this);\r\n engine.globalEvent.addEventListener('pictures-stop', _this.stop, _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 injectProps(event.data);\r\n this._gameView.start();\r\n };\r\n GameWrapper.prototype.stop = function (event) {\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 }\n\n return index;\n\n})));\n"
}
......@@ -44,7 +44,18 @@ function launchWithCustomModule(customModule) {
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', {
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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
......@@ -46,6 +46,9 @@ function launchWithCustomModule(customModule) {
}, 100);
setTimeout(() => {
engine.globalEvent.dispatchEvent('cloud-game-reset', {
});
engine.globalEvent.dispatchEvent('pictures-start', {
});
......@@ -55,6 +58,15 @@ function launchWithCustomModule(customModule) {
// engine.gameStage.sceneContainer.getChildAt(0).y = (d.stage.height-props.H)/2;
}, 1000);
setTimeout(() => {
engine.globalEvent.dispatchEvent('cloud-game-reset', {
});
engine.globalEvent.dispatchEvent('pictures-start', {
});
}, 20*1000);
// setTimeout(() => {
// engine.globalEvent.dispatchEvent('pictures-start', {
// picUrl: "http://yun.duiba.com.cn/aurora/assets/e1593b97c27077b85b92f7eaaeae1ed64a1eb79a.png",
......@@ -73,6 +85,9 @@ function launchWithCustomModule(customModule) {
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) {
......
This diff is collapsed.
......@@ -16,7 +16,7 @@
"GAME_TIME": {
"alias": "游戏时间",
"type": "number",
"default": 30
"default": 20
},
"moistPercent": {
"alias": "湿润度",
......@@ -43,6 +43,12 @@
"uuid":"ed0e8931-2557-4527-bcfc-9071f90d5737",
"ext":".png"
},
{
"name":"湿润度动效处理",
"url":"//yun.duiba.com.cn/aurora/assets/d02e290b34ca4b3254f705bd04f02d231003f05d.png",
"uuid":"9be94bf5-5dd9-470b-a251-705d9c0ff1b0",
"ext":".png"
},
{
"name":"wind",
"url":"//yun.duiba.com.cn/aurora/assets/15fc1dabf22baedd8bf5e5b418e57cfc81686072.svga",
......@@ -57,9 +63,9 @@
},
{
"name":"背景",
"url":"//yun.duiba.com.cn/aurora/assets/d0e22ae58b6e8519b969ed207197a31820790349.png",
"uuid":"5ab43bdc-a6ce-46fb-99c2-a806f57f7484",
"ext":".png"
"url":"//yun.duiba.com.cn/aurora/assets/ecc97b17c9865468e95709b8211d74d636e443d9.jpg",
"uuid":"ad720818-ce72-48a1-9494-5bd2b64136da",
"ext":".jpg"
},
{
"name":"倒计时",
......@@ -110,17 +116,12 @@
"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",
"name":"手无问题的常态",
"url":"//yun.duiba.com.cn/aurora/assets/7b0c9452e2cd4d9cb0d76b69b808642fd43a62f8.png",
"uuid":"e55ba5c2-ddbc-4392-b507-c2e7df91076f",
"ext":".png"
},
{
"name":"常态2",
"url":"//yun.duiba.com.cn/aurora/assets/875fd6ba38735682fe27d010338277238672f310.png",
......@@ -158,28 +159,13 @@
"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": {
"cloud-game-reset":{
"alias": "重置"
},
"pictures-start": {
"alias": "开始",
"data": {
......
......@@ -28,6 +28,7 @@ export default class CloudRain extends engine.Container{
let ld = Date.now();
this.addEventListener(engine.Event.ENTER_FRAME,()=>{
let dt = Date.now() - ld;
// console.log(111)
a += dt;
if(a>100){
this.clound1.x -= (800 * dt) / 1000;
......@@ -50,7 +51,4 @@ export default class CloudRain extends engine.Container{
}
\ No newline at end of file
......@@ -17,6 +17,7 @@ export class GameWrapper extends engine.Container {
constructor() {
super();
engine.globalEvent.addEventListener('cloud-game-reset', this.reset, this);
engine.globalEvent.addEventListener('pictures-start', this.start, this);
engine.globalEvent.addEventListener('pictures-stop', this.stop, this);
......@@ -40,4 +41,8 @@ export class GameWrapper extends engine.Container {
// this._gameView.stop();
this._gameTest.stop();
}
reset(event:engine.Event){
this._gameTest.again();
}
}
......@@ -29,25 +29,31 @@ export default class Human extends engine.Container{
}
scaleEffect(){
let aaa = 0;
let pt = Date.now();
this.addEventListener(engine.Event.ENTER_FRAME,()=>{
let dt = Date.now() -pt;
aaa += dt;
// 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();
// })
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();
})
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{
txt = new engine.TextInput();
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
moveImgContainer:any = new engine.Container();
constructor(){
super();
this.percent = 0;
......@@ -17,7 +22,6 @@ export default class Moist extends engine.Container{
this.moistBg.addChild(this.moist)
this.moist.mask = this.moistCover;
this.txt.text = this.percent*100+'%';
this.txt.size = 30;
this.txt.fillColor = '#7A83C5';
......@@ -28,9 +32,24 @@ export default class Moist extends engine.Container{
this.hintpic.x = -10;
this.hintpic.y = 440;
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){
percent = percent.toPrecision(2);
this.moistCover.anchorY = 416;
this.moistBg.addChild(this.moistCover)
this.moistCover.scaleY = percent;
......
import {getTexture} from './utils'
import {props} from '../props'
export default class TimeCounter extends engine.Container{
timeCounter:engine.Sprite = new engine.Sprite(getTexture('b7d2a60a-9e60-4eca-be80-a991abea47c9'));
......@@ -8,7 +9,7 @@ export default class TimeCounter extends engine.Container{
constructor(){
super()
this.time = 20
this.time = props.GAME_TIME;
this.addChild(this.timeCounter)
this.timeCounter.x = 256;
......
......@@ -151,7 +151,7 @@
if (GAME_TIME < 10) {
GAME_TIME = '0' + GAME_TIME;
}
console.log(GAME_TIME, "gametime1");
console.log(GAME_TIME);
engine.globalEvent.dispatchEvent('pictures-time-update', {
second: this.getSecond(),
});
......
......@@ -56,11 +56,11 @@
"pictures-start": {
"alias": "开始",
"data": {
"picUrl": "图片路径",
"blockUrl": "blockUrl",
"row": "行",
"column": "列",
"gameTime": "游戏时间"
"picUrl":"图片路径",
"blockUrl":"blockUrl",
"row":"行",
"column":"列",
"gameTime":"游戏时间"
}
},
"pictures-stop": {
......
......@@ -27,11 +27,19 @@ export default class GameView extends engine.Container {
private date
start() {
<<<<<<< HEAD
=======
//优先获取start事件接收到的参数
>>>>>>> 2533efe07c13d1586974175c8874bc3dad71643a
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)
<<<<<<< HEAD
=======
>>>>>>> 2533efe07c13d1586974175c8874bc3dad71643a
if (!this.guideHole) {
this.guideHole = new engine.Image();
this.guideHole.source = 'asset://' + props.blockUrl;
......
......@@ -19,14 +19,16 @@ export default class TestView extends engine.Container{
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.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)
this.startBtn.addEventListener(engine.MouseEvent.CLICK,this.onClick,this) */
}
smallBall:SmallPlane
......@@ -63,7 +65,7 @@ export default class TestView extends engine.Container{
score:number = 0;
start(){
// 炮车
this.planeModel = new engine.Sprite(getTexture('32ec481a-3f75-4c36-95ed-ee97aa936517'))
/* 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)
......@@ -173,13 +175,13 @@ export default class TestView extends engine.Container{
},16)
*/
}
onClick(){
/* onClick(){
this.addChild(this.gameBg);
this.gameBg.addChild(this.planeModel)
}
......@@ -215,6 +217,6 @@ export default class TestView extends engine.Container{
stop(){
}
} */
}
\ No newline at end of file
......@@ -12,7 +12,6 @@
function injectProps(p) {
engine.injectProp(props, p);
}
//# sourceMappingURL=props.js.map
var qietu = (function (parent, url, MAX_COL, MAX_ROW) {
var W = props.W;
......@@ -55,7 +54,6 @@
console.log(spr);
return [spr, pos];
});
//# sourceMappingURL=qietu.js.map
function getIndexFromRC(row, col, maxCol) {
var index;
......@@ -255,7 +253,6 @@
};
return GameView;
}(engine.Container));
//# sourceMappingURL=GameView.js.map
var GameWrapper = (function (_super) {
tslib.__extends(GameWrapper, _super);
......@@ -276,7 +273,6 @@
};
return GameWrapper;
}(engine.Container));
//# sourceMappingURL=GameWrapper.js.map
function index (props) {
prepareProps();
......@@ -284,7 +280,6 @@
var instance = new GameWrapper();
return instance;
}
//# sourceMappingURL=index.js.map
return index;
......
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