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
417b3c67
Commit
417b3c67
authored
Apr 02, 2025
by
Vũ Gia Vương
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update hammer
parent
5ceadf6d
Changes
6
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
427 additions
and
186 deletions
+427
-186
main.fire
assets/main.fire
+359
-151
Events.ts
assets/scripts/Events.ts
+3
-1
BreakingBottleController.ts
assets/scripts/GamePlay/BreakingBottleController.ts
+57
-15
FragmentController.ts
assets/scripts/GamePlay/FragmentController.ts
+7
-1
TheController.ts
assets/scripts/GamePlay/TheController.ts
+1
-0
BreakingBottleScreen.ts
assets/scripts/UI/BreakingBottleScreen.ts
+0
-18
No files found.
assets/main.fire
View file @
417b3c67
This diff is collapsed.
Click to expand it.
assets/scripts/Events.ts
View file @
417b3c67
...
...
@@ -22,3 +22,5 @@ export const STOP_GUILD_ROTATE = 'STOP_GUILD_ROTATE';
export
const
STOP_GUILD_TAP
=
'STOP_GUILD_TAP'
;
export
const
CHECK_TOUCH
=
'CHECK_TOUCH'
;
export
const
CHECK_FRAGMENT
=
'CHECK_FRAGMENT'
;
export
const
HAMMER
=
'HAMMER'
;
\ No newline at end of file
assets/scripts/GamePlay/BreakingBottleController.ts
View file @
417b3c67
import
{
CHECK_FRAGMENT
,
CHECK_TOUCH
,
eventTarget
,
HAMMER
}
from
"../Events"
;
import
{
Global
}
from
"../Global"
;
import
FragmentController
from
"./FragmentController"
;
import
TheController
from
"./TheController"
;
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
[]
=
[];
@
property
(
cc
.
Node
)
private
hammerNode
:
cc
.
Node
=
null
;
protected
onLoad
():
void
{
private
_spine
:
sp
.
Skeleton
=
null
;
private
_skins
=
[
"Ga"
,
"Gai_lung"
,
"Gay"
,
"Bua"
,];
private
_cardNode
:
cc
.
Node
=
null
;
private
_countFragment
=
0
;
[
this
.
_body
,
this
.
_lid
]
=
this
.
node
.
children
;
this
.
_fragmentsBody
=
this
.
_body
.
children
;
this
.
_fragmentsLid
=
this
.
_lid
.
children
;
this
.
_fragmentsAll
=
[...
this
.
_fragmentsBody
,
...
this
.
_fragmentsLid
];
onLoad
()
{
cc
.
director
.
getPhysicsManager
().
enabled
=
true
;
this
.
_spine
=
this
.
hammerNode
.
getComponentInChildren
(
sp
.
Skeleton
);
this
.
_cardNode
=
this
.
node
.
getComponentInChildren
(
TheController
).
node
;
this
.
_cardNode
.
active
=
false
;
// console.log('this._fragmentsAll', this._fragmentsAll.map(item => item.position.toString()));
this
.
node
.
position
=
cc
.
v3
(
0
,
0
);
this
.
node
.
on
(
cc
.
Node
.
EventType
.
TOUCH_START
,
this
.
onTouchStart
,
this
);
this
.
node
.
on
(
cc
.
Node
.
EventType
.
TOUCH_END
,
this
.
onTouchEnd
,
this
);
eventTarget
.
on
(
CHECK_FRAGMENT
,
this
.
checkFragment
,
this
);
eventTarget
.
on
(
HAMMER
,
this
.
onHammer
,
this
);
}
// this._fragmentsAll.forEach(item =>
{
// item.addComponent(FragmentController
);
// })
protected
start
():
void
{
this
.
hideHammer
(
);
}
private
onHammer
(
newPos
:
cc
.
Vec2
)
{
cc
.
tween
(
this
.
hammerNode
)
.
to
(
0.1
,
{
opacity
:
255
,
position
:
cc
.
v3
(
newPos
.
x
,
newPos
.
y
)
})
.
delay
(
0.7
)
.
to
(
0.2
,
{
opacity
:
0
})
.
start
();
}
private
checkFragment
(
name
:
string
)
{
this
.
_countFragment
++
;
if
(
this
.
_countFragment
==
8
)
{
this
.
_cardNode
.
active
=
true
;
}
}
private
onTouchStart
(
event
:
cc
.
Event
.
EventTouch
)
{
const
pos
=
event
.
getLocation
();
const
nodePos
=
this
.
node
.
convertToNodeSpaceAR
(
pos
);
const
newPos
=
cc
.
v3
(
nodePos
.
x
,
nodePos
.
y
);
eventTarget
.
emit
(
CHECK_TOUCH
,
nodePos
);
this
.
_spine
.
setSkin
(
this
.
_skins
[
Global
.
tool
%
this
.
_skins
.
length
]);
this
.
_spine
.
setAnimation
(
0
,
"Dap4"
,
false
);
}
private
onTouchEnd
(
event
:
cc
.
Event
.
EventTouch
)
{
}
private
hideHammer
()
{
this
.
hammerNode
.
opacity
=
0
;
}
}
assets/scripts/GamePlay/FragmentController.ts
View file @
417b3c67
import
{
eventTarget
,
CHECK_TOUCH
}
from
"../Events"
;
import
{
eventTarget
,
CHECK_TOUCH
,
CHECK_FRAGMENT
,
HAMMER
}
from
"../Events"
;
const
{
ccclass
,
property
}
=
cc
.
_decorator
;
...
...
@@ -25,6 +25,7 @@ export default class FragmentController extends cc.Component {
let
isInside
=
cc
.
Intersection
.
pointInPolygon
(
pos
,
this
.
_collider
.
points
);
if
(
isInside
)
{
eventTarget
.
emit
(
HAMMER
,
point
);
this
.
dropFragment
();
}
}
...
...
@@ -33,6 +34,7 @@ export default class FragmentController extends cc.Component {
const
pos
=
this
.
node
.
position
;
this
.
node
.
setSiblingIndex
(
-
1
);
cc
.
tween
(
this
.
node
)
.
delay
(
0.5
)
.
to
(
0.2
,
{
scale
:
0.95
})
.
to
(
0.2
,
{
scale
:
1.05
,
position
:
pos
.
clone
().
multiplyScalar
(
1.2
)
})
.
call
(()
=>
{
...
...
@@ -40,6 +42,10 @@ export default class FragmentController extends cc.Component {
this
.
_rg
.
type
=
cc
.
RigidBodyType
.
Dynamic
;
this
.
_rg
.
gravityScale
=
5
;
})
.
delay
(
1
)
.
call
(()
=>
{
eventTarget
.
emit
(
CHECK_FRAGMENT
,
this
.
node
.
name
);
})
.
start
();
}
}
assets/scripts/GamePlay/TheController.ts
View file @
417b3c67
...
...
@@ -14,6 +14,7 @@ export default class TheController extends cc.Component {
protected
onLoad
():
void
{
this
.
_textSprite
=
this
.
getComponentInChildren
(
cc
.
Sprite
);
this
.
_spine
=
this
.
node
.
getComponent
(
sp
.
Skeleton
);
this
.
_spine
.
setCompleteListener
((
trackEntry
)
=>
{
if
(
trackEntry
.
animation
.
name
==
'Open'
)
{
this
.
_spine
.
setAnimation
(
0
,
'Idle'
,
true
);
...
...
assets/scripts/UI/BreakingBottleScreen.ts
View file @
417b3c67
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
;
@
property
(
cc
.
Node
)
private
hammerNode
:
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
);
}
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
);
this
.
hammerNode
.
position
=
cc
.
v3
(
nodePos
.
x
,
nodePos
.
y
);
}
}
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