Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
scilla-core
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
劳工
scilla-core
Commits
217c86c6
Commit
217c86c6
authored
May 24, 2019
by
rockyl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加HtmlRenderer组件
parent
b4a6f7cf
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
13 deletions
+34
-13
AssetsManager.ts
src/assets-manager/AssetsManager.ts
+6
-2
Entity.ts
src/core/Entity.ts
+13
-2
ScillaEngine.ts
src/core/ScillaEngine.ts
+14
-8
DataCenter.ts
src/support/DataCenter.ts
+1
-1
No files found.
src/assets-manager/AssetsManager.ts
View file @
217c86c6
...
@@ -66,10 +66,11 @@ export default class AssetsManager{
...
@@ -66,10 +66,11 @@ export default class AssetsManager{
/**
/**
* 加载一批资源
* 加载一批资源
* @param items 资源数组: ['aaa.png', {uuid: 'bbb', url: 'alias.png'}]
* @param items 资源数组: ['aaa.png', {uuid: 'bbb', url: 'alias.png'}]
* @param replaceConfig 替换项配置
* @param progress 进度回调,参数为加载百分比
* @param progress 进度回调,参数为加载百分比
* @return Promise<Array<any>> 资源组
* @return Promise<Array<any>> 资源组
*/
*/
loadResItems
(
items
:
Array
<
any
|
string
>
,
progress
?:
(
percentage
:
number
)
=>
void
):
Promise
<
Array
<
any
>>
{
loadResItems
(
items
:
Array
<
any
|
string
>
,
replaceConfig
?,
progress
?:
(
percentage
:
number
)
=>
void
):
Promise
<
Array
<
any
>>
{
let
total
=
items
.
length
;
let
total
=
items
.
length
;
let
count
=
0
;
let
count
=
0
;
...
@@ -81,6 +82,9 @@ export default class AssetsManager{
...
@@ -81,6 +82,9 @@ export default class AssetsManager{
}
else
{
}
else
{
url
=
item
.
url
;
url
=
item
.
url
;
}
}
if
(
replaceConfig
){
url
=
replaceConfig
[
url
]
||
url
;
}
if
(
!
url
)
{
if
(
!
url
)
{
return
Promise
.
resolve
();
return
Promise
.
resolve
();
}
}
...
@@ -392,7 +396,7 @@ export default class AssetsManager{
...
@@ -392,7 +396,7 @@ export default class AssetsManager{
loadAnim
(
url
:
string
,
uuid
?:
string
,
cache
:
boolean
=
true
,
config
?:
any
):
Promise
<
FrameAnimation
[]
>
{
loadAnim
(
url
:
string
,
uuid
?:
string
,
cache
:
boolean
=
true
,
config
?:
any
):
Promise
<
FrameAnimation
[]
>
{
let
pngFile
=
url
.
substring
(
0
,
url
.
lastIndexOf
(
'.'
))
+
'.png'
;
let
pngFile
=
url
.
substring
(
0
,
url
.
lastIndexOf
(
'.'
))
+
'.png'
;
return
Promise
.
all
(
<
Promise
<
any
>
[]
>
[
return
<
Promise
<
FrameAnimation
[]
>>
Promise
.
all
(
[
this
.
loadJson
(
url
,
null
,
false
),
this
.
loadJson
(
url
,
null
,
false
),
this
.
loadImage
(
pngFile
,
null
,
false
),
this
.
loadImage
(
pngFile
,
null
,
false
),
]).
then
(
]).
then
(
...
...
src/core/Entity.ts
View file @
217c86c6
...
@@ -52,8 +52,12 @@ export class Entity extends HashObject {
...
@@ -52,8 +52,12 @@ export class Entity extends HashObject {
set
enabled
(
value
:
boolean
)
{
set
enabled
(
value
:
boolean
)
{
if
(
this
.
_enabled
!==
value
)
{
if
(
this
.
_enabled
!==
value
)
{
this
.
_enabled
=
value
;
this
.
_enabled
=
value
;
let
that
=
this
;
traverse
(
this
,
function
(
child
:
Entity
)
{
traverse
(
this
,
function
(
child
:
Entity
)
{
if
(
child
!==
that
&&
!
child
.
_enabled
)
{
return
true
;
}
child
.
_invokeEnabledState
(
value
);
child
.
_invokeEnabledState
(
value
);
return
false
;
return
false
;
},
-
1
,
true
)
},
-
1
,
true
)
...
@@ -61,10 +65,17 @@ export class Entity extends HashObject {
...
@@ -61,10 +65,17 @@ export class Entity extends HashObject {
}
}
_invokeEnabledState
(
enabled
:
boolean
)
{
_invokeEnabledState
(
enabled
:
boolean
)
{
if
(
this
.
_enabled
&&
enabled
)
{
/*
if (this._enabled && enabled) {
this.onEnable();
this.onEnable();
} else if (!this._enabled && !enabled) {
} else if (!this._enabled && !enabled) {
this.onDisable();
this.onDisable();
}*/
if
(
this
.
_enabled
)
{
if
(
enabled
){
this
.
onEnable
();
}
else
{
this
.
onDisable
();
}
}
}
}
}
...
...
src/core/ScillaEngine.ts
View file @
217c86c6
...
@@ -37,7 +37,7 @@ export class ScillaEngine {
...
@@ -37,7 +37,7 @@ export class ScillaEngine {
readonly
dataCenterConfig
:
any
=
{};
readonly
dataCenterConfig
:
any
=
{};
private
_root
:
Entity
;
private
_root
:
Entity
;
private
canvasElement
:
HTML
Element
;
private
_canvasElement
:
HTMLCanvas
Element
;
private
_flush
=
0
;
private
_flush
=
0
;
private
_currentFlush
=
0
;
private
_currentFlush
=
0
;
...
@@ -68,17 +68,19 @@ export class ScillaEngine {
...
@@ -68,17 +68,19 @@ export class ScillaEngine {
injectProp
(
this
.
customConfig
,
_customConfig
);
injectProp
(
this
.
customConfig
,
_customConfig
);
injectProp
(
this
.
dataCenterConfig
,
_dataCenterConfig
);
injectProp
(
this
.
dataCenterConfig
,
_dataCenterConfig
);
for
(
let
item
of
this
.
dataCenterConfig
.
dataCenterRoot
){
if
(
this
.
dataCenterConfig
.
dataCenterRoot
){
this
.
_dataCenter
.
register
(
item
);
for
(
let
item
of
this
.
dataCenterConfig
.
dataCenterRoot
){
this
.
_dataCenter
.
register
(
item
);
}
}
}
const
{
canvas
,
designWidth
,
designHeight
,
scaleMode
,
modifyCanvasSize
,
touchEnabled
}
=
this
.
engineConfig
;
const
{
canvas
,
designWidth
,
designHeight
,
scaleMode
,
modifyCanvasSize
,
touchEnabled
}
=
this
.
engineConfig
;
this
.
canvasElement
=
typeof
canvas
==
'string'
?
document
.
getElementById
(
canvas
)
:
canvas
;
this
.
_
canvasElement
=
typeof
canvas
==
'string'
?
document
.
getElementById
(
canvas
)
:
canvas
;
this
.
_interactContext
=
new
InteractContext
(
this
);
this
.
_interactContext
=
new
InteractContext
(
this
);
this
.
_interactContext
.
setup
({
this
.
_interactContext
.
setup
({
canvas
:
this
.
canvasElement
,
canvas
:
this
.
_
canvasElement
,
touchHandlers
:
{
touchHandlers
:
{
onTouchBegin
:
this
.
onTouchBegin
.
bind
(
this
),
onTouchBegin
:
this
.
onTouchBegin
.
bind
(
this
),
onTouchMove
:
this
.
onTouchMove
.
bind
(
this
),
onTouchMove
:
this
.
onTouchMove
.
bind
(
this
),
...
@@ -89,7 +91,7 @@ export class ScillaEngine {
...
@@ -89,7 +91,7 @@ export class ScillaEngine {
this
.
_renderContext
=
new
RenderContext
(
this
);
this
.
_renderContext
=
new
RenderContext
(
this
);
this
.
_renderContext
.
setup
({
this
.
_renderContext
.
setup
({
canvas
:
this
.
canvasElement
,
canvas
:
this
.
_
canvasElement
,
designWidth
,
designWidth
,
designHeight
,
designHeight
,
scaleMode
,
scaleMode
,
...
@@ -189,6 +191,10 @@ export class ScillaEngine {
...
@@ -189,6 +191,10 @@ export class ScillaEngine {
return
this
.
_assetsManager
;
return
this
.
_assetsManager
;
}
}
get
canvasElement
():
HTMLCanvasElement
{
return
this
.
_canvasElement
;
}
/**
/**
* 获取数据中心实例
* 获取数据中心实例
*/
*/
...
@@ -318,7 +324,7 @@ export class ScillaEngine {
...
@@ -318,7 +324,7 @@ export class ScillaEngine {
const
{
scaleX
,
scaleY
,
rotation
}
=
this
.
renderContext
;
const
{
scaleX
,
scaleY
,
rotation
}
=
this
.
renderContext
;
let
x
=
pageX
,
y
=
pageY
;
let
x
=
pageX
,
y
=
pageY
;
let
box
=
this
.
canvasElement
.
getBoundingClientRect
();
let
box
=
this
.
_
canvasElement
.
getBoundingClientRect
();
if
(
!
isLocalPos
)
{
if
(
!
isLocalPos
)
{
let
doc
=
document
.
documentElement
;
let
doc
=
document
.
documentElement
;
let
left
=
box
.
left
+
window
.
pageXOffset
-
doc
.
clientLeft
;
let
left
=
box
.
left
+
window
.
pageXOffset
-
doc
.
clientLeft
;
...
@@ -359,7 +365,7 @@ export class ScillaEngine {
...
@@ -359,7 +365,7 @@ export class ScillaEngine {
y
=
y
*
scaleY
;
y
=
y
*
scaleY
;
if
(
!
isLocalPos
)
{
if
(
!
isLocalPos
)
{
let
box
=
this
.
canvasElement
.
getBoundingClientRect
();
let
box
=
this
.
_
canvasElement
.
getBoundingClientRect
();
let
doc
=
document
.
documentElement
;
let
doc
=
document
.
documentElement
;
let
left
=
box
.
left
+
window
.
pageXOffset
-
doc
.
clientLeft
;
let
left
=
box
.
left
+
window
.
pageXOffset
-
doc
.
clientLeft
;
let
top
=
box
.
top
+
window
.
pageYOffset
-
doc
.
clientTop
;
let
top
=
box
.
top
+
window
.
pageYOffset
-
doc
.
clientTop
;
...
...
src/support/DataCenter.ts
View file @
217c86c6
...
@@ -48,7 +48,7 @@ export default class DataCenter extends EventEmitter{
...
@@ -48,7 +48,7 @@ export default class DataCenter extends EventEmitter{
* @param type
* @param type
* @param key
* @param key
*/
*/
public
get
(
type
:
string
,
key
:
string
)
{
public
get
(
type
:
string
,
key
?
:
string
)
{
if
(
!
key
)
return
this
.
store
[
type
];
if
(
!
key
)
return
this
.
store
[
type
];
return
this
.
store
[
type
][
key
];
return
this
.
store
[
type
][
key
];
}
}
...
...
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