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

fix bottle idle in action screen

parent 6e6b468c
This diff is collapsed.
......@@ -7,4 +7,8 @@ export const SHOW_CARD_POPUP = 'SHOW_CARD_POPUP';
export const STOP_ANIM_CHUM = 'STOP_ANIM_CHUM';
export const SHOW_SELECT_POPUP = 'SHOW_SELECT_POPUP';
export const PLAY_ROLLING_SOUND = 'PLAY_ROLLING_SOUND';
\ No newline at end of file
export const PLAY_ROLLING_SOUND = 'PLAY_ROLLING_SOUND';
export const PLAY_ANIM_NUT1 = 'PLAY_ANIM_NUT1';
export const PLAY_ANIM_NUT2 = 'PLAY_ANIM_NUT2';
export const PLAY_ANIM_NUT3 = 'PLAY_ANIM_NUT3';
export const PLAY_ANIM_NUT4 = 'PLAY_ANIM_NUT4';
\ No newline at end of file
import { eventTarget, SHOW_ACTION_SCREEN, SHOW_CARD_POPUP } from "../Events";
import { eventTarget, PLAY_ANIM_NUT1, PLAY_ANIM_NUT2, PLAY_ANIM_NUT3, PLAY_ANIM_NUT4, SHOW_ACTION_SCREEN, SHOW_CARD_POPUP } from "../Events";
import { Global } from "../Global";
import ChumController from "./ChumController";
......@@ -7,17 +7,12 @@ const { ccclass, property } = cc._decorator;
@ccclass
export default class BuaController extends cc.Component {
@property(cc.Node)
private chumNode: cc.Node = null;
private _chumCtrl: ChumController = null;
private spine: sp.Skeleton = null;
private _count = 0;
private _actions: Function[] = [];
private _skins = ["Bua", "Ga", "Gai_lung", "Gay"]
protected onLoad(): void {
this._chumCtrl = this.chumNode.getComponent(ChumController);
this.spine = this.node.getComponent(sp.Skeleton);
this.spine.setSkin('Bua');
......@@ -40,31 +35,39 @@ export default class BuaController extends cc.Component {
this.spine.setAnimation(0, "Dap1", false);
this.spine.timeScale = 1;
this.playSound();
this._chumCtrl.playAnimationNut1();
this.scheduleOnce(() => {
eventTarget.emit(PLAY_ANIM_NUT1);
}, 0.5)
}
private playAnimationDap2(): void {
this.spine.setAnimation(0, "Dap2", false);
this.spine.timeScale = 1.2;
this.playSound();
this._chumCtrl.playAnimationNut2();
this.scheduleOnce(() => {
eventTarget.emit(PLAY_ANIM_NUT2);
}, 0.4)
}
private playAnimationDap3(): void {
this.spine.setAnimation(0, "Dap3", false);
this.spine.timeScale = 1.4;
this.playSound();
this._chumCtrl.playAnimationNut3();
this.scheduleOnce(() => {
eventTarget.emit(PLAY_ANIM_NUT3);
}, 0.3)
}
private playAnimationDap4(): void {
this.spine.setAnimation(0, "Dap4", false);
this.spine.timeScale = 1.6;
this.playSound();
this._chumCtrl.playAnimationNut4();
this.scheduleOnce(() => {
eventTarget.emit(PLAY_ANIM_NUT4);
}, 0.2)
cc.tween(this.node)
.by(0.5, { position: cc.v3(300,) })
.by(0.5, { position: cc.v3(1000,) })
.call(() => {
eventTarget.emit(SHOW_CARD_POPUP);
})
......@@ -72,6 +75,5 @@ export default class BuaController extends cc.Component {
}
private playSound() {
// this.node.getComponent(cc.AudioSource).play();
}
}
import { eventTarget, SHOW_ACTION_SCREEN, STOP_ANIM_CHUM } from "../Events";
import { eventTarget, PLAY_ANIM_NUT1, PLAY_ANIM_NUT2, PLAY_ANIM_NUT3, PLAY_ANIM_NUT4, SHOW_ACTION_SCREEN, STOP_ANIM_CHUM } from "../Events";
const { ccclass, property } = cc._decorator;
......@@ -16,11 +16,15 @@ export default class ChumController extends cc.Component {
this.node.on(cc.Node.EventType.TOUCH_START, this.onTouchStart, this);
this._actions = [this.playAnimationNut1, this.playAnimationNut2, this.playAnimationNut3, this.playAnimationNut4];
eventTarget.on(STOP_ANIM_CHUM, this.stopAnimation, this);
eventTarget.on(PLAY_ANIM_NUT1, this.playAnimationNut1, this);
eventTarget.on(PLAY_ANIM_NUT2, this.playAnimationNut2, this);
eventTarget.on(PLAY_ANIM_NUT3, this.playAnimationNut3, this);
eventTarget.on(PLAY_ANIM_NUT4, this.playAnimationNut4, this);
}
private onTouchStart(): void {
// this._actions[this._count].bind(this)();
// this._count = (this._count + 1) % this._actions.length;
}
private stopAnimation(): void {
......@@ -28,6 +32,7 @@ export default class ChumController extends cc.Component {
}
public playAnimationNut1(): void {
this.node.active = true;
this.spine.setAnimation(0, "nut1", true);
this.spine.timeScale = 1;
}
......
......@@ -25,15 +25,14 @@ export default class HuController extends cc.Component {
this.node.on(cc.Node.EventType.TOUCH_MOVE, this.onTouchMove, this)
this.spine.setCompleteListener(() => this.setRotateAnim());
}
protected start(): void {
this.scheduleOnce(() => this.testDevice, 3);
}
private testDevice() {
this.text.string = 'testDevice';
console.log('testDevice',)
window.addEventListener("devicemotion", (event) => {
if (!event.accelerationIncludingGravity) {
return;
......@@ -85,6 +84,7 @@ export default class HuController extends cc.Component {
}
private onTouchStart(event: cc.Event.EventTouch): void {
console.log('onTouchStart', )
if (!this._pointStart) {
this.setRotateAnim();
}
......
import { eventTarget, SHOW_ACTION_SCREEN, SHOW_CARD_POPUP, SHOW_START_SCREEN } from "../Events";
import { eventTarget, PLAY_ANIM_NUT1, SHOW_ACTION_SCREEN, SHOW_CARD_POPUP, SHOW_START_SCREEN } from "../Events";
import BuaController from "../GamePlay/BuaController";
const { ccclass, property } = cc._decorator;
@ccclass
export default class ActionScreen extends cc.Component {
@property(cc.Node)
private bottleIdle: cc.Node = null;
@property(cc.Node)
private bottleAction: cc.Node = null;
private _buaController: BuaController = null;
onLoad() {
this.node.position = cc.v3();
this.node.active = false;
eventTarget.on(SHOW_ACTION_SCREEN, this.showScreen, this);
eventTarget.on(SHOW_START_SCREEN, this.hideScreen, this);
eventTarget.on(PLAY_ANIM_NUT1, this.hideBottle, this);
this._buaController = this.getComponentInChildren(BuaController);
// this.node.active = false;
}
private hideBottle() {
this.bottleAction.active = true;
this.bottleIdle.active = false;
}
private showScreen() {
this.bottleAction.active = false;
this.bottleIdle.active = true;
this.node.active = true;
this._buaController.onSetTool();
this.node.position = cc.v3();
}
private hideScreen() {
......
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