DelayNoMore/frontend/assets/scripts/BaseCharacter.js

45 lines
961 B
JavaScript
Raw Normal View History

2022-09-20 15:50:01 +00:00
module.export = cc.Class({
extends: cc.Component,
properties: {
lastMovedAt: {
type: cc.Float,
default: 0 // In "GMT milliseconds"
}
2022-09-20 15:50:01 +00:00
},
2022-11-20 13:07:45 +00:00
ctor() {
this.activeDirection = {
2022-09-20 15:50:01 +00:00
dx: 0,
dy: 0
};
},
onLoad() {
const self = this;
const canvasNode = self.mapNode.parent;
self.mapIns = self.mapNode.getComponent("Map");
2022-09-20 15:50:01 +00:00
const joystickInputControllerScriptIns = canvasNode.getComponent("TouchEventsManager");
self.ctrl = joystickInputControllerScriptIns;
},
update(dt) {},
2022-09-20 15:50:01 +00:00
lateUpdate(dt) {},
2022-09-20 15:50:01 +00:00
_generateRandomDirection() {
return ALL_DISCRETE_DIRECTIONS_CLOCKWISE[Math.floor(Math.random() * ALL_DISCRETE_DIRECTIONS_CLOCKWISE.length)];
},
updateSpeed(proposedSpeed) {
if (0 == proposedSpeed && 0 < this.speed) {
this.startFrozenDisplay();
}
2022-09-20 15:50:01 +00:00
if (0 < proposedSpeed && 0 == this.speed) {
this.stopFrozenDisplay();
}
this.speed = proposedSpeed;
2022-09-20 15:50:01 +00:00
},
});