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
21489ab8
Commit
21489ab8
authored
Apr 01, 2025
by
Vũ Gia Vương
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add dynamic rigibody
parent
6afb5718
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
921 additions
and
71 deletions
+921
-71
main.fire
assets/main.fire
+897
-67
FragmentController.ts
assets/scripts/GamePlay/FragmentController.ts
+22
-4
BreakingBottleScreen.ts
assets/scripts/UI/BreakingBottleScreen.ts
+2
-0
No files found.
assets/main.fire
View file @
21489ab8
This diff is collapsed.
Click to expand it.
assets/scripts/GamePlay/FragmentController.ts
View file @
21489ab8
...
...
@@ -7,22 +7,40 @@ const { ccclass, property } = cc._decorator;
export
default
class
FragmentController
extends
cc
.
Component
{
private
_collider
:
cc
.
PolygonCollider
=
null
;
private
_physicsCollider
:
cc
.
PhysicsPolygonCollider
=
null
;
private
_rg
:
cc
.
RigidBody
=
null
;
onLoad
()
{
this
.
_collider
=
this
.
node
.
getComponent
(
cc
.
PolygonCollider
);
console
.
log
(
'this._collider'
,
this
.
_collider
.
points
.
length
)
this
.
_physicsCollider
=
this
.
node
.
getComponent
(
cc
.
PhysicsPolygonCollider
);
this
.
_physicsCollider
.
points
=
this
.
_collider
.
points
;
this
.
_physicsCollider
.
enabled
=
false
;
this
.
_rg
=
this
.
node
.
getComponent
(
cc
.
RigidBody
);
eventTarget
.
on
(
CHECK_TOUCH
,
this
.
checkTouch
,
this
);
}
private
checkTouch
(
point
:
cc
.
Vec2
)
{
// console.log('point', point.toString(), this.node.position.toString());
const
pos
=
point
.
clone
().
subtract
(
cc
.
v2
(
this
.
node
.
position
.
x
,
this
.
node
.
position
.
y
));
let
isInside
=
cc
.
Intersection
.
pointInPolygon
(
pos
,
this
.
_collider
.
points
);
// console.log('this._collider.points', this._collider.points.map(i => i.toString()));
if
(
isInside
)
{
console
.
log
(
'isInside'
,
isInside
,
pos
.
toString
(),
this
.
node
.
name
)
this
.
dropFragment
();
}
}
private
dropFragment
()
{
const
pos
=
this
.
node
.
position
;
this
.
node
.
setSiblingIndex
(
-
1
);
cc
.
tween
(
this
.
node
)
.
to
(
0.2
,
{
scale
:
0.95
})
.
to
(
0.2
,
{
scale
:
1.05
,
position
:
pos
.
clone
().
multiplyScalar
(
1.2
)
})
.
call
(()
=>
{
this
.
_physicsCollider
.
enabled
=
true
;
this
.
_rg
.
type
=
cc
.
RigidBodyType
.
Dynamic
;
this
.
_rg
.
gravityScale
=
2
;
})
.
start
();
}
}
assets/scripts/UI/BreakingBottleScreen.ts
View file @
21489ab8
...
...
@@ -10,6 +10,8 @@ export default class BreakingBottleScreen extends cc.Component {
private
spriteNode
:
cc
.
Node
=
null
;
onLoad
()
{
cc
.
director
.
getPhysicsManager
().
enabled
=
true
;
this
.
node
.
position
=
cc
.
v3
(
0
,
0
);
this
.
node
.
on
(
cc
.
Node
.
EventType
.
TOUCH_START
,
this
.
onTouchStart
,
this
);
}
...
...
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