Commit 7273b42a authored by Vũ Gia Vương's avatar Vũ Gia Vương

clear not use in HuController

parent 655f27ce
import { eventTarget, PLAY_ROLLING_SOUND, ROTATE_GUILD, STOP_GUILD_ROTATE } from "../Events";
import { TrackEntry } from "../Utils";
import { eventTarget, PLAY_ROLLING_SOUND } from "../Events";
const { ccclass, property } = cc._decorator;
......@@ -7,28 +6,17 @@ const { ccclass, property } = cc._decorator;
export default class HuController extends cc.Component {
private _spine: sp.Skeleton = null;
private _pointStart: cc.Vec2 = null;
private _x: number = 0;
private _y: number = 0;
private _z: number = 0;
private _count = 0;
private _isShake = false;
private _track: TrackEntry = null;
private _debug: cc.Label = null;
protected onLoad(): void {
this._spine = this.node.getComponent(sp.Skeleton);
this._debug = this.node.getComponentInChildren(cc.Label);
this.node.on(cc.Node.EventType.TOUCH_START, this.onTouchStart, this);
this.node.on(cc.Node.EventType.TOUCH_END, this.onTouchEnd, this)
this.node.on(cc.Node.EventType.TOUCH_MOVE, this.onTouchMove, this)
eventTarget.on(ROTATE_GUILD, this.onRotateGuild, this);
this._spine.setCompleteListener(() => {
this.initBottle();
});
if (cc.sys.os === cc.sys.OS_IOS) {
this.setDeviceMotionIOS();
}
......@@ -36,11 +24,9 @@ export default class HuController extends cc.Component {
this.scheduleOnce(this.setDeviceMotion, 2);
}
this.initBottle();
this._spine.timeScale = 0;
}
private setDeviceMotionIOS() {
const debug = (text: string) => {
this._debug.string = text;
......@@ -77,45 +63,6 @@ export default class HuController extends cc.Component {
}
}
private initBottle() {
// this._spine.setAnimation(1, "Rotate", false);
// this._track = this._spine.getState().tracks[1];
}
private onTouchStart(event: cc.Event.EventTouch): void {
eventTarget.emit(STOP_GUILD_ROTATE);
this._pointStart = event.getLocation();
this._spine.timeScale = 0;
}
private onTouchEnd(): void {
this.scheduleOnce(() => {
this._spine.timeScale = 0;
}, 0.5);
}
private onTouchMove(event: cc.Event.EventTouch): void {
const newPoint = event.getLocation();
const distance = newPoint.x - this._pointStart.x;
if (Math.abs(distance) < 10) {
this._spine.timeScale = 0;
return;
}
if (this._track.trackTime < 0) {
this._track.trackTime = this._track.animationEnd - 1e-3;
}
this._pointStart = newPoint;
this._spine.timeScale = distance > 0 ? -1.5 : 1.5;
}
private onRotateGuild() {
this._spine.timeScale = 0.8;
this.scheduleOnce(() => {
this._spine.timeScale = 0;
}, 1);
}
private setDeviceMotion() {
window.addEventListener("devicemotion", (event) => {
if (!event.accelerationIncludingGravity) {
......
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