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

add RESET_FRAGMENT

parent f4eee2d3
...@@ -25,3 +25,4 @@ export const CHECK_TOUCH = 'CHECK_TOUCH'; ...@@ -25,3 +25,4 @@ export const CHECK_TOUCH = 'CHECK_TOUCH';
export const CHECK_FRAGMENT = 'CHECK_FRAGMENT'; export const CHECK_FRAGMENT = 'CHECK_FRAGMENT';
export const HAMMER = 'HAMMER'; export const HAMMER = 'HAMMER';
export const RESET_BOTTLE = 'RESET_BOTTLE'; export const RESET_BOTTLE = 'RESET_BOTTLE';
export const RESET_FRAGMENT = 'RESET_FRAGMENT';
\ No newline at end of file
import { CHECK_FRAGMENT, CHECK_TOUCH, eventTarget, HAMMER, RESET_BOTTLE, SHOW_CARD_POPUP } from "../Events"; import { CHECK_FRAGMENT, CHECK_TOUCH, eventTarget, HAMMER, RESET_BOTTLE, RESET_FRAGMENT, SHOW_CARD_POPUP } from "../Events";
import { Global } from "../Global"; import { Global } from "../Global";
import FragmentController from "./FragmentController"; import FragmentController from "./FragmentController";
import TheController from "./TheController"; import TheController from "./TheController";
...@@ -47,10 +47,10 @@ export default class BreakingBottleController extends cc.Component { ...@@ -47,10 +47,10 @@ export default class BreakingBottleController extends cc.Component {
this._spine.setSkin(this._skins[Global.tool % this._skins.length]); this._spine.setSkin(this._skins[Global.tool % this._skins.length]);
this._spine.setAnimation(0, "Dap4", false); this._spine.setAnimation(0, "Dap4", false);
this._fragmentsNode.forEach((item, index) => { this._fragmentsNode.forEach((node, index) => {
item.position = this._fragmentsPosition[index]; node.position = this._fragmentsPosition[index];
item.getComponent(FragmentController).reset();
}) })
eventTarget.emit(RESET_FRAGMENT);
} }
private onHammer(newPos: cc.Vec2) { private onHammer(newPos: cc.Vec2) {
......
import { eventTarget, CHECK_TOUCH, CHECK_FRAGMENT, HAMMER } from "../Events"; import { eventTarget, CHECK_TOUCH, CHECK_FRAGMENT, HAMMER, RESET_FRAGMENT } from "../Events";
const { ccclass, property } = cc._decorator; const { ccclass, property } = cc._decorator;
...@@ -20,6 +20,7 @@ export default class FragmentController extends cc.Component { ...@@ -20,6 +20,7 @@ export default class FragmentController extends cc.Component {
this.reset(); this.reset();
eventTarget.on(CHECK_TOUCH, this.checkTouch, this); eventTarget.on(CHECK_TOUCH, this.checkTouch, this);
eventTarget.on(RESET_FRAGMENT, this.reset, this);
} }
public reset() { public reset() {
......
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