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

update hammer when hit

parent ad3186fb
......@@ -67,7 +67,8 @@ export default class BreakingBottleController extends cc.Component {
cc.tween(this.hammerNode)
.to(0.5, { position: cc.v3(newPos.x, newPos.y, 0) })
.delay(1)
.delay(0.3)
.to(0.3, { position: cc.v3(400, -400) })
.call(() => this.hammerNode.active = false)
.start();
}
......@@ -81,14 +82,11 @@ export default class BreakingBottleController extends cc.Component {
}
this._countFragment++;
if (this._countFragment == 8) {
eventTarget.emit(SHOW_CARD_POPUP);
this.scheduleOnce(() => eventTarget.emit(SHOW_CARD_POPUP), 1.5);
this._isEnd = true;
}
if (this._bodyFragments.length == 6) {
eventTarget.emit(DROP_FRAGMENT);
// this.schedule(() => eventTarget.emit(SHOW_CARD_POPUP), 2);
// this._bodyFragments = [];
// this._isEnd = true;
}
}
......
......@@ -10,6 +10,7 @@ export default class FragmentController extends cc.Component {
private _physicsCollider: cc.PhysicsPolygonCollider = null;
private _rg: cc.RigidBody = null;
private _siblingIndex: number = 0;
private _isDropped: boolean = false;
onLoad() {
this._collider = this.node.getComponent(cc.PolygonCollider);
......@@ -29,9 +30,13 @@ export default class FragmentController extends cc.Component {
this._rg.type = cc.RigidBodyType.Static;
this.node.angle = 0;
this.node.setSiblingIndex(this._siblingIndex);
this._isDropped = false;
}
private checkTouch(point: cc.Vec2) {
if (this._isDropped) {
return;
}
const pos = point.clone().subtract(cc.v2(this.node.position.x, this.node.position.y));
let isInside = cc.Intersection.pointInPolygon(pos, this._collider.points);
......@@ -42,8 +47,12 @@ export default class FragmentController extends cc.Component {
}
private dropFragment() {
this._isDropped = true;
const pos = this.node.position;
this.node.setSiblingIndex(-1);
eventTarget.emit(CHECK_FRAGMENT, this.node.name);
console.log('CHECK_FRAGMENT', CHECK_FRAGMENT)
cc.tween(this.node)
.delay(0.5)
.call(() => {
......@@ -59,10 +68,6 @@ export default class FragmentController extends cc.Component {
})
.delay(1)
.to(0, { scale: 1 })
.call(() => {
eventTarget.emit(CHECK_FRAGMENT, this.node.name);
console.log('CHECK_FRAGMENT', CHECK_FRAGMENT)
})
.start();
}
}
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