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
ee17ddaa
Commit
ee17ddaa
authored
Nov 26, 2019
by
rockyl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
data类型修改为dynamic
增加map类型
parent
b68b29df
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
193 additions
and
19 deletions
+193
-19
index.html
examples/index.html
+26
-2
index.js
examples/index.js
+35
-0
package.json
package.json
+3
-2
rollup.config.js
rollup.config.js
+1
-2
Process.ts
src/zeroing/behavior-runtime/Process.ts
+19
-11
GameStage.ts
src/zeroing/game-warpper/GameStage.ts
+3
-1
Toast.ts
src/zeroing/game-warpper/Toast.ts
+64
-0
view-interpreter.ts
src/zeroing/game-warpper/view-interpreter.ts
+3
-1
utils.ts
src/zeroing/utils/utils.ts
+39
-0
No files found.
examples/index.html
View file @
ee17ddaa
...
...
@@ -2,9 +2,33 @@
<html
lang=
"en"
>
<head>
<meta
charset=
"UTF-8"
>
<title>
Examples
</title>
<title>
GameStage
</title>
<meta
name=
"viewport"
content=
"width=device-width,initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no"
/>
<meta
name=
"apple-mobile-web-app-capable"
content=
"yes"
/>
<meta
name=
"full-screen"
content=
"true"
/>
<meta
name=
"screen-orientation"
content=
"portrait"
/>
<meta
name=
"x5-fullscreen"
content=
"true"
/>
<meta
name=
"360-fullscreen"
content=
"true"
/>
<!-- <meta name="viewport" content="width=device-width,minimum-scale=1.0,user-scalable=no"> -->
<style>
html
,
body
{
padding
:
0
;
margin
:
0
;
border
:
0
;
width
:
100%
;
height
:
100%
;
overflow
:
hidden
;
position
:
absolute
;
background-color
:
white
;
}
</style>
</head>
<body>
<div
id=
"game-container"
style=
"line-height:0;font-size:0"
></div>
<script
type=
"text/javascript"
src=
"../dist/engine.js"
></script>
<script
src=
"index.js"
></script>
</body>
</html>
\ No newline at end of file
examples/index.js
0 → 100644
View file @
ee17ddaa
/**
* Created by rockyl on 2019-11-24.
*/
let
stage
=
window
[
'stage'
]
=
new
engine
.
Stage
(
"game-container"
,
750
,
1334
,
60
,
engine
.
StageScaleMode
.
FIXED_WIDTH
,
engine
.
RENDERER_TYPE
.
WEBGL
);
engine
.
Stage
.
flushAll
();
const
scrollView
=
new
engine
.
Container
();
stage
.
addChild
(
scrollView
);
/*let scrollView = new engine.ScrollView();
scrollView.x = 100;
scrollView.y = 100;
scrollView.width = 100;
scrollView.height = 100;
stage.addChild(scrollView);*/
let
rect
=
new
engine
.
Rect
();
rect
.
fillColor
=
'orange'
;
rect
.
strokeWidth
=
1
;
rect
.
width
=
200
;
rect
.
height
=
200
;
scrollView
.
addChild
(
rect
);
setTimeout
(()
=>
{
console
.
log
(
rect
.
width
,
rect
.
height
,
rect
.
getBounds
().
width
);
console
.
log
(
scrollView
.
width
);
},
200
);
package.json
View file @
ee17ddaa
...
...
@@ -26,9 +26,10 @@
},
"scripts"
:
{
"build-webpack"
:
"webpack"
,
"rollup"
:
"rollup -c"
,
"rollup"
:
"rollup -c -o dist/engine.js"
,
"rollup:debug"
:
"rollup -c -m "
,
"rename"
:
"node scripts/rename-hash.js dist/engine.js"
,
"build"
:
"yarn rollup && yarn rename"
,
"build"
:
"
rm -rf dist&&
yarn rollup && yarn rename"
,
"ts"
:
"dts-bundle --name engine --main types/src/index.d.ts --out ../../dist/index.d.ts"
,
"test"
:
"echo
\"
Error: no test specified
\"
&& exit 1"
,
"dev"
:
"webpack -w"
,
...
...
rollup.config.js
View file @
ee17ddaa
...
...
@@ -12,10 +12,9 @@ export default {
input
:
'src/index.ts'
,
output
:
[
{
file
:
`d
ist
/engine.js`
,
file
:
`d
ebug
/engine.js`
,
format
:
'umd'
,
name
:
'engine'
,
sourcemap
:
true
,
}
],
plugins
:
[
...
...
src/zeroing/behavior-runtime/Process.ts
View file @
ee17ddaa
...
...
@@ -7,6 +7,7 @@ import {VM} from "./VM";
import
{
getDataByPath
,
linkedFlag
,
nodeScheme
,
objClone
}
from
"../utils"
;
import
{
findNodeByUUID
}
from
"../node-utils"
;
import
{
dataCenter
}
from
"../game-warpper/data-center"
;
import
{
env
}
from
"../game-warpper/enviroment"
;
const
log
=
true
;
...
...
@@ -91,7 +92,7 @@ export class Process {
if
(
this
.
_meta
)
{
let
metaConfig
=
this
.
_meta
;
if
(
metaConfig
)
{
this
.
updateProps
(
payload
);
this
.
updateProps
(
this
.
_config
.
props
=
{},
payload
,
this
.
_originProps
,
this
.
_meta
.
props
);
if
(
metaConfig
.
script
)
{
let
func
=
new
Function
(
'args'
,
'props'
,
'target'
,
'global'
,
'vm'
,
warpAsyncScript
(
metaConfig
.
script
));
let
globalContext
=
this
.
_vm
.
globalContext
;
...
...
@@ -162,7 +163,7 @@ export class Process {
* 获取props
*/
getProps
(
key
?)
{
if
(
key
)
{
if
(
key
&&
this
.
_config
.
props
)
{
return
this
.
_config
.
props
[
key
];
}
return
this
.
_config
.
props
;
...
...
@@ -171,30 +172,37 @@ export class Process {
/**
* 更新props
*/
updateProps
(
args
)
{
if
(
this
.
_originProps
)
{
let
props
=
this
.
_config
.
props
;
let
propsConfig
=
this
.
_meta
.
props
;
updateProps
(
props
,
args
,
originProps
,
propsConfig
)
{
if
(
originProps
)
{
for
(
let
key
in
propsConfig
)
{
let
value
=
this
.
_
originProps
[
key
];
let
value
=
originProps
[
key
];
const
valueType
=
typeof
value
;
if
(
valueType
==
'object'
)
{
let
name
=
value
.
value
;
switch
(
value
.
type
)
{
case
'link'
:
let
linkedValue
=
this
.
resolveLinkedProp
(
value
,
key
);
if
(
linkedValue
!==
undefined
)
{
props
[
key
]
=
undefined
;
}
else
{
props
[
key
]
=
linkedValue
;
}
break
;
case
'static'
:
props
[
key
]
=
value
.
valu
e
;
props
[
key
]
=
nam
e
;
break
;
case
'arguments'
:
props
[
key
]
=
args
?
getDataByPath
(
args
,
value
.
valu
e
)
:
undefined
;
props
[
key
]
=
args
?
getDataByPath
(
args
,
nam
e
)
:
undefined
;
break
;
case
'data-center'
:
let
nameValue
=
dataCenter
.
getDataByName
(
value
.
value
);
props
[
key
]
=
nameValue
!==
undefined
?
nameValue
:
dataCenter
.
getDataByPath
(
value
.
value
);
let
nameValue
=
dataCenter
.
getDataByName
(
name
);
props
[
key
]
=
nameValue
!==
undefined
?
nameValue
:
dataCenter
.
getDataByPath
(
name
);
break
;
case
'env'
:
props
[
key
]
=
env
[
name
];
break
;
case
'map'
:
this
.
updateProps
(
props
[
key
]
=
{},
args
,
name
,
name
);
break
;
}
}
else
if
(
value
&&
value
.
indexOf
&&
value
.
indexOf
(
nodeScheme
)
===
0
)
{
...
...
src/zeroing/game-warpper/GameStage.ts
View file @
ee17ddaa
...
...
@@ -14,6 +14,7 @@ import {Rect} from "./nodes";
import
{
injectEnv
}
from
"./enviroment"
;
import
{
registerCustomModuleFromConfig
}
from
"./custom-module"
;
import
{
hideLoadingView
,
showLoadingView
}
from
"./loading-view"
;
import
{
Toast
}
from
"./Toast"
;
/**
* 游戏舞台
...
...
@@ -21,6 +22,7 @@ import {hideLoadingView, showLoadingView} from "./loading-view";
export
class
GameStage
extends
Container
{
private
_sceneContainer
:
StackContainer
;
//场景容器
private
_popupContainer
:
StackContainer
;
//弹层容器
private
_toast
:
Toast
;
private
_blackLayer
:
Rect
;
private
_stage
;
private
_dataCenter
:
DataCenter
;
...
...
@@ -189,7 +191,7 @@ export class GameStage extends Container {
case
'push'
:
case
'replace'
:
case
'popAll'
:
if
(
options
.
center
)
{
if
(
options
&&
options
.
center
)
{
view
.
horizonCenter
=
0
;
view
.
verticalCenter
=
0
;
}
...
...
src/zeroing/game-warpper/Toast.ts
0 → 100644
View file @
ee17ddaa
/**
* Created by rockyl on 2019-11-25.
*/
import
{
Container
}
from
"../../2d/display"
;
import
{
GameStage
}
from
"./GameStage"
;
import
{
Label
,
Rect
}
from
"./nodes"
;
export
class
Toast
extends
Container
{
private
_contentSample
:
Container
;
private
_content
:
Container
;
private
_gameStage
:
GameStage
;
constructor
(
gameStage
:
GameStage
)
{
super
();
this
.
_gameStage
=
gameStage
;
}
show
(
props
)
{
if
(
!
props
.
text
)
{
return
;
}
const
{
text
,
duration
,
viewName
}
=
props
;
let
contentView
=
this
.
getContent
(
viewName
);
let
lab
=
contentView
.
getChildByName
(
'lab'
);
if
(
!
lab
)
{
console
.
warn
(
'[lab] child no exists on toast view'
);
return
;
}
lab
.
text
=
text
;
contentView
.
width
=
lab
.
width
;
contentView
.
height
=
lab
.
height
;
this
.
addChild
(
contentView
);
}
hide
()
{
}
private
getContent
(
viewName
)
{
let
view
;
if
(
viewName
)
{
view
=
this
.
_gameStage
.
instantiateView
(
viewName
);
}
if
(
!
view
)
{
if
(
!
this
.
_content
)
{
this
.
_content
=
new
Container
();
let
bg
=
new
Rect
();
bg
.
percentWidth
=
100
;
bg
.
percentHeight
=
100
;
bg
.
alpha
=
0.7
;
view
.
addChild
(
bg
);
let
lab
=
new
Label
();
lab
.
name
=
'lab'
;
view
.
addChild
(
bg
);
}
view
=
this
.
_content
;
}
return
view
;
}
}
src/zeroing/game-warpper/view-interpreter.ts
View file @
ee17ddaa
...
...
@@ -3,14 +3,16 @@
*/
import
{
Container
}
from
"../../2d/display"
;
import
{
Rect
,
Image
,
Label
}
from
"./nodes"
;
import
{
Rect
,
Image
,
Label
,
Circle
,
ScrollView
}
from
"./nodes"
;
import
{
propertyParse
}
from
"../utils"
;
const
nodeTypeMapping
=
{
node
:
Container
,
rect
:
Rect
,
circle
:
Circle
,
label
:
Label
,
image
:
Image
,
scrollView
:
ScrollView
,
};
export
function
instantiate
(
config
)
{
...
...
src/zeroing/utils/utils.ts
View file @
ee17ddaa
...
...
@@ -162,3 +162,42 @@ export function importUMDCode(code) {
create
.
call
(
exports
);
return
exports
;
}
export
function
trimChar
(
str
:
string
,
char
:
string
)
{
while
(
true
)
{
let
len
=
str
.
length
,
from
=
0
,
end
=
len
;
if
(
str
[
0
]
===
char
)
{
from
=
1
;
}
if
(
str
[
len
-
1
]
===
char
)
{
end
=
len
-
1
;
}
str
=
str
.
substring
(
from
,
end
);
if
(
str
.
length
==
len
)
{
break
;
}
}
return
str
;
}
export
function
joinPath
(...
segments
:
string
[])
{
let
result
=
[];
for
(
let
segment
of
segments
)
{
result
.
push
(
trimChar
(
segment
,
'/'
));
}
return
result
.
join
(
'/'
);
}
export
function
findVariable
(
name
:
string
,
...
contexts
)
{
let
result
;
for
(
let
context
of
contexts
)
{
if
(
context
)
{
result
=
context
[
name
];
if
(
result
!==
undefined
){
break
;
}
}
}
return
result
;
}
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