Commit 51e96fe0 authored by Vũ Gia Vương's avatar Vũ Gia Vương

fix rotate

parent f7ad56ad
This diff is collapsed.
...@@ -5,8 +5,6 @@ const { ccclass, property } = cc._decorator; ...@@ -5,8 +5,6 @@ const { ccclass, property } = cc._decorator;
@ccclass @ccclass
export default class HuController extends cc.Component { export default class HuController extends cc.Component {
@property(sp.Skeleton)
private spine2: sp.Skeleton = null;
private _spine: sp.Skeleton = null; private _spine: sp.Skeleton = null;
private _pointStart: cc.Vec2 = null; private _pointStart: cc.Vec2 = null;
...@@ -27,7 +25,7 @@ export default class HuController extends cc.Component { ...@@ -27,7 +25,7 @@ export default class HuController extends cc.Component {
this._spine.setCompleteListener(() => { this._spine.setCompleteListener(() => {
console.log('setCompleteListener',) console.log('setCompleteListener',)
this.setRotateAnim(); this.initBottle();
}); });
this.scheduleOnce(this.setDeviceMotion, 2); this.scheduleOnce(this.setDeviceMotion, 2);
...@@ -35,40 +33,27 @@ export default class HuController extends cc.Component { ...@@ -35,40 +33,27 @@ export default class HuController extends cc.Component {
this.initBottle(); this.initBottle();
} }
private onRotateGuild() {
this._spine.timeScale = 0.5;
this.scheduleOnce(() => {
this._track.trackTime = this._track.animationEnd / 4;
this._spine.timeScale = 0;
}, 1.2);
}
private initBottle() { private initBottle() {
this.setRotateAnim(); this._spine.setAnimation(1, "Rotate", false);
let state = this._spine.getState(); this._spine.timeScale = this._pointStart ? 0 : 0.5;
this._track = state.tracks[1]; this._track = this._spine.getState().tracks[1];
this._track.trackTime = this._track.animationEnd / 4;
this._spine.timeScale = 0; this._spine.timeScale = 0;
} }
private onTouchStart(event: cc.Event.EventTouch): void { private onTouchStart(event: cc.Event.EventTouch): void {
eventTarget.emit(STOP_GUILD_ROTATE); eventTarget.emit(STOP_GUILD_ROTATE);
// if (!this._pointStart) {
// this.setRotateAnim();
// }
this._pointStart = event.getLocation(); this._pointStart = event.getLocation();
this._spine.timeScale = 0; this._spine.timeScale = 0;
} }
private onTouchEnd(): void { private onTouchEnd(): void {
this.scheduleOnce(() => this._spine.timeScale = 0, 0.5); this.scheduleOnce(() => {
this._spine.timeScale = 0;
let state = this._spine.getState(); if (this._track.trackTime < 0) {
let track = state.tracks[1]; this._track.trackTime = this._track.animationEnd - 0.01;
if (track.trackTime < 0) {
track.trackTime = 0;
} }
}, 0.5);
} }
private onTouchMove(event: cc.Event.EventTouch): void { private onTouchMove(event: cc.Event.EventTouch): void {
...@@ -83,9 +68,11 @@ export default class HuController extends cc.Component { ...@@ -83,9 +68,11 @@ export default class HuController extends cc.Component {
this._spine.timeScale = distance > 0 ? -1 : 1; this._spine.timeScale = distance > 0 ? -1 : 1;
} }
private setRotateAnim(): void { private onRotateGuild() {
this._spine.setAnimation(1, "Rotate", false); this._spine.timeScale = 0.5;
this._spine.timeScale = this._pointStart ? 0 : 0.5; this.scheduleOnce(() => {
this._spine.timeScale = 0;
}, 1.2);
} }
private setDeviceMotion() { private setDeviceMotion() {
......
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