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

fix drop fragment

parent d46dc308
......@@ -6299,7 +6299,7 @@
"__id__": 198
}
],
"_active": true,
"_active": false,
"_components": [
{
"__id__": 201
......@@ -7519,7 +7519,7 @@
"__id__": 205
}
],
"_active": false,
"_active": true,
"_components": [],
"_prefab": {
"__id__": 208
......@@ -7841,7 +7841,7 @@
"__id__": 215
}
],
"_active": false,
"_active": true,
"_components": [
{
"__id__": 218
......
import { eventTarget, RESET_FRAGMENT, SHAKE_FRAGMENT } from "../Events";
import { Global } from "../Global";
const { ccclass, property } = cc._decorator;
......@@ -32,11 +33,20 @@ export default class BehindFragment extends cc.Component {
.start();
}
public onDrop() {
this._isDropped = true;
const position = cc.v3(Math.random() * 100 - 50, Math.random() * 100);
cc.tween(this.node)
.repeat(4, cc.tween(this.node)
.by(Global.getRandomTime(), { position: cc.v3(-5, -5) })
.by(Global.getRandomTime(), { position: cc.v3(5, 5) })
)
.start();
cc.tween(this.node)
.by(1, { position })
.to(1, { scale: 0.9 })
.call(() => {
this._rg.type = cc.RigidBodyType.Dynamic;
this._rg.gravityScale = 10;
......@@ -49,5 +59,6 @@ export default class BehindFragment extends cc.Component {
this._physicsCollider.enabled = false;
this._rg.type = cc.RigidBodyType.Static;
this.node.angle = 0;
this.node.scale = 1;
}
}
......@@ -108,7 +108,7 @@ export default class BreakingJarController extends cc.Component {
cc.Tween.stopAllByTarget(this.mask);
cc.tween(this.mask)
.to(1, { opacity: 0 })
.to(1.5, { opacity: 0 })
.call(() => {
eventTarget.emit(DROP_ALL_FRAGMENT);
this._behindJarChild.forEach(item => item.onDrop());
......@@ -116,6 +116,7 @@ export default class BreakingJarController extends cc.Component {
.delay(2)
.call(() => eventTarget.emit(SHOW_CARD_POPUP))
.start();
this._isEnd = true;
return;
}
......
import { CHECK_FRAGMENT, CHECK_TOUCH, DROP_ALL_FRAGMENT, DROP_TOP_FRAGMENT, eventTarget, HAMMER, PLAY_DROP_SOUND, RESET_FRAGMENT, SHAKE_FRAGMENT, SHOW_FOG } from "../Events";
import { Global } from "../Global";
const { ccclass, property } = cc._decorator;
......@@ -39,6 +40,7 @@ export default class FragmentJarController extends cc.Component {
this._physicsCollider.enabled = false;
this._rg.type = cc.RigidBodyType.Static;
this.node.angle = 0;
this.node.scale = 1;
this.node.setSiblingIndex(this._siblingIndex);
this.isDropped = false;
this._numberOfBeats = 3;
......@@ -117,15 +119,15 @@ export default class FragmentJarController extends cc.Component {
eventTarget.emit(CHECK_FRAGMENT, this.node);
cc.tween(this.node)
.delay(0.5)
.repeat(4, cc.tween(this.node)
.by(Global.getRandomTime(), { position: cc.v3(-5, -5) })
.by(Global.getRandomTime(), { position: cc.v3(5, 5) })
)
.to(Global.getRandomTime() * 5, { scale: 1.1 })
.call(() => {
eventTarget.emit(PLAY_DROP_SOUND);
this.node.setSiblingIndex(-1);
})
.to(0.1, { scale: 0.9 })
.to(0.1, { scale: 1.05 })
.to(0.2, { position: pos.clone().multiplyScalar(1.2) })
.call(() => {
this._physicsCollider.enabled = true;
this._rg.type = cc.RigidBodyType.Dynamic;
this._rg.gravityScale = 10;
......
export class Global {
public static tool: number = 0;
public static getRandomTime() {
return Math.random() * 0.05 + 0.03;
}
}
\ 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