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

fix drop fragment

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