Commit 8b42bb0e authored by 王梦佳's avatar 王梦佳

娃娃机

parent d1566d32
File added
This diff is collapsed.
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
} }
FrontBoxs.prototype.setup = function () { FrontBoxs.prototype.setup = function () {
var initX, initY = 0; var initX, initY = 0;
for (var i = 0; i < +props.dollNum + 1; i++) { for (var i = 0; i < props.dollNum; i++) {
if (!new engine.Sprite(getTextureByName('frontbox_' + i))) { if (!new engine.Sprite(getTextureByName('frontbox_' + i))) {
return; return;
} }
...@@ -40,6 +40,9 @@ ...@@ -40,6 +40,9 @@
initY = this.frontBoxs[0].y = props.frontInitY; initY = this.frontBoxs[0].y = props.frontInitY;
this.frontBoxs[i]['npcType'] = 'box' + i; this.frontBoxs[i]['npcType'] = 'box' + i;
} }
this.frontBoxs[props.dollNum] = new engine.Sprite(getTextureByName('frontbox_0'));
this.frontBoxs[props.dollNum]['npcType'] = 'box' + props.dollNum;
console.log(this.frontBoxs);
for (var i = 0; i < this.frontBoxs.length; i++) { for (var i = 0; i < this.frontBoxs.length; i++) {
if (i == 0) { if (i == 0) {
this.frontBoxs[i].x = initX; this.frontBoxs[i].x = initX;
...@@ -62,13 +65,18 @@ ...@@ -62,13 +65,18 @@
item.visible = true; item.visible = true;
} }
if (item.x >= 750) { if (item.x >= 750) {
var lastitem = _this.frontBoxs.shift(); var tmpIndex = 0;
lastitem.x = _this.frontBoxs[_this.frontBoxs.length - 1].x - _this.frontBoxs[0].width - props.frontmargin; if (index <= 0) {
tmpIndex = _this.frontBoxs.length - 1;
}
else {
tmpIndex = index - 1;
}
item.x = _this.frontBoxs[tmpIndex].x - _this.frontBoxs[0].width - props.frontmargin;
if (!_this.GameView.getMoveX() && item.x <= 0 && _this.GameView.startstatus) { if (!_this.GameView.getMoveX() && item.x <= 0 && _this.GameView.startstatus) {
_this.GameView.setMoveX((370 - item.x - 13) / props.moveSpeed, item); _this.GameView.setMoveX((370 - item.x - 13) / props.moveSpeed, item);
_this.hideBox = item; _this.hideBox = item;
} }
_this.frontBoxs.push(lastitem);
} }
}); });
}; };
...@@ -79,6 +87,7 @@ ...@@ -79,6 +87,7 @@
}; };
return FrontBoxs; return FrontBoxs;
}(engine.Container)); }(engine.Container));
//# sourceMappingURL=frontBox.js.map
var BackBoxs = (function (_super) { var BackBoxs = (function (_super) {
tslib.__extends(BackBoxs, _super); tslib.__extends(BackBoxs, _super);
...@@ -150,13 +159,13 @@ ...@@ -150,13 +159,13 @@
this.connect.x = 18; this.connect.x = 18;
this.connect.y = -5; this.connect.y = -5;
this.left_zhuazi = new engine.Sprite(getTextureByName("左爪")); this.left_zhuazi = new engine.Sprite(getTextureByName("左爪"));
this.left_zhuazi.x = -15; this.left_zhuazi.x = props.leftLocX;
this.left_zhuazi.y = 60; this.left_zhuazi.y = props.leftLocY;
this.left_zhuazi.anchorX = this.left_zhuazi.width; this.left_zhuazi.anchorX = this.left_zhuazi.width;
this.left_zhuazi.anchorY = 0; this.left_zhuazi.anchorY = 0;
this.right_zhuazi = new engine.Sprite(getTextureByName("右爪")); this.right_zhuazi = new engine.Sprite(getTextureByName("右爪"));
this.right_zhuazi.x = 98; this.right_zhuazi.x = props.rightLocX;
this.right_zhuazi.y = 60; this.right_zhuazi.y = props.rightLocY;
this.ganNode.addChild(this.left_zhuazi); this.ganNode.addChild(this.left_zhuazi);
this.ganNode.addChild(this.right_zhuazi); this.ganNode.addChild(this.right_zhuazi);
this.ganNode.addChild(this.connect); this.ganNode.addChild(this.connect);
...@@ -232,7 +241,7 @@ ...@@ -232,7 +241,7 @@
}; };
Zhuazi.prototype.getLong = function () { Zhuazi.prototype.getLong = function () {
var _this = this; var _this = this;
var droptime = Number((this.GameView.getMoveX() / 60 - 1).toFixed(2)) * 1000; var droptime = Number((this.GameView.getMoveX() / 60 - 1).toFixed(2)) * 1000 - 130;
console.log('dr', droptime); console.log('dr', droptime);
var times = (props.ganMoveEndY - this.ganzi.y) / this.ganzi.height; var times = (props.ganMoveEndY - this.ganzi.y) / this.ganzi.height;
console.log(Number(times.toFixed(2))); console.log(Number(times.toFixed(2)));
...@@ -267,8 +276,8 @@ ...@@ -267,8 +276,8 @@
tslib.__extends(GameView, _super); tslib.__extends(GameView, _super);
function GameView() { function GameView() {
var _this = _super.call(this) || this; var _this = _super.call(this) || this;
_this.startstatus = true; _this.startstatus = false;
_this.ifPrize = true; _this.ifPrize = false;
_this.goodsItems = []; _this.goodsItems = [];
_this.once(engine.Event.ADDED_TO_STAGE, _this.setup, _this); _this.once(engine.Event.ADDED_TO_STAGE, _this.setup, _this);
return _this; return _this;
...@@ -376,7 +385,6 @@ ...@@ -376,7 +385,6 @@
}; };
return GameView; return GameView;
}(engine.Container)); }(engine.Container));
//# sourceMappingURL=GameView.js.map
var GameWrapper = (function (_super) { var GameWrapper = (function (_super) {
tslib.__extends(GameWrapper, _super); tslib.__extends(GameWrapper, _super);
......
This diff is collapsed.
...@@ -102,11 +102,31 @@ ...@@ -102,11 +102,31 @@
"type": "number", "type": "number",
"default": 20 "default": 20
}, },
"leftLocX": {
"alias": "左边爪子X位置",
"type": "number",
"default": -15
},
"leftLocY": {
"alias": "左边爪子Y位置",
"type": "number",
"default": 60
},
"rightRotation": { "rightRotation": {
"alias": "右边爪子旋转角度", "alias": "右边爪子旋转角度",
"type": "number", "type": "number",
"default": -20 "default": -20
}, },
"rightLocX": {
"alias": "右边爪子X位置",
"type": "number",
"default": 98
},
"rightLocY": {
"alias": "右边爪子Y位置",
"type": "number",
"default": 60
},
"prizeBoxInitX": { "prizeBoxInitX": {
"alias": "中奖娃娃的x位置", "alias": "中奖娃娃的x位置",
"type": "number", "type": "number",
...@@ -148,12 +168,6 @@ ...@@ -148,12 +168,6 @@
"url": "//yun.duiba.com.cn/aurora/assets/fde8c60981791e5136c7914274c2a2d0936626cd.png", "url": "//yun.duiba.com.cn/aurora/assets/fde8c60981791e5136c7914274c2a2d0936626cd.png",
"uuid": "aa30ee7c-a6ad-4e10-9b6a-13b139664ab1", "uuid": "aa30ee7c-a6ad-4e10-9b6a-13b139664ab1",
"ext": ".png" "ext": ".png"
},
{
"name": "frontbox_4",
"url": "//yun.duiba.com.cn/aurora/assets/fde8c60981791e5136c7914274c2a2d0936626cd.png",
"uuid": "aa30ee7c-a6ad-4e10-9b6a-13b139664ab2",
"ext": ".png"
}, },
{ {
"name": "backbox_0", "name": "backbox_0",
......
...@@ -51,9 +51,9 @@ export default class GameView extends engine.Container { ...@@ -51,9 +51,9 @@ export default class GameView extends engine.Container {
//游戏状态 //游戏状态
private gameIng; private gameIng;
//是否已获取位移值 //是否已获取位移值
public startstatus=true; public startstatus=false;
//是否中奖 //是否中奖
public ifPrize=true; public ifPrize=false;
//npc出身计时器 //npc出身计时器
private timer; private timer;
//倒计时计时器 //倒计时计时器
......
...@@ -36,13 +36,13 @@ export class Zhuazi extends engine.Container { ...@@ -36,13 +36,13 @@ export class Zhuazi extends engine.Container {
this.connect.x = 18; this.connect.x = 18;
this.connect.y = -5; this.connect.y = -5;
this.left_zhuazi = new engine.Sprite(getTextureByName("左爪")); this.left_zhuazi = new engine.Sprite(getTextureByName("左爪"));
this.left_zhuazi.x = -15; this.left_zhuazi.x = props.leftLocX;
this.left_zhuazi.y = 60; this.left_zhuazi.y = props.leftLocY;
this.left_zhuazi.anchorX = this.left_zhuazi.width; this.left_zhuazi.anchorX = this.left_zhuazi.width;
this.left_zhuazi.anchorY = 0; this.left_zhuazi.anchorY = 0;
this.right_zhuazi = new engine.Sprite(getTextureByName("右爪")); this.right_zhuazi = new engine.Sprite(getTextureByName("右爪"));
this.right_zhuazi.x = 98; this.right_zhuazi.x = props.rightLocX;
this.right_zhuazi.y = 60; this.right_zhuazi.y = props.rightLocY;
this.ganNode.addChild(this.left_zhuazi); this.ganNode.addChild(this.left_zhuazi);
this.ganNode.addChild(this.right_zhuazi); this.ganNode.addChild(this.right_zhuazi);
this.ganNode.addChild(this.connect); this.ganNode.addChild(this.connect);
...@@ -115,7 +115,7 @@ export class Zhuazi extends engine.Container { ...@@ -115,7 +115,7 @@ export class Zhuazi extends engine.Container {
}, 500); }, 500);
} }
getLong() { getLong() {
let droptime = Number((this.GameView.getMoveX() / 60 - 1).toFixed(2)) * 1000; let droptime = Number((this.GameView.getMoveX() / 60 - 1).toFixed(2)) * 1000 -130;
console.log('dr', droptime); console.log('dr', droptime);
let times = (props.ganMoveEndY - this.ganzi.y ) / this.ganzi.height; let times = (props.ganMoveEndY - this.ganzi.y ) / this.ganzi.height;
console.log(Number(times.toFixed(2)) ); console.log(Number(times.toFixed(2)) );
......
...@@ -21,17 +21,19 @@ export class FrontBoxs extends engine.Container { ...@@ -21,17 +21,19 @@ export class FrontBoxs extends engine.Container {
} }
setup() { setup() {
let initX , initY = 0; let initX , initY = 0;
for(let i = 0; i < +props.dollNum+1; i++) { for(let i = 0; i < props.dollNum; i++) {
if (!new engine.Sprite(getTextureByName('frontbox_' + i))) { if (!new engine.Sprite(getTextureByName('frontbox_' + i))) {
return; return;
} }
this.frontBoxs[i] = new engine.Sprite(getTextureByName('frontbox_'+i)); this.frontBoxs[i] = new engine.Sprite(getTextureByName('frontbox_'+i));
initX = this.frontBoxs[0].x = props.frontInitX; initX = this.frontBoxs[0].x = props.frontInitX;
initY = this.frontBoxs[0].y = props.frontInitY; initY = this.frontBoxs[0].y = props.frontInitY;
this.frontBoxs[i]['npcType'] = 'box'+i; this.frontBoxs[i]['npcType'] = 'box'+i;
} }
// this.frontBoxs[props.dollNum] = new engine.Sprite(getTextureByName('frontbox_0')); this.frontBoxs[props.dollNum] = new engine.Sprite(getTextureByName('frontbox_0'));
// this.frontBoxs[props.dollNum]['npcType'] = 'box' + props.dollNum; this.frontBoxs[props.dollNum]['npcType'] = 'box' + props.dollNum;
console.log(this.frontBoxs);
for(let i = 0; i < this.frontBoxs.length; i++) { for(let i = 0; i < this.frontBoxs.length; i++) {
if(i == 0) { if(i == 0) {
...@@ -50,18 +52,25 @@ export class FrontBoxs extends engine.Container { ...@@ -50,18 +52,25 @@ export class FrontBoxs extends engine.Container {
frameMove() { frameMove() {
this.frontBoxs.forEach((item, index) => { this.frontBoxs.forEach((item, index) => {
item.x += props.moveSpeed; item.x += props.moveSpeed;
if(item.x <=0 && !item.visible) { if (item.x <= 0 && !item.visible) {
item.visible = true; item.visible = true;
} }
if(item.x >= 750) { if (item.x >= 750) {
let lastitem = this.frontBoxs.shift(); //let lastitem = this.frontBoxs.shift();
lastitem.x = this.frontBoxs[this.frontBoxs.length - 1].x - this.frontBoxs[0].width - props.frontmargin; let tmpIndex = 0;
if (index <= 0) {
tmpIndex = this.frontBoxs.length - 1;
} else {
tmpIndex = index - 1;
}
item.x = this.frontBoxs[tmpIndex].x - this.frontBoxs[0].width - props.frontmargin;
if (!this.GameView.getMoveX() && item.x <= 0 && this.GameView.startstatus) { if (!this.GameView.getMoveX() && item.x <= 0 && this.GameView.startstatus) {
this.GameView.setMoveX((370 - item.x - 13) / props.moveSpeed, item); this.GameView.setMoveX((370 - item.x - 13) / props.moveSpeed, item);
this.hideBox = item; this.hideBox = item;
} }
this.frontBoxs.push(lastitem); //this.frontBoxs.push(lastitem);
} }
}) })
} }
......
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