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
c742359e
Commit
c742359e
authored
Apr 28, 2025
by
Vũ Gia Vương
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add polygon in fragment jar
parent
f8cdb5e3
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
751 additions
and
214 deletions
+751
-214
main.fire
assets/main.fire
+671
-214
FragmentJarController.ts
assets/scripts/GamePlay/FragmentJarController.ts
+70
-0
FragmentJarController.ts.meta
assets/scripts/GamePlay/FragmentJarController.ts.meta
+10
-0
No files found.
assets/main.fire
View file @
c742359e
This diff is collapsed.
Click to expand it.
assets/scripts/GamePlay/FragmentJarController.ts
0 → 100644
View file @
c742359e
import
{
CHECK_FRAGMENT
,
CHECK_TOUCH
,
DROP_FRAGMENT
,
eventTarget
,
HAMMER
,
PLAY_DROP_SOUND
,
RESET_FRAGMENT
}
from
"../Events"
;
const
{
ccclass
,
property
}
=
cc
.
_decorator
;
@
ccclass
export
default
class
FragmentJarController
extends
cc
.
Component
{
private
_collider
:
cc
.
PolygonCollider
=
null
;
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
);
this
.
_physicsCollider
=
this
.
node
.
getComponent
(
cc
.
PhysicsPolygonCollider
);
this
.
_physicsCollider
.
points
=
this
.
_collider
.
points
;
this
.
_rg
=
this
.
node
.
getComponent
(
cc
.
RigidBody
);
this
.
_siblingIndex
=
this
.
node
.
getSiblingIndex
();
this
.
reset
();
eventTarget
.
on
(
CHECK_TOUCH
,
this
.
checkTouch
,
this
);
eventTarget
.
on
(
RESET_FRAGMENT
,
this
.
reset
,
this
);
eventTarget
.
on
(
DROP_FRAGMENT
,
()
=>
this
.
node
.
name
.
includes
(
'nap'
)
&&
this
.
dropFragment
(),
this
);
}
public
reset
()
{
this
.
_physicsCollider
.
enabled
=
false
;
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
);
if
(
isInside
)
{
eventTarget
.
emit
(
HAMMER
,
point
);
this
.
dropFragment
();
}
}
private
dropFragment
()
{
this
.
_isDropped
=
true
;
const
pos
=
this
.
node
.
position
;
this
.
node
.
setSiblingIndex
(
-
1
);
eventTarget
.
emit
(
CHECK_FRAGMENT
,
this
.
node
.
name
);
cc
.
tween
(
this
.
node
)
.
delay
(
0.5
)
.
call
(()
=>
{
eventTarget
.
emit
(
PLAY_DROP_SOUND
);
})
.
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
;
})
.
delay
(
1
)
.
to
(
0
,
{
scale
:
1
})
.
start
();
}
}
assets/scripts/GamePlay/FragmentJarController.ts.meta
0 → 100644
View file @
c742359e
{
"ver": "1.1.0",
"uuid": "6c74056e-3e34-4e34-9605-e6acbcef252c",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
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