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

add tutorial rotate

parent 3811eacc
This diff is collapsed.
{
"ver": "1.1.2",
"uuid": "63d032ad-e87d-42a0-84a8-137e2034682c",
"importer": "ttf-font",
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.3.7",
"uuid": "5ccefdb7-c84d-4e62-a98c-1251745e4ee3",
"importer": "texture",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 215,
"height": 291,
"platformSettings": {},
"subMetas": {
"hand": {
"ver": "1.0.6",
"uuid": "bb4b8653-efdf-49ce-b06e-3e199eddbc6f",
"importer": "sprite-frame",
"rawTextureUuid": "5ccefdb7-c84d-4e62-a98c-1251745e4ee3",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 215,
"height": 291,
"rawWidth": 215,
"rawHeight": 291,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
...@@ -14,4 +14,7 @@ export const PLAY_DROP_SOUND = 'PLAY_DROP_SOUND'; ...@@ -14,4 +14,7 @@ export const PLAY_DROP_SOUND = 'PLAY_DROP_SOUND';
export const PLAY_ANIM_NUT1 = 'PLAY_ANIM_NUT1'; export const PLAY_ANIM_NUT1 = 'PLAY_ANIM_NUT1';
export const PLAY_ANIM_NUT2 = 'PLAY_ANIM_NUT2'; export const PLAY_ANIM_NUT2 = 'PLAY_ANIM_NUT2';
export const PLAY_ANIM_NUT3 = 'PLAY_ANIM_NUT3'; export const PLAY_ANIM_NUT3 = 'PLAY_ANIM_NUT3';
export const PLAY_ANIM_NUT4 = 'PLAY_ANIM_NUT4'; export const PLAY_ANIM_NUT4 = 'PLAY_ANIM_NUT4';
\ No newline at end of file
export const ROTATE_GUILD = 'ROTATE_GUILD';
export const STOP_GUILD = 'STOP_GUILD';
\ No newline at end of file
import { eventTarget, PLAY_ROLLING_SOUND } from "../Events"; import { eventTarget, PLAY_ROLLING_SOUND, ROTATE_GUILD, STOP_GUILD } from "../Events";
import { TrackEntry } from "../Utils";
const { ccclass, property } = cc._decorator; const { ccclass, property } = cc._decorator;
...@@ -12,6 +13,7 @@ export default class HuController extends cc.Component { ...@@ -12,6 +13,7 @@ export default class HuController extends cc.Component {
private _z: number = 0; private _z: number = 0;
private _count = 0; private _count = 0;
private _isShake = false; private _isShake = false;
private _track: TrackEntry = null;
protected onLoad(): void { protected onLoad(): void {
this._spine = this.node.getComponent(sp.Skeleton); this._spine = this.node.getComponent(sp.Skeleton);
...@@ -19,6 +21,7 @@ export default class HuController extends cc.Component { ...@@ -19,6 +21,7 @@ export default class HuController extends cc.Component {
this.node.on(cc.Node.EventType.TOUCH_START, this.onTouchStart, this); 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_END, this.onTouchEnd, this)
this.node.on(cc.Node.EventType.TOUCH_MOVE, this.onTouchMove, this) this.node.on(cc.Node.EventType.TOUCH_MOVE, this.onTouchMove, this)
eventTarget.on(ROTATE_GUILD, this.onRotateGuild, this);
this._spine.setCompleteListener(() => { this._spine.setCompleteListener(() => {
console.log('setCompleteListener',) console.log('setCompleteListener',)
...@@ -30,15 +33,25 @@ export default class HuController extends cc.Component { ...@@ -30,15 +33,25 @@ 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.setRotateAnim();
let state = this._spine.getState(); let state = this._spine.getState();
let track = state.tracks[1]; this._track = state.tracks[1];
track.trackTime = 3 / 4; 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);
// if (!this._pointStart) { // if (!this._pointStart) {
// this.setRotateAnim(); // this.setRotateAnim();
// } // }
...@@ -49,8 +62,8 @@ export default class HuController extends cc.Component { ...@@ -49,8 +62,8 @@ export default class HuController extends cc.Component {
private onTouchEnd(): void { private onTouchEnd(): void {
this.scheduleOnce(() => this._spine.timeScale = 0, 0.5); this.scheduleOnce(() => this._spine.timeScale = 0, 0.5);
let state = this._spine.getState(); let state = this._spine.getState();
let track = state.tracks[1]; let track = state.tracks[1];
if (track.trackTime < 0) { if (track.trackTime < 0) {
track.trackTime = 0; track.trackTime = 0;
} }
......
import { eventTarget, ROTATE_GUILD, STOP_GUILD } from "../Events";
const { ccclass, property } = cc._decorator;
@ccclass
export default class TutorialController extends cc.Component {
private _hand: cc.Node;
protected onLoad(): void {
[this._hand] = this.node.children;
this.tutorialRotate();
eventTarget.on(STOP_GUILD, this.stopGuild, this);
}
private stopGuild() {
cc.Tween.stopAllByTarget(this._hand);
this._hand.active = false;
}
private tutorialRotate() {
this._hand.active = true;
cc.tween(this._hand)
.repeatForever(cc.tween(this._hand)
.to(0, { position: cc.v3(350) }, { easing: 'easingOutQuad' })
.to(0.5, { angle: -10 }, { easing: 'easingInQuad' })
.to(0.5, { angle: 15 })
.call(() => eventTarget.emit(ROTATE_GUILD))
.to(1.2, { position: cc.v3(-150) })
)
.start();
}
}
{
"ver": "1.1.0",
"uuid": "3bfa65da-3350-411d-a61c-9a13db8fb529",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
export interface TrackEntry {
alpha: number,
animation: null
animationEnd: number,
animationLast: number,
animationStart: number,
attachmentThreshold: number,
delay: number,
drawOrderThreshold: number,
eventThreshold: number,
holdPrevious: false
interruptAlpha: number,
listener: null
loop: false
mixBlend: number,
mixDuration: number,
mixTime: number,
mixingFrom: null
mixingTo: null
next: null
nextAnimationLast: number,
nextTrackLast: number,
timeScale: number,
timelineHoldMix: []
timelineMode: []
timelinesRotation: []
totalAlpha: number,
trackEnd: number,
trackIndex: number,
trackLast: number,
trackTime: number,
}
\ No newline at end of file
{
"ver": "1.1.0",
"uuid": "1e4fae74-9c0b-4bd5-8c84-597f7cd02dc9",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
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