Commit a33af498 authored by Chen Jiping's avatar Chen Jiping

完善

parent dbc4c314
...@@ -1519,6 +1519,9 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -1519,6 +1519,9 @@ export class PlayComponent implements OnInit, OnDestroy {
let toX = this.bigLotusLeaf.lotusLeaf.x - this.frog.width / 2; let toX = this.bigLotusLeaf.lotusLeaf.x - this.frog.width / 2;
let toY = this.bigLotusLeaf.lotusLeaf.y - this.frog.height + 50 * this.mapScale; let toY = this.bigLotusLeaf.lotusLeaf.y - this.frog.height + 50 * this.mapScale;
this.frog.bigLeafX = toX;
this.frog.bigLeafY = toY;
//跳到大荷叶上 //跳到大荷叶上
this.frogJump(toX, toY, 1, ()=>{ this.frogJump(toX, toY, 1, ()=>{
...@@ -1596,9 +1599,9 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -1596,9 +1599,9 @@ export class PlayComponent implements OnInit, OnDestroy {
//停留0.1秒,然后跳出 //停留0.1秒,然后跳出
setTimeout(() => { setTimeout(() => {
let tPos = this.getJumpOutMap(toX, toY, this.frog.width, this.frog.height); let tPos = this.getJumpOutMap2(toX, toY, this.frog.bigLeafX, this.frog.bigLeafY, this.frog.width);
console.log('out pos', tPos); console.log(toX, toY, 'out pos', tPos);
this.frogJump(tPos.x, tPos.y, 0.5,()=>{ this.frogJump(tPos.x, tPos.y, 0.5,()=>{
...@@ -1688,37 +1691,37 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -1688,37 +1691,37 @@ export class PlayComponent implements OnInit, OnDestroy {
}); });
} }
/** /**
* 获取青蛙跳坐标 * 获取青蛙跳入水中坐标
* @param curX * @param curX
* @param curY * @param curY
* @param sX
* @param sY
* @param width
*/ */
getJumpOutMap(curX, curY, width, height){ getJumpOutMap2(curX, curY, sX, sY, width){
if(curX < this.canvasWidth /2){ //斜率
let k = (curY - sY)/(curX - sX);
//第二象限 //取得跳出的坐标
if(curY < this.canvasHeight / 2){ let outX = 0;
return {x : curX, y:-height};
}
else{
//第三象限
return {x: -width, y: curY};
}
}
else{
if(curY < this.canvasHeight / 2){ if(curX <= sX){
//第一象限
return {x: curX, y: -height}; outX = -width;
} }
else{ else{
//第四象限
return {x: curX, y: -height}; outX = this.canvasWidth + width;
}
}
} }
let outY = k * (outX - curX) + curY;
return {x : outX, y: outY};
}
/** /**
* 跳到荷叶上显示小星星 * 跳到荷叶上显示小星星
...@@ -1811,12 +1814,12 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -1811,12 +1814,12 @@ export class PlayComponent implements OnInit, OnDestroy {
//大荷叶划出屏幕 //大荷叶划出屏幕
let toX = this.canvasWidth + this.bigLotusLeaf.lotusLeaf.getBoundingBox().width / 2; let toX = this.canvasWidth + this.bigLotusLeaf.lotusLeaf.getBoundingBox().width / 2;
let toY = this.canvasHeight + this.bigLotusLeaf.lotusLeaf.getBoundingBox().height / 2; let toY = this.canvasHeight + this.bigLotusLeaf.lotusLeaf.getBoundingBox().height / 2;
tweenChange(this.bigLotusLeaf.lotusLeaf, {x: toX, y:toY}, 1); tweenChange(this.bigLotusLeaf.lotusLeaf, {x: toX, y:toY}, 0.5, ()=>{
//显示重新开始按钮 //显示重新开始按钮
tweenChange(this.btnRestart.sprite, {x: this.btnRestart.showX, y:this.btnRestart.showY}, 0.3); tweenChange(this.btnRestart.sprite, {x: this.btnRestart.showX, y:this.btnRestart.showY}, 0.3);
this.tempSmallLotusLeafs = [... this.smallLotusLeafs]; this.tempSmallLotusLeafs = [... this.smallLotusLeafs];
});
} }
/** /**
......
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