Commit cb8f7b3e authored by 任建锋's avatar 任建锋

--

parent 08bf8fe8
This diff is collapsed.
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
inst.source = 'asset://' + engine.getAssetByName(name).uuid; inst.source = 'asset://' + engine.getAssetByName(name).uuid;
return inst; return inst;
} }
//# sourceMappingURL=utils.js.map
var Goods = (function (_super) { var Goods = (function (_super) {
tslib.__extends(Goods, _super); tslib.__extends(Goods, _super);
...@@ -131,13 +132,14 @@ ...@@ -131,13 +132,14 @@
_this.playerCatchX = _this.player.x; _this.playerCatchX = _this.player.x;
}; };
_this.onMoveStage = function (e) { _this.onMoveStage = function (e) {
var maxStageBound = props.maxStageBound;
if (_this.gameIng) { if (_this.gameIng) {
var playerX = _this.playerCatchX + (e.localX - _this.moveCatchX); var playerX = _this.playerCatchX + (e.localX - _this.moveCatchX);
if (playerX < 0) { if (playerX < maxStageBound) {
_this.player.x = 0; _this.player.x = maxStageBound;
} }
else if (playerX + _this.player.width > 750) { else if (playerX + _this.player.width + maxStageBound > 750) {
_this.player.x = 750 - _this.player.width; _this.player.x = 750 - maxStageBound - _this.player.width;
} }
else { else {
_this.player.x = playerX; _this.player.x = playerX;
...@@ -326,9 +328,14 @@ ...@@ -326,9 +328,14 @@
this.goodsItems = []; this.goodsItems = [];
}; };
GameView.prototype.hasHit = function (a, b) { GameView.prototype.hasHit = function (a, b) {
var playerH = a.height;
console.log("props", props.playerHeight);
if (props.playerHeight) {
playerH = props.playerHeight;
}
if (Math.abs((a.x + a.width / 2) - (b.x + b.width / 2)) < a.width / 2 + b.width / 2 if (Math.abs((a.x + a.width / 2) - (b.x + b.width / 2)) < a.width / 2 + b.width / 2
&& &&
Math.abs((a.y + a.height / 1.3) - (b.y + b.height / 2)) < a.height / 2 + b.height / 2) { Math.abs((a.y + playerH / 1.3) - (b.y + b.height / 2)) < playerH / 2 + b.height / 2) {
return true; return true;
} }
else { else {
...@@ -337,7 +344,6 @@ ...@@ -337,7 +344,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.
{ {
"name": "口红机", "name": "接粽子",
"desc": "口红机模块", "desc": "接粽子模块",
"props": { "props": {
"playerPositionY": { "playerPositionY": {
"alias": "玩家Y轴位置", "alias": "玩家Y轴位置",
...@@ -27,6 +27,18 @@ ...@@ -27,6 +27,18 @@
"type": "number", "type": "number",
"default": 3 "default": 3
}, },
"playerHeight": {
"alias": "玩家高度",
"type": "number",
"default": 50
},
"maxStageBound": {
"alias": "最大移动边距",
"type": "number",
"default": -20
},
"gameOverCondition": { "gameOverCondition": {
"alias": "游戏结束条件(1:接到炸弹死亡,2:分数负数或接到炸弹死亡)", "alias": "游戏结束条件(1:接到炸弹死亡,2:分数负数或接到炸弹死亡)",
"type": "number", "type": "number",
......
...@@ -64,7 +64,7 @@ export default class GameView extends engine.Container { ...@@ -64,7 +64,7 @@ export default class GameView extends engine.Container {
this.NpcBg.alpha = 1; this.NpcBg.alpha = 1;
this.NpcBg.width = 0; this.NpcBg.width = 0;
this.NpcBg.height = 0; this.NpcBg.height = 0;
this.addChild(this.NpcBg) this.addChild(this.NpcBg);
...@@ -297,11 +297,17 @@ export default class GameView extends engine.Container { ...@@ -297,11 +297,17 @@ export default class GameView extends engine.Container {
* @param b b盒子 * @param b b盒子
*/ */
private hasHit(a, b) { private hasHit(a, b) {
let playerH=a.height
console.log("props",props.playerHeight)
if(props.playerHeight){
playerH=props.playerHeight
}
if ( if (
Math.abs((a.x + a.width / 2) - (b.x + b.width / 2)) < a.width / 2 + b.width / 2 Math.abs((a.x + a.width / 2) - (b.x + b.width / 2)) < a.width / 2 + b.width / 2
&& &&
// Math.abs((a.y + a.height / 2 ) - (b.y + b.height / 2)) < a.height / 2 + b.height / 2 // Math.abs((a.y + a.height / 2 ) - (b.y + b.height / 2)) < a.height / 2 + b.height / 2
Math.abs((a.y + a.height / 1.3 ) - (b.y + b.height / 2)) < a.height / 2 + b.height / 2 Math.abs((a.y + playerH / 1.3 ) - (b.y + b.height / 2)) < playerH / 2 + b.height / 2
) { ) {
return true; return true;
} else { } else {
...@@ -315,12 +321,13 @@ export default class GameView extends engine.Container { ...@@ -315,12 +321,13 @@ export default class GameView extends engine.Container {
} }
private onMoveStage = (e) => { private onMoveStage = (e) => {
let maxStageBound=props.maxStageBound;
if (this.gameIng) { if (this.gameIng) {
let playerX=this.playerCatchX + (e.localX - this.moveCatchX) let playerX=this.playerCatchX + (e.localX - this.moveCatchX)
if(playerX<0){ if(playerX<maxStageBound){
this.player.x=0 this.player.x=maxStageBound
}else if(playerX+this.player.width>750){ }else if(playerX+this.player.width+maxStageBound>750){
this.player.x=750-this.player.width this.player.x=750-maxStageBound-this.player.width
}else{ }else{
this.player.x=playerX this.player.x=playerX
} }
......
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