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
6afb5718
Commit
6afb5718
authored
Apr 01, 2025
by
Vũ Gia Vương
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add collider to Fragment
parent
0c905f64
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
1352 additions
and
60 deletions
+1352
-60
main.fire
assets/main.fire
+1235
-59
Events.ts
assets/scripts/Events.ts
+3
-1
BreakingBottleController.ts
assets/scripts/GamePlay/BreakingBottleController.ts
+31
-0
BreakingBottleController.ts.meta
assets/scripts/GamePlay/BreakingBottleController.ts.meta
+10
-0
FragmentController.ts
assets/scripts/GamePlay/FragmentController.ts
+28
-0
FragmentController.ts.meta
assets/scripts/GamePlay/FragmentController.ts.meta
+10
-0
BreakingBottleScreen.ts
assets/scripts/UI/BreakingBottleScreen.ts
+25
-0
BreakingBottleScreen.ts.meta
assets/scripts/UI/BreakingBottleScreen.ts.meta
+10
-0
No files found.
assets/main.fire
View file @
6afb5718
This diff is collapsed.
Click to expand it.
assets/scripts/Events.ts
View file @
6afb5718
...
@@ -19,4 +19,6 @@ export const PLAY_ANIM_NUT4 = 'PLAY_ANIM_NUT4';
...
@@ -19,4 +19,6 @@ export const PLAY_ANIM_NUT4 = 'PLAY_ANIM_NUT4';
export
const
ROTATE_GUILD
=
'ROTATE_GUILD'
;
export
const
ROTATE_GUILD
=
'ROTATE_GUILD'
;
export
const
BEAT_GUILD
=
'BEAT_GUILD'
;
export
const
BEAT_GUILD
=
'BEAT_GUILD'
;
export
const
STOP_GUILD_ROTATE
=
'STOP_GUILD_ROTATE'
;
export
const
STOP_GUILD_ROTATE
=
'STOP_GUILD_ROTATE'
;
export
const
STOP_GUILD_TAP
=
'STOP_GUILD_TAP'
;
export
const
STOP_GUILD_TAP
=
'STOP_GUILD_TAP'
;
\ No newline at end of file
export
const
CHECK_TOUCH
=
'CHECK_TOUCH'
;
\ No newline at end of file
assets/scripts/GamePlay/BreakingBottleController.ts
0 → 100644
View file @
6afb5718
import
FragmentController
from
"./FragmentController"
;
const
{
ccclass
,
property
}
=
cc
.
_decorator
;
@
ccclass
export
default
class
BreakingBottleController
extends
cc
.
Component
{
private
_body
:
cc
.
Node
=
null
;
private
_lid
:
cc
.
Node
=
null
;
private
_fragmentsBody
:
cc
.
Node
[]
=
[];
private
_fragmentsLid
:
cc
.
Node
[]
=
[];
private
_fragmentsAll
:
cc
.
Node
[]
=
[];
protected
onLoad
():
void
{
[
this
.
_body
,
this
.
_lid
]
=
this
.
node
.
children
;
this
.
_fragmentsBody
=
this
.
_body
.
children
;
this
.
_fragmentsLid
=
this
.
_lid
.
children
;
this
.
_fragmentsAll
=
[...
this
.
_fragmentsBody
,
...
this
.
_fragmentsLid
];
// console.log('this._fragmentsAll', this._fragmentsAll.map(item => item.position.toString()));
// this._fragmentsAll.forEach(item => {
// item.addComponent(FragmentController);
// })
}
}
assets/scripts/GamePlay/BreakingBottleController.ts.meta
0 → 100644
View file @
6afb5718
{
"ver": "1.1.0",
"uuid": "6fcd7f71-d097-4f64-a0f3-52bd35d14332",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
assets/scripts/GamePlay/FragmentController.ts
0 → 100644
View file @
6afb5718
import
{
eventTarget
,
CHECK_TOUCH
}
from
"../Events"
;
const
{
ccclass
,
property
}
=
cc
.
_decorator
;
@
ccclass
export
default
class
FragmentController
extends
cc
.
Component
{
private
_collider
:
cc
.
PolygonCollider
=
null
;
onLoad
()
{
this
.
_collider
=
this
.
node
.
getComponent
(
cc
.
PolygonCollider
);
console
.
log
(
'this._collider'
,
this
.
_collider
.
points
.
length
)
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
)
}
}
}
assets/scripts/GamePlay/FragmentController.ts.meta
0 → 100644
View file @
6afb5718
{
"ver": "1.1.0",
"uuid": "ad9b7183-781d-4ae6-ac93-79add38d57c7",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
assets/scripts/UI/BreakingBottleScreen.ts
0 → 100644
View file @
6afb5718
import
{
eventTarget
,
CHECK_TOUCH
}
from
"../Events"
;
const
{
ccclass
,
property
}
=
cc
.
_decorator
;
@
ccclass
export
default
class
BreakingBottleScreen
extends
cc
.
Component
{
@
property
(
cc
.
Node
)
private
spriteNode
:
cc
.
Node
=
null
;
onLoad
()
{
this
.
node
.
position
=
cc
.
v3
(
0
,
0
);
this
.
node
.
on
(
cc
.
Node
.
EventType
.
TOUCH_START
,
this
.
onTouchStart
,
this
);
}
private
onTouchStart
(
event
:
cc
.
Event
.
EventTouch
)
{
const
pos
=
event
.
getLocation
();
const
nodePos
=
this
.
node
.
convertToNodeSpaceAR
(
pos
);
this
.
spriteNode
.
position
=
cc
.
v3
(
nodePos
.
x
,
nodePos
.
y
);
eventTarget
.
emit
(
CHECK_TOUCH
,
nodePos
);
}
}
assets/scripts/UI/BreakingBottleScreen.ts.meta
0 → 100644
View file @
6afb5718
{
"ver": "1.1.0",
"uuid": "90267826-75d6-4f90-b056-fde22260947a",
"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