Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
dap-hu
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vũ Gia Vương
dap-hu
Commits
a81242c4
Commit
a81242c4
authored
Apr 02, 2025
by
Vũ Gia Vương
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update hammer when hit
parent
ad3186fb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
9 deletions
+12
-9
BreakingBottleController.ts
assets/scripts/GamePlay/BreakingBottleController.ts
+3
-5
FragmentController.ts
assets/scripts/GamePlay/FragmentController.ts
+9
-4
No files found.
assets/scripts/GamePlay/BreakingBottleController.ts
View file @
a81242c4
...
...
@@ -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;
}
}
...
...
assets/scripts/GamePlay/FragmentController.ts
View file @
a81242c4
...
...
@@ -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
();
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment