Commit 842d0321 authored by haiyoucuv's avatar haiyoucuv

init

parent 33d430f1
......@@ -262,7 +262,9 @@ export class Snake extends Component {
}
setAngle(angle: number) {
this.isLife && (this.head.angle = angle);
if (this.isLife) {
this.head.angle = angle;
}
}
isFast = false;
......@@ -293,13 +295,10 @@ export class Snake extends Component {
}
// 更新头部位置
const newHeadPos = this.getNewPos(
this.head.angle,
dt,
this.head.getPosition()
);
const newHeadPos = this.getNewPos(this.head.angle, dt, this.head.position);
this.head.setPosition(newHeadPos);
this.head.setScale(this.scale, this.scale);
const flipY = this.head.angle > 90 && this.head.angle < 270;
this.head.setScale(this.scale, flipY ? -this.scale : this.scale);
this.head.setSiblingIndex(this.bodyArr.length);
const space = ~~(this.SEGMENT_SPACING * this.scale);
......
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