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
Show 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 {
...
@@ -738,10 +738,14 @@ export default class Container extends DisplayObject {
// this.scale.x = 1;
// this.scale.x = 1;
// }
// }
if
(
this
.
_width
!==
value
)
{
if
(
this
.
_width
!==
value
)
{
if
(
!
value
&&
value
!=
0
)
{
this
.
_width
=
undefined
;
}
else
{
//子类有用,有_width,才需设置scaleX
//子类有用,有_width,才需设置scaleX
this
.
_width
=
value
;
this
.
_width
=
value
;
this
.
_localBoundsSelf
.
width
=
value
;
this
.
_localBoundsSelf
.
width
=
value
;
//if (this.stage) this.stage.layoutInvalid = true;
//if (this.stage) this.stage.layoutInvalid = true;
}
this
.
dispatchEvent
(
Event
.
RESIZE
);
this
.
dispatchEvent
(
Event
.
RESIZE
);
}
}
}
}
...
@@ -762,10 +766,14 @@ export default class Container extends DisplayObject {
...
@@ -762,10 +766,14 @@ export default class Container extends DisplayObject {
// } else {
// } else {
// this.scale.y = 1;
// this.scale.y = 1;
// }
// }
if
(
!
value
&&
value
!=
0
)
{
this
.
_height
=
undefined
;
}
else
{
if
(
this
.
_height
!==
value
)
{
if
(
this
.
_height
!==
value
)
{
this
.
_height
=
value
;
this
.
_height
=
value
;
this
.
_localBoundsSelf
.
height
=
value
;
this
.
_localBoundsSelf
.
height
=
value
;
//if (this.stage) this.stage.layoutInvalid = true;
//if (this.stage) this.stage.layoutInvalid = true;
}
this
.
dispatchEvent
(
Event
.
RESIZE
);
this
.
dispatchEvent
(
Event
.
RESIZE
);
}
}
}
}
...
...
src/2d/display/Sprite.ts
View file @
f4456b7c
...
@@ -94,9 +94,9 @@ export default class Sprite extends Container {
...
@@ -94,9 +94,9 @@ export default class Sprite extends Container {
this
.
_texture
=
null
;
this
.
_texture
=
null
;
this
.
_width
=
0
;
//
this._width = 0;
this
.
_height
=
0
;
//
this._height = 0;
this
.
_tint
=
null
;
this
.
_tint
=
null
;
this
.
_tintRGB
=
null
;
this
.
_tintRGB
=
null
;
...
@@ -391,14 +391,21 @@ export default class Sprite extends Container {
...
@@ -391,14 +391,21 @@ export default class Sprite extends Container {
* @member {number}
* @member {number}
*/
*/
get
width
()
{
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
)
{
set
width
(
value
)
{
if
(
this
.
_width
!==
value
)
{
if
(
!
value
&&
value
!=
0
)
{
this
.
scale
.
x
=
1
}
else
{
const
s
=
sign
(
this
.
scale
.
x
)
||
1
;
const
s
=
sign
(
this
.
scale
.
x
)
||
1
;
this
.
scale
.
x
=
s
*
value
/
this
.
_texture
.
orig
.
width
;
this
.
scale
.
x
=
s
*
value
/
this
.
_texture
.
orig
.
width
;
}
this
.
_width
=
value
;
this
.
_width
=
value
;
this
.
dispatchEvent
(
Event
.
RESIZE
);
}
}
}
/**
/**
...
@@ -406,13 +413,22 @@ export default class Sprite extends Container {
...
@@ -406,13 +413,22 @@ export default class Sprite extends Container {
* @member {number}
* @member {number}
*/
*/
get
height
()
{
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
)
{
set
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
;
const
s
=
sign
(
this
.
scale
.
y
)
||
1
;
this
.
scale
.
y
=
s
*
value
/
this
.
_texture
.
orig
.
height
;
this
.
scale
.
y
=
s
*
value
/
this
.
_texture
.
orig
.
height
;
}
this
.
_height
=
value
;
this
.
_height
=
value
;
this
.
dispatchEvent
(
Event
.
RESIZE
);
}
}
}
/**
/**
...
...
src/2d/text/TextField.ts
View file @
f4456b7c
...
@@ -169,28 +169,42 @@ export class TextField extends Sprite {
...
@@ -169,28 +169,42 @@ export class TextField extends Sprite {
// private _textHeight: number = 0;
// private _textHeight: number = 0;
get
width
():
number
{
get
width
():
number
{
if
(
this
.
_width
)
return
this
.
_width
;
if
(
!
this
.
_width
&&
this
.
_width
!=
0
)
{
this
.
updateText
();
this
.
updateText
();
return
this
.
scale
.
x
*
this
.
getLocalBounds
().
width
;
return
this
.
scale
.
x
*
this
.
getLocalBounds
().
width
;
}
else
{
return
this
.
_width
;
}
}
}
set
width
(
value
:
number
)
{
set
width
(
value
:
number
)
{
if
(
this
.
_width
!==
value
)
{
if
(
this
.
_width
!==
value
)
{
if
(
!
value
&&
value
!=
0
)
{
this
.
_width
=
undefined
;
}
else
{
this
.
_width
=
value
;
this
.
_width
=
value
;
}
this
.
dirty
=
true
;
this
.
dirty
=
true
;
this
.
dispatchEvent
(
Event
.
RESIZE
);
this
.
dispatchEvent
(
Event
.
RESIZE
);
}
}
}
}
get
height
():
number
{
get
height
():
number
{
if
(
this
.
_height
)
return
this
.
_height
;
if
(
!
this
.
_height
&&
this
.
_height
!=
0
)
{
this
.
updateText
();
this
.
updateText
();
return
this
.
scale
.
y
*
this
.
getLocalBounds
().
height
;
return
this
.
scale
.
y
*
this
.
getLocalBounds
().
height
;
}
else
{
return
this
.
_height
;
}
}
}
set
height
(
value
:
number
)
{
set
height
(
value
:
number
)
{
if
(
this
.
_height
!==
value
)
{
if
(
this
.
_height
!==
value
)
{
if
(
!
value
&&
value
!=
0
)
{
this
.
_height
=
undefined
;
}
else
{
this
.
_height
=
value
;
this
.
_height
=
value
;
}
this
.
dirty
=
true
;
this
.
dirty
=
true
;
this
.
dispatchEvent
(
Event
.
RESIZE
);
this
.
dispatchEvent
(
Event
.
RESIZE
);
}
}
...
@@ -588,7 +602,7 @@ export class TextField extends Sprite {
...
@@ -588,7 +602,7 @@ export class TextField extends Sprite {
if
(
!
text
)
{
if
(
!
text
)
{
s
.
canvas
.
width
=
0
;
s
.
canvas
.
width
=
0
;
s
.
canvas
.
height
=
0
;
s
.
canvas
.
height
=
0
;
if
(
!
this
.
_width
&&
!
this
.
_height
)
{
if
(
!
this
.
_width
&&
!
this
.
_height
)
{
s
.
_localBoundsSelf
.
clear
();
s
.
_localBoundsSelf
.
clear
();
}
}
this
.
anchorTexture
=
{
x
:
0
,
y
:
0
};
this
.
anchorTexture
=
{
x
:
0
,
y
:
0
};
...
@@ -611,7 +625,7 @@ export class TextField extends Sprite {
...
@@ -611,7 +625,7 @@ export class TextField extends Sprite {
s
.
realLines
=
realLines
;
s
.
realLines
=
realLines
;
s
.
_prepContext
(
ctx
);
s
.
_prepContext
(
ctx
);
let
textWidth
=
s
.
_width
;
let
textWidth
=
!
s
.
_width
&&
s
.
_width
!=
0
?
0
:
s
.
_width
;
// let lineH = s._lineSpacing + s.size;
// let lineH = s._lineSpacing + s.size;
//单行文本时
//单行文本时
if
(
isPureText
&&
text
.
indexOf
(
"
\n
"
)
<
0
&&
s
.
lineType
==
TEXT_lINETYPE
.
SINGLE
)
{
if
(
isPureText
&&
text
.
indexOf
(
"
\n
"
)
<
0
&&
s
.
lineType
==
TEXT_lINETYPE
.
SINGLE
)
{
...
@@ -639,7 +653,7 @@ export class TextField extends Sprite {
...
@@ -639,7 +653,7 @@ export class TextField extends Sprite {
}
}
}
else
{
}
else
{
//textWidth取每行最大值,如果没设置过textWidth
//textWidth取每行最大值,如果没设置过textWidth
const
shouldMeasureTextWidth
=
!
textWidth
;
const
shouldMeasureTextWidth
=
!
s
.
_width
&&
s
.
_width
!=
0
?
true
:
false
;
let
index
=
0
;
let
index
=
0
;
for
(
let
i
=
0
,
l
=
hardLines
.
length
;
i
<
l
;
i
++
)
{
for
(
let
i
=
0
,
l
=
hardLines
.
length
;
i
<
l
;
i
++
)
{
let
str
=
hardLines
[
i
];
let
str
=
hardLines
[
i
];
...
...
src/zeroing/game-warpper/EditorStage.ts
View file @
f4456b7c
...
@@ -10,8 +10,9 @@ import {devicePixelRatio} from "../../2d/const";
...
@@ -10,8 +10,9 @@ import {devicePixelRatio} from "../../2d/const";
import
{
Point
}
from
"../../2d/math/Point"
;
import
{
Point
}
from
"../../2d/math/Point"
;
const
propPrefixFilter
=
[
'_'
,
'__'
,
'$'
];
const
propPrefixFilter
=
[
'_'
,
'__'
,
'$'
];
const
includeProps
=
[
'_width'
,
'_height'
];
const
includeProps
=
[
'_width'
,
'_height'
,
'worldMatrix'
];
const
propTypeFilter
=
[
'function'
];
const
excludeProps
=
[
'eventTypes'
,
'eventTypes1'
,
'tempDisplayObjectParent'
,
'renderable'
,
'destroyed'
,
'children'
,
'start'
,
'pluginName'
,
'isUI'
,
'crossOrigin'
];
const
propTypeFilter
=
[
'function'
,
'object'
];
const
offsetPrefix
=
'offset_'
;
const
offsetPrefix
=
'offset_'
;
const
absValueMapping
=
{
const
absValueMapping
=
{
x
:
'a'
,
x
:
'a'
,
...
@@ -63,27 +64,39 @@ export class EditorStage extends Node {
...
@@ -63,27 +64,39 @@ export class EditorStage extends Node {
let
node2
=
{};
let
node2
=
{};
for
(
let
key
in
node
)
{
for
(
let
key
in
node
)
{
let
pass
=
false
;
let
pass
=
false
;
if
(
excludeProps
.
indexOf
(
key
)
>=
0
){
pass
=
true
;
}
if
(
!
pass
){
for
(
let
prefix
of
propPrefixFilter
)
{
for
(
let
prefix
of
propPrefixFilter
)
{
if
(
key
.
indexOf
(
prefix
)
>=
0
)
{
if
(
key
.
indexOf
(
prefix
)
>=
0
)
{
pass
=
true
;
pass
=
true
;
break
;
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
;
pass
=
false
;
}
}
if
(
pass
)
{
if
(
pass
)
{
continue
;
continue
;
}
}
let
v
=
node
[
key
];
if
(
propTypeFilter
.
indexOf
(
typeof
v
)
<
0
)
{
if
(
typeof
v
===
'object'
)
{
if
(
typeof
v
===
'object'
)
{
v
=
objClone
(
v
);
v
=
objClone
(
v
);
}
}
node2
[
key
]
=
v
;
node2
[
key
]
=
v
;
}
}
}
return
node2
;
return
node2
;
}
}
}
}
...
@@ -100,9 +113,9 @@ export class EditorStage extends Node {
...
@@ -100,9 +113,9 @@ export class EditorStage extends Node {
for
(
let
key
in
props
)
{
for
(
let
key
in
props
)
{
let
v
=
props
[
key
];
let
v
=
props
[
key
];
if
(
key
.
indexOf
(
offsetPrefix
)
<
0
)
{
if
(
key
.
indexOf
(
offsetPrefix
)
<
0
)
{
if
(
emptyProps
.
indexOf
(
key
)
>=
0
)
{
/*if(!v && v != 0 &&
emptyProps.indexOf(key) >= 0) {
key = '_' + key;
key = '_' + key;
}
}
*/
node
[
key
]
=
v
;
node
[
key
]
=
v
;
}
else
{
}
else
{
key
=
key
.
replace
(
offsetPrefix
,
''
);
key
=
key
.
replace
(
offsetPrefix
,
''
);
...
...
src/zeroing/game-warpper/nodes/shapes.ts
View file @
f4456b7c
...
@@ -32,9 +32,11 @@ class ShapeBase extends Graphics implements IUIComponent {
...
@@ -32,9 +32,11 @@ class ShapeBase extends Graphics implements IUIComponent {
private
onResize
(
e
)
{
private
onResize
(
e
)
{
this
.
__fieldDirty
=
true
;
this
.
__fieldDirty
=
true
;
//this.onEnterFrame();
}
}
private
onEnterFrame
(
e
)
{
private
onEnterFrame
(
e
=
null
)
{
if
(
this
.
__fieldDirty
)
{
if
(
this
.
__fieldDirty
)
{
this
.
__fieldDirty
=
false
;
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