Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Z
zeroing-engine
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
劳工
zeroing-engine
Commits
f4456b7c
Commit
f4456b7c
authored
May 19, 2020
by
rockyl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复
parent
b804b07c
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
98 additions
and
45 deletions
+98
-45
Container.ts
src/2d/display/Container.ts
+16
-8
Sprite.ts
src/2d/display/Sprite.ts
+26
-10
TextField.ts
src/2d/text/TextField.ts
+25
-11
EditorStage.ts
src/zeroing/game-warpper/EditorStage.ts
+28
-15
shapes.ts
src/zeroing/game-warpper/nodes/shapes.ts
+3
-1
No files found.
src/2d/display/Container.ts
View file @
f4456b7c
...
...
@@ -738,10 +738,14 @@ export default class Container extends DisplayObject {
// this.scale.x = 1;
// }
if
(
this
.
_width
!==
value
)
{
//子类有用,有_width,才需设置scaleX
this
.
_width
=
value
;
this
.
_localBoundsSelf
.
width
=
value
;
//if (this.stage) this.stage.layoutInvalid = true;
if
(
!
value
&&
value
!=
0
)
{
this
.
_width
=
undefined
;
}
else
{
//子类有用,有_width,才需设置scaleX
this
.
_width
=
value
;
this
.
_localBoundsSelf
.
width
=
value
;
//if (this.stage) this.stage.layoutInvalid = true;
}
this
.
dispatchEvent
(
Event
.
RESIZE
);
}
}
...
...
@@ -762,10 +766,14 @@ export default class Container extends DisplayObject {
// } else {
// this.scale.y = 1;
// }
if
(
this
.
_height
!==
value
)
{
this
.
_height
=
value
;
this
.
_localBoundsSelf
.
height
=
value
;
//if (this.stage) this.stage.layoutInvalid = true;
if
(
!
value
&&
value
!=
0
)
{
this
.
_height
=
undefined
;
}
else
{
if
(
this
.
_height
!==
value
)
{
this
.
_height
=
value
;
this
.
_localBoundsSelf
.
height
=
value
;
//if (this.stage) this.stage.layoutInvalid = true;
}
this
.
dispatchEvent
(
Event
.
RESIZE
);
}
}
...
...
src/2d/display/Sprite.ts
View file @
f4456b7c
...
...
@@ -94,9 +94,9 @@ export default class Sprite extends Container {
this
.
_texture
=
null
;
this
.
_width
=
0
;
//
this._width = 0;
this
.
_height
=
0
;
//
this._height = 0;
this
.
_tint
=
null
;
this
.
_tintRGB
=
null
;
...
...
@@ -391,14 +391,21 @@ export default class Sprite extends Container {
* @member {number}
*/
get
width
()
{
return
Math
.
abs
(
this
.
scale
.
x
)
*
this
.
_texture
.
orig
.
width
;
return
this
.
_width
||
Math
.
abs
(
this
.
scale
.
x
)
*
this
.
_texture
.
orig
.
width
;
}
set
width
(
value
)
{
const
s
=
sign
(
this
.
scale
.
x
)
||
1
;
if
(
this
.
_width
!==
value
)
{
if
(
!
value
&&
value
!=
0
)
{
this
.
scale
.
x
=
1
}
else
{
const
s
=
sign
(
this
.
scale
.
x
)
||
1
;
this
.
scale
.
x
=
s
*
value
/
this
.
_texture
.
orig
.
width
;
this
.
_width
=
value
;
this
.
scale
.
x
=
s
*
value
/
this
.
_texture
.
orig
.
width
;
}
this
.
_width
=
value
;
this
.
dispatchEvent
(
Event
.
RESIZE
);
}
}
/**
...
...
@@ -406,13 +413,22 @@ export default class Sprite extends Container {
* @member {number}
*/
get
height
()
{
return
Math
.
abs
(
this
.
scale
.
y
)
*
this
.
_texture
.
orig
.
height
;
return
this
.
_height
||
Math
.
abs
(
this
.
scale
.
y
)
*
this
.
_texture
.
orig
.
height
;
}
set
height
(
value
)
{
const
s
=
sign
(
this
.
scale
.
y
)
||
1
;
this
.
scale
.
y
=
s
*
value
/
this
.
_texture
.
orig
.
height
;
this
.
_height
=
value
;
if
(
!
value
&&
value
!=
0
)
{
this
.
_height
=
undefined
;
}
else
{
if
(
!
value
&&
value
!=
0
)
{
this
.
scale
.
y
=
1
}
else
{
const
s
=
sign
(
this
.
scale
.
y
)
||
1
;
this
.
scale
.
y
=
s
*
value
/
this
.
_texture
.
orig
.
height
;
}
this
.
_height
=
value
;
this
.
dispatchEvent
(
Event
.
RESIZE
);
}
}
/**
...
...
src/2d/text/TextField.ts
View file @
f4456b7c
...
...
@@ -169,28 +169,42 @@ export class TextField extends Sprite {
// private _textHeight: number = 0;
get
width
():
number
{
if
(
this
.
_width
)
return
this
.
_width
;
this
.
updateText
();
return
this
.
scale
.
x
*
this
.
getLocalBounds
().
width
;
if
(
!
this
.
_width
&&
this
.
_width
!=
0
)
{
this
.
updateText
();
return
this
.
scale
.
x
*
this
.
getLocalBounds
().
width
;
}
else
{
return
this
.
_width
;
}
}
set
width
(
value
:
number
)
{
if
(
this
.
_width
!==
value
)
{
this
.
_width
=
value
;
if
(
!
value
&&
value
!=
0
)
{
this
.
_width
=
undefined
;
}
else
{
this
.
_width
=
value
;
}
this
.
dirty
=
true
;
this
.
dispatchEvent
(
Event
.
RESIZE
);
}
}
get
height
():
number
{
if
(
this
.
_height
)
return
this
.
_height
;
this
.
updateText
();
return
this
.
scale
.
y
*
this
.
getLocalBounds
().
height
;
if
(
!
this
.
_height
&&
this
.
_height
!=
0
)
{
this
.
updateText
();
return
this
.
scale
.
y
*
this
.
getLocalBounds
().
height
;
}
else
{
return
this
.
_height
;
}
}
set
height
(
value
:
number
)
{
if
(
this
.
_height
!==
value
)
{
this
.
_height
=
value
;
if
(
!
value
&&
value
!=
0
)
{
this
.
_height
=
undefined
;
}
else
{
this
.
_height
=
value
;
}
this
.
dirty
=
true
;
this
.
dispatchEvent
(
Event
.
RESIZE
);
}
...
...
@@ -588,7 +602,7 @@ export class TextField extends Sprite {
if
(
!
text
)
{
s
.
canvas
.
width
=
0
;
s
.
canvas
.
height
=
0
;
if
(
!
this
.
_width
&&
!
this
.
_height
)
{
if
(
!
this
.
_width
&&
!
this
.
_height
)
{
s
.
_localBoundsSelf
.
clear
();
}
this
.
anchorTexture
=
{
x
:
0
,
y
:
0
};
...
...
@@ -611,7 +625,7 @@ export class TextField extends Sprite {
s
.
realLines
=
realLines
;
s
.
_prepContext
(
ctx
);
let
textWidth
=
s
.
_width
;
let
textWidth
=
!
s
.
_width
&&
s
.
_width
!=
0
?
0
:
s
.
_width
;
// let lineH = s._lineSpacing + s.size;
//单行文本时
if
(
isPureText
&&
text
.
indexOf
(
"
\n
"
)
<
0
&&
s
.
lineType
==
TEXT_lINETYPE
.
SINGLE
)
{
...
...
@@ -639,7 +653,7 @@ export class TextField extends Sprite {
}
}
else
{
//textWidth取每行最大值,如果没设置过textWidth
const
shouldMeasureTextWidth
=
!
textWidth
;
const
shouldMeasureTextWidth
=
!
s
.
_width
&&
s
.
_width
!=
0
?
true
:
false
;
let
index
=
0
;
for
(
let
i
=
0
,
l
=
hardLines
.
length
;
i
<
l
;
i
++
)
{
let
str
=
hardLines
[
i
];
...
...
src/zeroing/game-warpper/EditorStage.ts
View file @
f4456b7c
...
...
@@ -10,8 +10,9 @@ import {devicePixelRatio} from "../../2d/const";
import
{
Point
}
from
"../../2d/math/Point"
;
const
propPrefixFilter
=
[
'_'
,
'__'
,
'$'
];
const
includeProps
=
[
'_width'
,
'_height'
];
const
propTypeFilter
=
[
'function'
];
const
includeProps
=
[
'_width'
,
'_height'
,
'worldMatrix'
];
const
excludeProps
=
[
'eventTypes'
,
'eventTypes1'
,
'tempDisplayObjectParent'
,
'renderable'
,
'destroyed'
,
'children'
,
'start'
,
'pluginName'
,
'isUI'
,
'crossOrigin'
];
const
propTypeFilter
=
[
'function'
,
'object'
];
const
offsetPrefix
=
'offset_'
;
const
absValueMapping
=
{
x
:
'a'
,
...
...
@@ -63,26 +64,38 @@ export class EditorStage extends Node {
let
node2
=
{};
for
(
let
key
in
node
)
{
let
pass
=
false
;
for
(
let
prefix
of
propPrefixFilter
)
{
if
(
key
.
indexOf
(
prefix
)
>=
0
)
{
pass
=
true
;
break
;
if
(
excludeProps
.
indexOf
(
key
)
>=
0
){
pass
=
true
;
}
if
(
!
pass
){
for
(
let
prefix
of
propPrefixFilter
)
{
if
(
key
.
indexOf
(
prefix
)
>=
0
)
{
pass
=
true
;
break
;
}
}
}
if
(
pass
&&
includeProps
.
indexOf
(
key
)
>
0
)
{
if
(
key
===
'width'
){
//debugger
}
let
v
=
node
[
key
];
if
(
propTypeFilter
.
indexOf
(
typeof
v
)
>=
0
)
{
pass
=
true
;
}
if
(
includeProps
.
indexOf
(
key
)
>=
0
)
{
pass
=
false
;
}
if
(
pass
)
{
continue
;
}
let
v
=
node
[
key
];
if
(
propTypeFilter
.
indexOf
(
typeof
v
)
<
0
)
{
if
(
typeof
v
===
'object'
)
{
v
=
objClone
(
v
);
}
node2
[
key
]
=
v
;
if
(
typeof
v
===
'object'
)
{
v
=
objClone
(
v
);
}
node2
[
key
]
=
v
;
}
return
node2
;
}
...
...
@@ -100,9 +113,9 @@ export class EditorStage extends Node {
for
(
let
key
in
props
)
{
let
v
=
props
[
key
];
if
(
key
.
indexOf
(
offsetPrefix
)
<
0
)
{
if
(
emptyProps
.
indexOf
(
key
)
>=
0
)
{
/*if(!v && v != 0 &&
emptyProps.indexOf(key) >= 0) {
key = '_' + key;
}
}
*/
node
[
key
]
=
v
;
}
else
{
key
=
key
.
replace
(
offsetPrefix
,
''
);
...
...
src/zeroing/game-warpper/nodes/shapes.ts
View file @
f4456b7c
...
...
@@ -32,9 +32,11 @@ class ShapeBase extends Graphics implements IUIComponent {
private
onResize
(
e
)
{
this
.
__fieldDirty
=
true
;
//this.onEnterFrame();
}
private
onEnterFrame
(
e
)
{
private
onEnterFrame
(
e
=
null
)
{
if
(
this
.
__fieldDirty
)
{
this
.
__fieldDirty
=
false
;
...
...
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