Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
test11111111
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
template admin
test11111111
Commits
858319e4
Commit
858319e4
authored
4 years ago
by
Li Mingzhe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: drag
parent
786dcc03
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
0 deletions
+52
-0
ScratchCards.js
...atch_cards/components/ScratchCards/Script/ScratchCards.js
+52
-0
No files found.
play/assets/ljx_scratch_cards/components/ScratchCards/Script/ScratchCards.js
View file @
858319e4
...
...
@@ -49,7 +49,12 @@ cc.Class({
// LIFE-CYCLE CALLBACKS:
onLoad
()
{
this
.
downFlag
=
false
;
this
.
mask
=
this
.
node
.
getChildByName
(
'
Mask
'
).
getComponent
(
cc
.
Mask
);
this
.
node
.
on
(
cc
.
Node
.
EventType
.
MOUSE_DOWN
,
this
.
mouseDown
,
this
);
this
.
node
.
on
(
cc
.
Node
.
EventType
.
MOUSE_MOVE
,
this
.
mouseMove
,
this
);
this
.
node
.
on
(
cc
.
Node
.
EventType
.
MOUSE_UP
,
this
.
mouseUp
,
this
);
this
.
node
.
on
(
cc
.
Node
.
EventType
.
TOUCH_START
,
this
.
touchStart
,
this
);
this
.
node
.
on
(
cc
.
Node
.
EventType
.
TOUCH_MOVE
,
this
.
touchMove
,
this
);
this
.
node
.
on
(
cc
.
Node
.
EventType
.
TOUCH_END
,
this
.
touchEnd
,
this
);
...
...
@@ -74,23 +79,70 @@ cc.Class({
// console.log(55555, this._id, able);
this
.
touchable
=
able
;
},
mouseDown
(
e
){
if
(
!
this
.
touchable
)
{
return
}
this
.
downFlag
=
true
;
this
.
scratch
(
e
);
if
(
this
.
node
.
hasEventListener
(
cc
.
Node
.
EventType
.
TOUCH_START
))
{
this
.
node
.
off
(
cc
.
Node
.
EventType
.
TOUCH_START
,
this
.
touchStart
,
this
);
}
},
mouseMove
(
e
){
if
(
!
this
.
touchable
)
{
return
}
if
(
!
this
.
downFlag
)
{
return
;
}
this
.
scratch
(
e
);
if
(
this
.
node
.
hasEventListener
(
cc
.
Node
.
EventType
.
TOUCH_MOVE
))
{
this
.
node
.
off
(
cc
.
Node
.
EventType
.
TOUCH_MOVE
,
this
.
touchMove
,
this
);
}
},
mouseUp
(
e
)
{
this
.
downFlag
=
false
;
if
(
this
.
node
.
hasEventListener
(
cc
.
Node
.
EventType
.
TOUCH_END
))
{
this
.
node
.
off
(
cc
.
Node
.
EventType
.
TOUCH_END
,
this
.
touchEnd
,
this
);
}
if
(
this
.
node
.
hasEventListener
(
cc
.
Node
.
EventType
.
TOUCH_CANCEL
))
{
this
.
node
.
off
(
cc
.
Node
.
EventType
.
TOUCH_CANCEL
,
this
.
touchCancel
,
this
);
}
},
touchStart
(
e
){
if
(
!
this
.
touchable
)
{
return
}
this
.
downFlag
=
true
;
this
.
scratch
(
e
);
if
(
this
.
node
.
hasEventListener
(
cc
.
Node
.
EventType
.
MOUSE_DOWN
))
{
this
.
node
.
off
(
cc
.
Node
.
EventType
.
MOUSE_DOWN
,
this
.
mouseDown
,
this
);
}
},
touchMove
(
e
){
if
(
!
this
.
touchable
)
{
return
}
this
.
scratch
(
e
);
if
(
this
.
node
.
hasEventListener
(
cc
.
Node
.
EventType
.
MOUSE_MOVE
))
{
this
.
node
.
off
(
cc
.
Node
.
EventType
.
MOUSE_MOVE
,
this
.
mouseMove
,
this
);
}
},
touchEnd
(
e
){
this
.
downFlag
=
false
;
// this.scratch(e);
if
(
this
.
node
.
hasEventListener
(
cc
.
Node
.
EventType
.
MOUSE_UP
))
{
this
.
node
.
off
(
cc
.
Node
.
EventType
.
MOUSE_UP
,
this
.
mouseUp
,
this
);
}
},
touchCancel
(
e
){
this
.
downFlag
=
false
;
// this.scratch(e);
if
(
this
.
node
.
hasEventListener
(
cc
.
Node
.
EventType
.
MOUSE_UP
))
{
this
.
node
.
off
(
cc
.
Node
.
EventType
.
MOUSE_UP
,
this
.
mouseUp
,
this
);
}
},
initRectMaskPoints
()
{
const
rows
=
Math
.
floor
(
this
.
node
.
height
/
(
this
.
touchScratchRadius
*
2
));
...
...
This diff is collapsed.
Click to expand it.
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