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
dcdb6f57
Commit
dcdb6f57
authored
May 09, 2020
by
rockyl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
设计时适配
parent
78a9a144
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
93 additions
and
20 deletions
+93
-20
engine.js
debug/engine.js
+30
-1
engine.js.map
debug/engine.js.map
+1
-1
manifest.json
manifest.json
+1
-1
Container.ts
src/2d/display/Container.ts
+18
-0
EditorStage.ts
src/zeroing/game-warpper/EditorStage.ts
+21
-2
Image.ts
src/zeroing/game-warpper/nodes/Image.ts
+19
-14
launcher.ts
src/zeroing/launcher.ts
+3
-1
No files found.
debug/engine.js
View file @
dcdb6f57
...
@@ -3268,6 +3268,20 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
...
@@ -3268,6 +3268,20 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
return
this
;
return
this
;
}
}
};
};
Container
.
prototype
.
getIndexPath
=
function
(
untilNode
)
{
untilNode
=
untilNode
||
this
.
stage
;
var
node
=
this
;
var
path
=
[];
while
(
node
.
parent
)
{
var
child
=
node
;
node
=
node
.
parent
;
path
.
unshift
(
node
.
getChildIndex
(
child
));
if
(
node
===
untilNode
)
{
break
;
}
}
return
path
.
join
(
'/'
);
};
Container
.
prototype
.
findChildByUUID
=
function
(
uuid
)
{
Container
.
prototype
.
findChildByUUID
=
function
(
uuid
)
{
if
(
this
[
'uuid'
]
===
uuid
)
{
if
(
this
[
'uuid'
]
===
uuid
)
{
return
this
;
return
this
;
...
@@ -18992,6 +19006,9 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
...
@@ -18992,6 +19006,9 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
if
(
url
.
indexOf
(
'://'
)
>=
0
)
{
if
(
url
.
indexOf
(
'://'
)
>=
0
)
{
if
(
url
.
indexOf
(
assetScheme
)
===
0
)
{
if
(
url
.
indexOf
(
assetScheme
)
===
0
)
{
url
=
url
.
replace
(
assetScheme
,
''
);
url
=
url
.
replace
(
assetScheme
,
''
);
if
(
exports
.
editorMode
)
{
url
=
exports
.
assetResolver
(
url
);
}
}
}
}
}
else
{
else
{
...
@@ -20757,7 +20774,10 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
...
@@ -20757,7 +20774,10 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
tslib_1
.
__extends
(
EditorStage
,
_super
);
tslib_1
.
__extends
(
EditorStage
,
_super
);
function
EditorStage
(
stage
)
{
function
EditorStage
(
stage
)
{
var
_this
=
_super
.
call
(
this
)
||
this
;
var
_this
=
_super
.
call
(
this
)
||
this
;
_this
.
_pos
=
new
Point
();
_this
.
name
=
'editor-stage'
;
_this
.
name
=
'editor-stage'
;
_this
.
percentWidth
=
100
;
_this
.
percentHeight
=
100
;
return
_this
;
return
_this
;
}
}
EditorStage
.
prototype
.
launch
=
function
(
onStart
)
{
EditorStage
.
prototype
.
launch
=
function
(
onStart
)
{
...
@@ -20807,6 +20827,7 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
...
@@ -20807,6 +20827,7 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
var
node
=
this
.
getNode
(
nodePath
,
true
);
var
node
=
this
.
getNode
(
nodePath
,
true
);
if
(
node
)
{
if
(
node
)
{
injectProperties
(
node
,
props
);
injectProperties
(
node
,
props
);
node
.
adjustProxy
.
adjustLayout
();
return
true
;
return
true
;
}
}
else
{
else
{
...
@@ -20814,6 +20835,13 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
...
@@ -20814,6 +20835,13 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
return
false
;
return
false
;
}
}
};
};
EditorStage
.
prototype
.
getNodeWithPos
=
function
(
pos
)
{
var
globalPos
=
this
.
stage
.
globalToLocal
(
pos
,
this
.
_pos
);
globalPos
.
x
*=
devicePixelRatio
;
globalPos
.
y
*=
devicePixelRatio
;
var
node
=
this
.
hitTestPoint
(
globalPos
,
true
);
return
node
;
};
return
EditorStage
;
return
EditorStage
;
}(
Node$1
));
}(
Node$1
));
...
@@ -20853,8 +20881,9 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
...
@@ -20853,8 +20881,9 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
case
1
:
case
1
:
_a
.
sent
();
_a
.
sent
();
return
[
4
,
new
Promise
(
function
(
resolve
)
{
return
[
4
,
new
Promise
(
function
(
resolve
)
{
var
_a
=
config
.
options
,
containerId
=
_a
.
containerId
,
designWidth
=
_a
.
designWidth
,
designHeight
=
_a
.
designHeight
,
frameRate
=
_a
.
frameRate
,
scaleMode
=
_a
.
scaleMode
,
rendererType
=
_a
.
rendererType
,
bgColor
=
_a
.
bgColor
,
autoResize
=
_a
.
autoResize
,
_editorMode
=
_a
.
editorMode
;
var
_a
=
config
.
options
,
containerId
=
_a
.
containerId
,
designWidth
=
_a
.
designWidth
,
designHeight
=
_a
.
designHeight
,
frameRate
=
_a
.
frameRate
,
scaleMode
=
_a
.
scaleMode
,
rendererType
=
_a
.
rendererType
,
bgColor
=
_a
.
bgColor
,
autoResize
=
_a
.
autoResize
,
_editorMode
=
_a
.
editorMode
,
_assetResolver
=
_a
.
assetResolver
;
exports
.
editorMode
=
_editorMode
;
exports
.
editorMode
=
_editorMode
;
exports
.
assetResolver
=
_assetResolver
;
var
stage
=
window
[
'stage'
]
=
new
Stage
(
containerId
||
"game-container"
,
designWidth
||
750
,
designHeight
||
1334
,
frameRate
||
60
,
scaleMode
||
StageScaleMode
.
FIXED_WIDTH
,
rendererType
||
exports
.
RENDERER_TYPE
.
WEBGL
,
true
,
bgColor
,
autoResize
);
var
stage
=
window
[
'stage'
]
=
new
Stage
(
containerId
||
"game-container"
,
designWidth
||
750
,
designHeight
||
1334
,
frameRate
||
60
,
scaleMode
||
StageScaleMode
.
FIXED_WIDTH
,
rendererType
||
exports
.
RENDERER_TYPE
.
WEBGL
,
true
,
bgColor
,
autoResize
);
initAutoLayout
(
stage
);
initAutoLayout
(
stage
);
Stage
.
flushAll
();
Stage
.
flushAll
();
...
...
debug/engine.js.map
View file @
dcdb6f57
This source diff could not be displayed because it is too large. You can
view the blob
instead.
manifest.json
View file @
dcdb6f57
{
"id"
:
"engine"
,
"url"
:
"engine.d2f4eafa108b00ed5ac00e2d30ee98f8af4a9118.js"
}
{
"id"
:
"engine"
,
"url"
:
"engine.50767b1fe652a3daf7f557e5cfb9eaa6090fc805.js"
}
\ No newline at end of file
\ No newline at end of file
src/2d/display/Container.ts
View file @
dcdb6f57
...
@@ -278,6 +278,24 @@ export default class Container extends DisplayObject {
...
@@ -278,6 +278,24 @@ export default class Container extends DisplayObject {
}
}
}
}
/**
* 获取索引路径
*/
getIndexPath
(
untilNode
?):
string
{
untilNode
=
untilNode
||
this
.
stage
;
let
node
=
this
;
let
path
=
[];
while
(
node
.
parent
)
{
let
child
=
node
;
node
=
node
.
parent
;
path
.
unshift
(
node
.
getChildIndex
(
child
));
if
(
node
===
untilNode
)
{
break
;
}
}
return
path
.
join
(
'/'
);
}
/**
/**
* 根据uuid搜索子节点
* 根据uuid搜索子节点
* @param uuid
* @param uuid
...
...
src/zeroing/game-warpper/EditorStage.ts
View file @
dcdb6f57
...
@@ -6,6 +6,8 @@ import {Stage} from "../../2d/display/index";
...
@@ -6,6 +6,8 @@ import {Stage} from "../../2d/display/index";
import
{
Node
}
from
"./nodes/Node"
;
import
{
Node
}
from
"./nodes/Node"
;
import
{
instantiate
}
from
"./view-interpreter"
;
import
{
instantiate
}
from
"./view-interpreter"
;
import
{
injectProperties
,
objClone
}
from
"../utils/utils"
;
import
{
injectProperties
,
objClone
}
from
"../utils/utils"
;
import
{
devicePixelRatio
}
from
"../../2d/const"
;
import
{
Point
}
from
"../../2d/math/Point"
;
const
propPrefixFilter
=
[
'_'
,
'__'
,
'$'
];
const
propPrefixFilter
=
[
'_'
,
'__'
,
'$'
];
const
propTypeFilter
=
[
'object'
,
'function'
];
const
propTypeFilter
=
[
'object'
,
'function'
];
...
@@ -20,6 +22,9 @@ export class EditorStage extends Node {
...
@@ -20,6 +22,9 @@ export class EditorStage extends Node {
super
();
super
();
this
.
name
=
'editor-stage'
;
this
.
name
=
'editor-stage'
;
this
.
percentWidth
=
100
;
this
.
percentHeight
=
100
;
}
}
launch
(
onStart
)
{
launch
(
onStart
)
{
...
@@ -37,9 +42,9 @@ export class EditorStage extends Node {
...
@@ -37,9 +42,9 @@ export class EditorStage extends Node {
getNode
(
nodePath
,
origin
=
false
):
any
{
getNode
(
nodePath
,
origin
=
false
):
any
{
let
node
=
this
.
_view
.
getChildByIndexPath
(
nodePath
);
let
node
=
this
.
_view
.
getChildByIndexPath
(
nodePath
);
if
(
node
)
{
if
(
node
)
{
if
(
origin
)
{
if
(
origin
)
{
return
node
;
return
node
;
}
else
{
}
else
{
let
node2
=
{};
let
node2
=
{};
for
(
let
key
in
node
)
{
for
(
let
key
in
node
)
{
let
pass
=
false
;
let
pass
=
false
;
...
@@ -71,10 +76,24 @@ export class EditorStage extends Node {
...
@@ -71,10 +76,24 @@ export class EditorStage extends Node {
if
(
node
)
{
if
(
node
)
{
injectProperties
(
node
,
props
);
injectProperties
(
node
,
props
);
node
.
adjustProxy
.
adjustLayout
();
return
true
;
return
true
;
}
else
{
}
else
{
console
.
warn
(
'node not found:'
,
nodePath
);
console
.
warn
(
'node not found:'
,
nodePath
);
return
false
;
return
false
;
}
}
}
}
private
_pos
=
new
Point
();
getNodeWithPos
(
pos
)
{
let
globalPos
:
any
=
this
.
stage
.
globalToLocal
(
pos
,
this
.
_pos
);
globalPos
.
x
*=
devicePixelRatio
;
globalPos
.
y
*=
devicePixelRatio
;
let
node
=
this
.
hitTestPoint
(
globalPos
,
true
);
//console.log(globalPos.x, globalPos.y, node ? node.name : '');
return
node
;
}
}
}
src/zeroing/game-warpper/nodes/Image.ts
View file @
dcdb6f57
...
@@ -9,6 +9,7 @@ import {ESCAPE_REG_EXP} from "../../utils/index";
...
@@ -9,6 +9,7 @@ import {ESCAPE_REG_EXP} from "../../utils/index";
import
{
Event
}
from
"../../../2d/events/index"
;
import
{
Event
}
from
"../../../2d/events/index"
;
import
{
Container
}
from
"../../../2d/display/index"
;
import
{
Container
}
from
"../../../2d/display/index"
;
import
{
IUIComponent
}
from
"./IUIComponent"
;
import
{
IUIComponent
}
from
"./IUIComponent"
;
import
{
assetResolver
,
editorMode
}
from
"../../launcher"
;
const
assetScheme
=
'asset://'
;
const
assetScheme
=
'asset://'
;
...
@@ -36,21 +37,25 @@ export class Image extends Sprite implements IUIComponent {
...
@@ -36,21 +37,25 @@ export class Image extends Sprite implements IUIComponent {
private
updateSource
()
{
private
updateSource
()
{
let
url
=
this
.
_source
;
let
url
=
this
.
_source
;
if
(
url
)
{
if
(
url
)
{
if
(
url
.
indexOf
(
'://'
)
>=
0
)
{
//如果是有协议的地址
if
(
url
.
indexOf
(
'://'
)
>=
0
)
{
//如果是有协议的地址
if
(
url
.
indexOf
(
assetScheme
)
===
0
)
{
if
(
url
.
indexOf
(
assetScheme
)
===
0
)
{
url
=
url
.
replace
(
assetScheme
,
''
);
url
=
url
.
replace
(
assetScheme
,
''
);
/*const assetConfig = getAssetByUUID(uuid);
/*const assetConfig = getAssetByUUID(uuid);
if(assetConfig){
if(assetConfig){
url = assetConfig.url;
url = assetConfig.url;
this.texture = Texture.fromImage(url);
this.texture = Texture.fromImage(url);
}*/
}*/
}
}
else
{
//否则就使用素材名
if
(
editorMode
)
{
const
assetConfig
=
getAssetByName
(
url
);
url
=
assetResolver
(
url
);
if
(
assetConfig
)
{
}
url
=
assetConfig
.
uuid
;
}
}
else
{
//否则就使用素材名
const
assetConfig
=
getAssetByName
(
url
);
if
(
assetConfig
)
{
url
=
assetConfig
.
uuid
;
}
}
}
}
this
.
texture
=
Texture
.
fromImage
(
url
,
this
.
crossOrigin
);
this
.
texture
=
Texture
.
fromImage
(
url
,
this
.
crossOrigin
);
}
else
{
}
else
{
this
.
texture
=
null
;
this
.
texture
=
null
;
...
...
src/zeroing/launcher.ts
View file @
dcdb6f57
...
@@ -17,6 +17,7 @@ export let gameStage: GameStage;
...
@@ -17,6 +17,7 @@ export let gameStage: GameStage;
export
let
editorStage
:
EditorStage
;
export
let
editorStage
:
EditorStage
;
export
let
editorMode
=
false
;
export
let
editorMode
=
false
;
export
let
assetResolver
;
export
function
launch
(
url
,
loadingDelegate
?,
onStart
?)
{
export
function
launch
(
url
,
loadingDelegate
?,
onStart
?)
{
if
(
queryParams
.
__proxy_mode__
)
{
if
(
queryParams
.
__proxy_mode__
)
{
...
@@ -55,8 +56,9 @@ export async function launchWithConfig(config, loadingDelegate?, onStart?) {
...
@@ -55,8 +56,9 @@ export async function launchWithConfig(config, loadingDelegate?, onStart?) {
setTimeout
(
resolve
,
300
);
setTimeout
(
resolve
,
300
);
});
});
return
await
new
Promise
(
resolve
=>
{
return
await
new
Promise
(
resolve
=>
{
const
{
containerId
,
designWidth
,
designHeight
,
frameRate
,
scaleMode
,
rendererType
,
bgColor
,
autoResize
,
editorMode
:
_editorMode
,
}
=
config
.
options
;
const
{
containerId
,
designWidth
,
designHeight
,
frameRate
,
scaleMode
,
rendererType
,
bgColor
,
autoResize
,
editorMode
:
_editorMode
,
assetResolver
:
_assetResolver
}
=
config
.
options
;
editorMode
=
_editorMode
;
editorMode
=
_editorMode
;
assetResolver
=
_assetResolver
;
let
stage
=
window
[
'stage'
]
=
new
Stage
(
let
stage
=
window
[
'stage'
]
=
new
Stage
(
containerId
||
"game-container"
,
containerId
||
"game-container"
,
...
...
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