Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
renderingEngine
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
王剑峰
renderingEngine
Commits
29783cac
Commit
29783cac
authored
Nov 08, 2019
by
wjf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
l
parent
f987a9a6
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
8 additions
and
46 deletions
+8
-46
Container.ts
src/2d/display/Container.ts
+1
-2
Sprite.ts
src/2d/display/Sprite.ts
+0
-17
Stage.ts
src/2d/display/Stage.ts
+5
-3
Graphics.ts
src/2d/graphics/Graphics.ts
+2
-24
No files found.
src/2d/display/Container.ts
View file @
29783cac
...
...
@@ -381,10 +381,9 @@ export default class Container extends DisplayObject {
* 重写父类方法
*/
hitTestPoint
(
globalPoint
:
Point
,
isMouseEvent
:
boolean
=
false
)
{
//如果不可见
if
(
!
this
.
visible
)
return
null
//如果禁止子级的鼠标事件
// if (isMouseEvent && !this.mouseEnabled) return null;
//禁止子级的事件
if
(
isMouseEvent
&&
!
this
.
mouseChildren
)
return
null
;
var
children
=
this
.
children
;
var
length
=
children
.
length
...
...
src/2d/display/Sprite.ts
View file @
29783cac
...
...
@@ -334,23 +334,6 @@ export default class Sprite extends Container {
* @param isMouseEvent
*/
hitTestPoint
(
globalPoint
:
Point
,
isMouseEvent
:
boolean
=
false
)
{
/*if (!this.visible) return null
//如果禁止子级的鼠标事件
if (isMouseEvent && !this.mouseEnabled) return null;
//如果以后加缓存成位图,另写
let hitDisplayObject;
//先检查子级,因为子级层级更高
hitDisplayObject = super.hitTestPoint(globalPoint, isMouseEvent);
//子级已有,返回
if (hitDisplayObject) return hitDisplayObject;
//检查自己
hitDisplayObject = this.displayObjectHitTestPoint(globalPoint, isMouseEvent);
if (hitDisplayObject) return hitDisplayObject;
return null;*/
//不可见,返回
if
(
!
this
.
visible
)
return
null
if
(
isMouseEvent
&&
!
this
.
mouseEnabled
&&
!
this
.
mouseChildren
)
return
null
;
let
hitDisplayObject
;
//先检查子级,因为子级层级更高
hitDisplayObject
=
super
.
hitTestPoint
(
globalPoint
,
isMouseEvent
);
...
...
src/2d/display/Stage.ts
View file @
29783cac
...
...
@@ -683,7 +683,7 @@ export class Stage extends Container {
if
(
eLen
>
0
)
{
//有事件开始遍历显示列表
//找出最底层的显示对象
let
d
:
any
=
s
.
hitTestPoint
(
cp
,
true
);
let
d
:
DisplayObject
=
s
.
hitTestPoint
(
cp
,
true
);
// console.log(d)
let
displayList
:
Array
<
DisplayObject
>
=
[];
if
(
d
)
{
...
...
@@ -705,7 +705,8 @@ export class Stage extends Container {
d
=
displayList
[
i
];
for
(
let
j
=
0
;
j
<
eLen
;
j
++
)
{
if
(
!
events
[
j
][
"_bpd"
])
{
if
(
d
.
hasEventListener
(
events
[
j
].
type
))
{
//有事件,且mouseEnabled为true
if
(
d
.
hasEventListener
(
events
[
j
].
type
)
&&
d
.
mouseEnabled
)
{
events
[
j
].
currentTarget
=
d
;
events
[
j
].
target
=
displayList
[
0
];
lp
=
d
.
globalToLocal
(
cp
,
DisplayObject
.
_bp
);
...
...
@@ -722,7 +723,8 @@ export class Stage extends Container {
d
=
displayList
[
i
];
for
(
let
j
=
0
;
j
<
eLen
;
j
++
)
{
if
(
!
events
[
j
][
"_bpd"
])
{
if
(
d
.
hasEventListener
(
events
[
j
].
type
))
{
//有事件,且mouseEnabled为true
if
(
d
.
hasEventListener
(
events
[
j
].
type
)
&&
d
.
mouseEnabled
)
{
events
[
j
].
currentTarget
=
d
;
events
[
j
].
target
=
displayList
[
eLen
-
1
];
lp
=
d
.
globalToLocal
(
cp
,
DisplayObject
.
_bp
);
...
...
src/2d/graphics/Graphics.ts
View file @
29783cac
...
...
@@ -1130,35 +1130,13 @@ export default class Graphics extends Container {
* @param {Point} point - the point to test
*/
hitTestPoint
(
point
:
Point
,
isMouseEvent
:
boolean
=
false
):
DisplayObject
{
/*let s = this;
if (!s.visible) return null;
if (isMouseEvent && !s.mouseEnabled) return null;
let hitDisplayObject;
//先检查子级,因为子级层级更高
hitDisplayObject = super.hitTestPoint(point, isMouseEvent);
//子级已有,返回
if (hitDisplayObject) return hitDisplayObject
//再粗略检查自己,先计算自身盒子
this.updateLocalBoundsSelf();
hitDisplayObject = this.displayObjectHitTestPoint(point, isMouseEvent);
//如果
if (hitDisplayObject) {
//不需要像素级检测直接返回
if (!s.hitTestByPixel) return hitDisplayObject;
//精确检测
return this.hitTestPointAccuratly(point)
}
return null*/
//不可见,返回
if
(
!
this
.
visible
)
return
null
if
(
isMouseEvent
&&
!
this
.
mouseEnabled
&&
!
this
.
mouseChildren
)
return
null
;
let
hitDisplayObject
;
//先检查子级,因为子级层级更高
hitDisplayObject
=
super
.
hitTestPoint
(
point
,
isMouseEvent
);
//子级已有,返回
if
(
hitDisplayObject
)
return
hitDisplayObject
;
//子级没有的话,为了可以不updateLocalBoundsSelf,判断一下
if
(
isMouseEvent
&&
!
this
.
mouseEnabled
)
return
null
;
//再粗略检查自己,先计算自身盒子
this
.
updateLocalBoundsSelf
();
hitDisplayObject
=
this
.
displayObjectHitTestPoint
(
point
,
isMouseEvent
);
...
...
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