Commit f86dcb7f authored by haiyoucuv's avatar haiyoucuv

init

parent a4c7a61c
......@@ -198,9 +198,9 @@
"_far": 2000,
"_color": {
"__type__": "cc.Color",
"r": 75,
"g": 75,
"b": 75,
"r": 102,
"g": 102,
"b": 102,
"a": 255
},
"_depth": 1,
......@@ -1790,6 +1790,9 @@
"fastBtn": {
"__id__": 63
},
"camera": {
"__id__": 4
},
"_id": "2dUcPvKs9AvZqQZfZoDIZT"
},
{
......
import {
_decorator, EventKeyboard, Input, input, KeyCode, director,
_decorator, EventKeyboard, Input, input, KeyCode, director, Camera, lerp,
} from "cc";
import { Snake } from "./Snake";
......@@ -19,6 +19,18 @@ export class Player extends Snake {
@property(FastBtn)
fastBtn: FastBtn = null;
@property(Camera)
camera: Camera = null;
get scale() {
return super.scale;
}
set scale(value: number) {
super.scale = value;
this.camera.orthoHeight = lerp(275, 612, value);
}
get length(): number {
return super.length;
}
......
......@@ -56,7 +56,16 @@ export class Snake extends Component {
// 蛇的状态
isLife: boolean = false;
private scale: number = 0.2;
private _scale: number = 0.2;
get scale() {
return this._scale;
}
set scale(value: number) {
this._scale = value;
}
speed: number = 300;
private energy: number = 0;
tag: number = 0;
......@@ -202,11 +211,11 @@ export class Snake extends Component {
value += this.lastRemaining;
while (value >= growthThreshold) {
this.grow();
value -= growthThreshold;
if (this.scale < 1) {
this.scale += 0.005;
}
this.grow();
}
this.lastRemaining = value;
......
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