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
4beb6018
Commit
4beb6018
authored
Nov 08, 2019
by
rockyl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mouseEnable 改为 mouseEnabled
parent
53470397
Changes
24
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
24 changed files
with
269 additions
and
87 deletions
+269
-87
index.js
dist/index.js
+73
-21
index.js.map
dist/index.js.map
+1
-1
game-stage.js
examples/game-stage.js
+7
-6
view-data.js
examples/view-data.js
+58
-17
Container.ts
src/2d/display/Container.ts
+11
-3
DisplayObject.ts
src/2d/display/DisplayObject.ts
+9
-7
Sprite.ts
src/2d/display/Sprite.ts
+1
-1
Graphics.ts
src/2d/graphics/Graphics.ts
+1
-1
Shape.ts
src/2d/graphics/Shape.ts
+1
-1
GameStage.ts
src/zeroing/GameStage.ts
+6
-0
StackContainer.ts
src/zeroing/StackContainer.ts
+1
-0
assets-manager.ts
src/zeroing/assets-manager.ts
+8
-0
data-center.ts
src/zeroing/data-center.ts
+11
-8
auto-adjust.ts
src/zeroing/decorators/auto-adjust.ts
+1
-1
events.ts
src/zeroing/decorators/events.ts
+47
-0
scripts.ts
src/zeroing/decorators/scripts.ts
+2
-2
index.ts
src/zeroing/index.ts
+3
-2
launcher.ts
src/zeroing/launcher.ts
+1
-1
Image.ts
src/zeroing/nodes/Image.ts
+12
-5
Container.d.ts
types/2d/display/Container.d.ts
+2
-1
DisplayObject.d.ts
types/2d/display/DisplayObject.d.ts
+6
-6
Loader.d.ts
types/2d/loader/Loader.d.ts
+3
-1
index.d.ts
types/2d/ui/index.d.ts
+0
-1
index.d.ts
types/zeroing/index.d.ts
+4
-1
No files found.
dist/index.js
View file @
4beb6018
...
...
@@ -1199,7 +1199,7 @@
__extends
(
DisplayObject
,
_super
);
function
DisplayObject
()
{
var
_this
=
_super
.
call
(
this
)
||
this
;
_this
.
mouseEnable
=
true
;
_this
.
mouseEnable
d
=
true
;
_this
.
_components
=
[];
_this
.
_instanceType
=
"DisplayObject"
;
_this
.
tempDisplayObjectParent
=
null
;
...
...
@@ -1236,7 +1236,7 @@
var
s
=
this
;
if
(
!
s
.
visible
)
return
null
;
if
(
isMouseEvent
&&
!
s
.
mouseEnable
)
if
(
isMouseEvent
&&
!
s
.
mouseEnable
d
)
return
null
;
if
(
!
isMouseEvent
)
{
if
(
s
.
_localBoundsSelf
.
isPointIn
(
point
))
{
...
...
@@ -1356,7 +1356,7 @@
this
.
_bounds
=
null
;
this
.
tempDisplayObjectParent
=
null
;
this
.
_mask
=
null
;
this
.
mouseEnable
=
false
;
this
.
mouseEnable
d
=
false
;
this
.
destroyed
=
true
;
};
Object
.
defineProperty
(
DisplayObject
.
prototype
,
"alpha"
,
{
...
...
@@ -1919,6 +1919,33 @@
return
ScriptsContainer
;
}());
var
_a
;
var
eventsConfig
=
(
_a
=
{},
_a
[
MouseEvent
.
CLICK
]
=
'click'
,
_a
);
function
applyEvents
(
ctor
)
{
ctor
.
prototype
.
applyEvents
=
function
()
{
var
events
=
this
.
events
=
new
Events
();
for
(
var
k
in
eventsConfig
)
{
this
.
addEventListener
(
k
,
events
.
onEvent
,
events
);
}
};
}
var
Events
=
(
function
(
_super
)
{
__extends
(
Events
,
_super
);
function
Events
()
{
return
_super
.
call
(
this
)
||
this
;
}
Events
.
prototype
.
invoke
=
function
(
name
,
e
)
{
};
Events
.
prototype
.
onEvent
=
function
(
e
)
{
console
.
log
(
this
.
instanceId
,
e
.
type
,
e
.
currentTarget
.
name
);
};
Events
.
prototype
.
destroy
=
function
()
{
};
return
Events
;
}(
HashObject
));
var
Container
=
(
function
(
_super
)
{
__extends
(
Container
,
_super
);
function
Container
()
{
...
...
@@ -1928,6 +1955,7 @@
_this
.
children
=
[];
_this
.
applyAutoAdjust
();
_this
.
applyScripts
();
_this
.
applyEvents
();
return
_this
;
}
Container_1
=
Container
;
...
...
@@ -1935,6 +1963,8 @@
};
Container
.
prototype
.
applyScripts
=
function
()
{
};
Container
.
prototype
.
applyEvents
=
function
()
{
};
Container
.
prototype
.
onChildrenChange
=
function
(
index
)
{
};
Container
.
prototype
.
addChild
=
function
(
child
)
{
...
...
@@ -2159,7 +2189,7 @@
if
(
isMouseEvent
===
void
0
)
{
isMouseEvent
=
false
;
}
if
(
!
this
.
visible
)
return
null
;
if
(
isMouseEvent
&&
!
this
.
mouseEnable
)
if
(
isMouseEvent
&&
!
this
.
mouseEnable
d
)
return
null
;
var
children
=
this
.
children
;
var
length
=
children
.
length
;
...
...
@@ -2303,7 +2333,8 @@
var
Container_1
;
Container
=
Container_1
=
__decorate
([
applyAutoAdjust
,
applyScript
applyScript
,
applyEvents
],
Container
);
return
Container
;
}(
DisplayObject
));
...
...
@@ -4081,7 +4112,7 @@
if
(
isMouseEvent
===
void
0
)
{
isMouseEvent
=
false
;
}
if
(
!
this
.
visible
)
return
null
;
if
(
isMouseEvent
&&
!
this
.
mouseEnable
)
if
(
isMouseEvent
&&
!
this
.
mouseEnable
d
)
return
null
;
var
hitDisplayObject
;
hitDisplayObject
=
_super
.
prototype
.
hitTestPoint
.
call
(
this
,
globalPoint
,
isMouseEvent
);
...
...
@@ -8495,7 +8526,7 @@
var
s
=
this
;
if
(
!
s
.
visible
)
return
null
;
if
(
isMouseEvent
&&
!
s
.
mouseEnable
)
if
(
isMouseEvent
&&
!
s
.
mouseEnable
d
)
return
null
;
var
hitDisplayObject
;
hitDisplayObject
=
_super
.
prototype
.
hitTestPoint
.
call
(
this
,
point
,
isMouseEvent
);
...
...
@@ -9151,7 +9182,7 @@
var
s
=
this
;
if
(
!
s
.
visible
)
return
null
;
if
(
isMouseEvent
&&
!
s
.
mouseEnable
)
if
(
isMouseEvent
&&
!
s
.
mouseEnable
d
)
return
null
;
var
hitResult
=
_super
.
prototype
.
hitTestPoint
.
call
(
this
,
globalPoint
,
isMouseEvent
);
if
(
!
hitResult
)
...
...
@@ -10629,6 +10660,7 @@
var
_this
=
_super
.
call
(
this
)
||
this
;
_this
[
'percentWidth'
]
=
100
;
_this
[
'percentHeight'
]
=
100
;
_this
.
mouseEnabled
=
false
;
return
_this
;
}
StackContainer
.
prototype
.
push
=
function
(
view
)
{
...
...
@@ -10698,6 +10730,9 @@
function
getAssetByUUID
(
uuid
)
{
return
assetsConfig
.
find
(
function
(
item
)
{
return
item
.
uuid
===
uuid
;
});
}
function
getAssetByName
(
name
)
{
return
assetsConfig
.
find
(
function
(
item
)
{
return
item
.
name
===
name
;
});
}
function
fieldChanged
(
onModify
)
{
return
function
(
target
,
key
)
{
...
...
@@ -10843,7 +10878,8 @@
}
return
result
;
};
DataCenter
.
prototype
.
mutate
=
function
(
name
,
data
,
path
)
{
DataCenter
.
prototype
.
mutate
=
function
(
name
,
data
,
path
,
dispatch
)
{
if
(
dispatch
===
void
0
)
{
dispatch
=
true
;
}
var
group
=
this
.
getGroup
(
name
);
if
(
!
group
)
{
return
;
...
...
@@ -10862,6 +10898,7 @@
this
.
registerGroup
(
name
,
data
);
}
}
if
(
dispatch
)
{
for
(
var
_i
=
0
,
_a
=
this
.
watchers
;
_i
<
_a
.
length
;
_i
++
)
{
var
watcher
=
_a
[
_i
];
if
(
watcher
.
path
.
indexOf
(
name
)
===
0
)
{
...
...
@@ -10872,6 +10909,7 @@
});
}
}
}
};
DataCenter
.
prototype
.
watch
=
function
(
name
,
path
)
{
var
watcher
=
{
name
:
name
,
path
:
path
};
...
...
@@ -10915,11 +10953,19 @@
});
Image
.
prototype
.
updateSource
=
function
()
{
var
url
=
this
.
_source
;
if
(
this
.
_source
.
indexOf
(
assetScheme
)
===
0
)
{
var
uuid
=
this
.
_source
.
replace
(
assetScheme
,
''
);
if
(
url
.
indexOf
(
'://'
)
>=
0
)
{
if
(
url
.
indexOf
(
assetScheme
)
===
0
)
{
var
uuid
=
url
.
replace
(
assetScheme
,
''
);
var
assetConfig
=
getAssetByUUID
(
uuid
);
url
=
assetConfig
.
url
;
}
}
else
{
var
assetConfig
=
getAssetByName
(
url
);
if
(
assetConfig
)
{
url
=
assetConfig
.
url
;
}
}
this
.
texture
=
Texture
.
fromImage
(
url
);
};
Image
.
prototype
.
_setSourceDirect
=
function
(
value
)
{
...
...
@@ -11062,12 +11108,16 @@
__extends
(
GameStage
,
_super
);
function
GameStage
(
stage
)
{
var
_this
=
_super
.
call
(
this
)
||
this
;
_this
.
name
=
'game-stage'
;
_this
.
_stage
=
stage
;
_this
.
_dataCenter
=
dataCenter
;
_this
[
'percentWidth'
]
=
100
;
_this
[
'percentHeight'
]
=
100
;
_this
.
mouseEnabled
=
false
;
_this
.
addChild
(
_this
.
_sceneContainer
=
new
StackContainer
());
_this
.
addChild
(
_this
.
_popupContainer
=
new
StackContainer
());
_this
.
_sceneContainer
.
name
=
'scene-container'
;
_this
.
_popupContainer
.
name
=
'popup-container'
;
return
_this
;
}
Object
.
defineProperty
(
GameStage
.
prototype
,
"sceneContainer"
,
{
...
...
@@ -11171,9 +11221,11 @@
exports
.
URL_FILE_EXTENSION
=
URL_FILE_EXTENSION
;
exports
.
VERSION
=
VERSION
;
exports
.
applyAutoAdjust
=
applyAutoAdjust
;
exports
.
applyEvents
=
applyEvents
;
exports
.
applyScript
=
applyScript
;
exports
.
cos
=
cos
;
exports
.
devicePixelRatio
=
devicePixelRatio
;
exports
.
getAssetByName
=
getAssetByName
;
exports
.
getAssetByUUID
=
getAssetByUUID
;
exports
.
getTexture
=
getTexture
;
exports
.
inputFeildIosEnable
=
inputFeildIosEnable
;
...
...
dist/index.js.map
View file @
4beb6018
This diff is collapsed.
Click to expand it.
examples/game-stage.js
View file @
4beb6018
...
...
@@ -8,7 +8,7 @@ engine.registerScriptDef(ScriptDemo);
const
gameStage
=
engine
.
launch
(
data
);
const
dataCenter
=
gameStage
.
dataCenter
;
/*
const dataCenter = gameStage.dataCenter;
dataCenter.registerGroup('test', {
hello: {
...
...
@@ -16,15 +16,16 @@ dataCenter.registerGroup('test', {
name: 'tom',
id: 1001,
age: 29,
avatar
:
'
0a5f2064-f5b4-41a9-8a54-2085e208d20f
'
,
avatar: '
face
',
}
}
});
/
*console.log(dataCenter.getDataByPath('test.hello.aaa.name'));*
/
/
!*console.log(dataCenter.getDataByPath('test.hello.aaa.name'));*!
/
let i = 0;
setInterval(()=>{
//dataCenter.mutate('test', 'jerry' + Math.random(), 'hello.aaa.name');
dataCenter
.
mutate
(
'test'
,
data
.
assets
[
i
%
data
.
assets
.
length
].
uuid
,
'hello.aaa.avatar'
);
let asset = data.assets[i % data.assets.length];
dataCenter.mutate('test', asset.name, 'hello.aaa.name');
dataCenter.mutate('test', asset.name, 'hello.aaa.avatar');
i++;
},
1000
);
}, 1000);
*/
examples/view-data.js
View file @
4beb6018
...
...
@@ -19,40 +19,81 @@ const data = {
properties
:
{
width
:
'100%'
,
height
:
'100%'
,
//mouseEnabled: false,
},
uuid
:
'3a357816-5581-41ba-aa6f-4a6cc40ae396'
,
children
:
[
/*
{
{
name
:
"bg"
,
type
:
"rect"
,
uuid
:
"f97bbf76-6923-4669-b5a3-e6382753e49a"
,
//mouseEnabled: false,
properties
:
{
width
:
'100%'
,
height
:
'100%'
,
fillColor
:
"#1E2127"
,
},
},*/
/*{
},
{
name
:
"button"
,
type
:
"node"
,
uuid
:
"f97bbf76-6923-4669-b5a3-e6382753e49a"
,
properties
:
{
width
:
150
,
height
:
50
,
x
:
10
,
y
:
10
,
mouseChildren
:
false
,
},
children
:
[
{
name
:
"bg"
,
type
:
"rect"
,
uuid
:
"f97bbf76-6923-4669-b5a3-e6382753e49a"
,
properties
:
{
width
:
'100%'
,
height
:
'100%'
,
borderRadius
:
10
,
fillColor
:
"#27ADB8"
,
},
},
{
name
:
"label"
,
type
:
"label"
,
uuid
:
"f97bbf76-6923-4669-b5a3-e6382753e49a"
,
properties
:
{
width
:
'100%'
,
height
:
'100%'
,
fillColor: "#44ff00
",
text: 'Hello ${nickname}
',
fillColor
:
"white
"
,
text
:
'Button
'
,
size
:
30
,
textAlign
:
'center'
,
verticalAlign
:
'middle'
,
},
},*/
},
],
events
:
{
click
:
{
once
:
false
,
behaviors
:
[
{
uuid
:
'aa1'
,
alias
:
'主过程'
,
meta
:
'main'
,
}
]
}
},
},
/*{
name: "img",
type: "image",
uuid: "f97bbf76-6923-4669-b5a3-e6382753e49a",
properties: {
source
:
'asset://${avatar}'
y: 40,
source: '${avatar}'
},
/*
scripts: [
scripts: [
{
script: 'ScriptDemo',
disabled: false,
...
...
@@ -60,8 +101,8 @@ const data = {
duration: 1000,
},
}
]
*/
},
]
},
*/
]
},
{
...
...
src/2d/display/Container.ts
View file @
4beb6018
...
...
@@ -4,8 +4,10 @@ import { Point } from '../math';
import
CanvasRenderer
from
'../renderers/CanvasRenderer'
;
import
{
Event
}
from
"../events/Event"
import
{
WebglRenderer
}
from
'../renderers/WebglRenderer'
;
import
{
applyAutoAdjust
}
from
"../../zeroing/auto-adjust"
;
import
{
applyScript
}
from
"../../zeroing/script-manager"
;
import
{
applyAutoAdjust
}
from
"../../zeroing/decorators/auto-adjust"
;
import
{
applyScript
}
from
"../../zeroing/decorators/scripts"
;
import
{
applyEvents
}
from
"../../zeroing/decorators/events"
;
/**
* 容器类
...
...
@@ -14,6 +16,7 @@ import {applyScript} from "../../zeroing/script-manager";
*/
@
applyAutoAdjust
@
applyScript
@
applyEvents
export
default
class
Container
extends
DisplayObject
{
/**
...
...
@@ -39,6 +42,7 @@ export default class Container extends DisplayObject {
this
.
children
=
[];
this
.
applyAutoAdjust
();
this
.
applyScripts
();
this
.
applyEvents
();
}
applyAutoAdjust
()
{
...
...
@@ -49,6 +53,10 @@ export default class Container extends DisplayObject {
}
applyEvents
()
{
}
/**
* children改变时
* @private
...
...
@@ -375,7 +383,7 @@ export default class Container extends DisplayObject {
hitTestPoint
(
globalPoint
:
Point
,
isMouseEvent
:
boolean
=
false
)
{
if
(
!
this
.
visible
)
return
null
//如果禁止子级的鼠标事件
if
(
isMouseEvent
&&
!
this
.
mouseEnable
)
return
null
;
if
(
isMouseEvent
&&
!
this
.
mouseEnable
d
)
return
null
;
var
children
=
this
.
children
;
var
length
=
children
.
length
let
child
,
hitDisplayObject
;
...
...
src/2d/display/DisplayObject.ts
View file @
4beb6018
...
...
@@ -37,12 +37,12 @@ export class DisplayObject extends EventDispatcher {
/**
* 舞台
*/
stage
:
any
stage
:
any
;
/**
* 名字,预留
*/
name
:
string
name
:
string
;
/**
* 全局透明度
...
...
@@ -56,7 +56,7 @@ export class DisplayObject extends EventDispatcher {
/**
* 用于计算世界bounds,包括自身和子级,一般只在获取宽高时使用,变形后的
*/
protected
_bounds
:
Rectangle
protected
_bounds
:
Rectangle
;
protected
_boundsID
:
number
;
protected
_lastBoundsID
:
number
;
/**
...
...
@@ -81,7 +81,7 @@ export class DisplayObject extends EventDispatcher {
/**
* 是否可响应鼠标事件
*/
mouseEnable
:
boolean
=
true
;
mouseEnable
d
:
boolean
=
true
;
/**
* 临时父级,特殊用处
...
...
@@ -158,7 +158,7 @@ export class DisplayObject extends EventDispatcher {
public
static
_p3
:
Point
=
new
Point
();
public
static
_p4
:
Point
=
new
Point
();
//bounds缓存
public
static
temBounds
=
new
Rectangle
()
public
static
temBounds
=
new
Rectangle
()
;
/**
* 点击碰撞测试,就是舞台上的一个point是否在显示对象内,在则返回该对象,不在则返回null
* 对于那些不是继承container,而直接继承displayObject的不用重写,如Bitmap
...
...
@@ -172,7 +172,7 @@ export class DisplayObject extends EventDispatcher {
public
hitTestPoint
(
point
:
Point
,
isMouseEvent
:
boolean
=
false
):
DisplayObject
{
let
s
=
this
;
if
(
!
s
.
visible
)
return
null
;
if
(
isMouseEvent
&&
!
s
.
mouseEnable
)
return
null
;
if
(
isMouseEvent
&&
!
s
.
mouseEnable
d
)
return
null
;
if
(
!
isMouseEvent
)
{
//如果不是系统调用则不考虑这个点是从全局来的,只认为这个点就是当前要碰撞测试同级别下的坐标点
if
(
s
.
_localBoundsSelf
.
isPointIn
(
point
))
{
...
...
@@ -260,6 +260,7 @@ export class DisplayObject extends EventDispatcher {
* @since 1.0.0
* @public
* @param {Point} point
* @param bp
* @return {Point}
*/
public
globalToLocal
(
point
:
Point
,
bp
:
Point
=
null
):
Point
{
...
...
@@ -272,6 +273,7 @@ export class DisplayObject extends EventDispatcher {
* @public
* @since 1.0.0
* @param {Point} point
* @param bp
* @return {Point}
*/
public
localToGlobal
(
point
:
Point
,
bp
:
Point
=
null
):
Point
{
...
...
@@ -382,7 +384,7 @@ export class DisplayObject extends EventDispatcher {
this
.
_bounds
=
null
;
this
.
tempDisplayObjectParent
=
null
;
this
.
_mask
=
null
;
this
.
mouseEnable
=
false
;
this
.
mouseEnable
d
=
false
;
//标记为已销毁
this
.
destroyed
=
true
;
}
...
...
src/2d/display/Sprite.ts
View file @
4beb6018
...
...
@@ -336,7 +336,7 @@ export default class Sprite extends Container {
hitTestPoint
(
globalPoint
:
Point
,
isMouseEvent
:
boolean
=
false
)
{
if
(
!
this
.
visible
)
return
null
//如果禁止子级的鼠标事件
if
(
isMouseEvent
&&
!
this
.
mouseEnable
)
return
null
;
if
(
isMouseEvent
&&
!
this
.
mouseEnable
d
)
return
null
;
//如果以后加缓存成位图,另写
let
hitDisplayObject
;
//先检查子级,因为子级层级更高
...
...
src/2d/graphics/Graphics.ts
View file @
4beb6018
...
...
@@ -1132,7 +1132,7 @@ export default class Graphics extends Container {
hitTestPoint
(
point
:
Point
,
isMouseEvent
:
boolean
=
false
):
DisplayObject
{
let
s
=
this
;
if
(
!
s
.
visible
)
return
null
;
if
(
isMouseEvent
&&
!
s
.
mouseEnable
)
return
null
;
if
(
isMouseEvent
&&
!
s
.
mouseEnable
d
)
return
null
;
let
hitDisplayObject
;
//先检查子级,因为子级层级更高
...
...
src/2d/graphics/Shape.ts
View file @
4beb6018
...
...
@@ -739,7 +739,7 @@ export class Shape extends Sprite {
public
hitTestPoint
(
globalPoint
:
Point
,
isMouseEvent
:
boolean
=
false
):
DisplayObject
{
let
s
:
Shape
=
this
;
if
(
!
s
.
visible
)
return
null
;
if
(
isMouseEvent
&&
!
s
.
mouseEnable
)
return
null
;
if
(
isMouseEvent
&&
!
s
.
mouseEnable
d
)
return
null
;
//直接继承
var
hitResult
=
super
.
hitTestPoint
(
globalPoint
,
isMouseEvent
)
//如果这样返回都没有,直接返回null
...
...
src/zeroing/GameStage.ts
View file @
4beb6018
...
...
@@ -22,14 +22,20 @@ export class GameStage extends Container {
constructor
(
stage
:
Stage
)
{
super
();
this
.
name
=
'game-stage'
;
this
.
_stage
=
stage
;
this
.
_dataCenter
=
dataCenter
;
this
[
'percentWidth'
]
=
100
;
this
[
'percentHeight'
]
=
100
;
this
.
mouseEnabled
=
false
;
this
.
addChild
(
this
.
_sceneContainer
=
new
StackContainer
());
this
.
addChild
(
this
.
_popupContainer
=
new
StackContainer
());
this
.
_sceneContainer
.
name
=
'scene-container'
;
this
.
_popupContainer
.
name
=
'popup-container'
;
}
/**
...
...
src/zeroing/StackContainer.ts
View file @
4beb6018
...
...
@@ -13,6 +13,7 @@ export class StackContainer extends Container {
this
[
'percentWidth'
]
=
100
;
this
[
'percentHeight'
]
=
100
;
this
.
mouseEnabled
=
false
;
}
/**
...
...
src/zeroing/assets-manager.ts
View file @
4beb6018
...
...
@@ -62,3 +62,11 @@ export function loadAssets(config, onProgress?, onComplete?) {
export
function
getAssetByUUID
(
uuid
)
{
return
assetsConfig
.
find
(
item
=>
item
.
uuid
===
uuid
);
}
/**
* 根据name获取素材配置
* @param name
*/
export
function
getAssetByName
(
name
)
{
return
assetsConfig
.
find
(
item
=>
item
.
name
===
name
);
}
src/zeroing/data-center.ts
View file @
4beb6018
...
...
@@ -82,8 +82,9 @@ export class DataCenter extends EventDispatcher {
* @param name
* @param data
* @param path
* @param dispatch
*/
mutate
(
name
,
data
?,
path
?)
{
mutate
(
name
,
data
?,
path
?
,
dispatch
=
true
)
{
let
group
=
this
.
getGroup
(
name
);
if
(
!
group
)
{
...
...
@@ -102,6 +103,7 @@ export class DataCenter extends EventDispatcher {
}
}
if
(
dispatch
){
for
(
let
watcher
of
this
.
watchers
)
{
if
(
watcher
.
path
.
indexOf
(
name
)
===
0
)
{
this
.
dispatchEvent
(
watcher
.
name
,
{
...
...
@@ -112,6 +114,7 @@ export class DataCenter extends EventDispatcher {
}
}
}
}
/**
* 添加数据侦听
...
...
src/zeroing/auto-adjust.ts
→
src/zeroing/
decorators/
auto-adjust.ts
View file @
4beb6018
...
...
@@ -4,7 +4,7 @@
* 自适应功能
*/
import
{
Event
}
from
"../2d/events"
;
import
{
Event
}
from
"../
../
2d/events"
;
/**
* 自适应数据
...
...
src/zeroing/decorators/events.ts
0 → 100644
View file @
4beb6018
/**
* Created by rockyl on 2019-11-08.
*/
import
{
Event
,
MouseEvent
}
from
"../../2d/events"
;
import
{
HashObject
}
from
"../../2d/HashObject"
;
const
eventsConfig
=
{
//[Event.ADDED_TO_STAGE]: 'awake',
//[Event.REMOVED_FROM_STAGE]: 'sleep',
[
MouseEvent
.
CLICK
]:
'click'
,
//[MouseEvent.MOUSE_DOWN]: 'touchstart',
//[MouseEvent.MOUSE_MOVE]: 'touchmove',
//[MouseEvent.MOUSE_UP]: 'touchend',
};
/**
* 应用事件委托
* @param ctor
*/
export
function
applyEvents
(
ctor
:
Function
)
{
ctor
.
prototype
.
applyEvents
=
function
()
{
let
events
=
this
.
events
=
new
Events
();
for
(
let
k
in
eventsConfig
){
this
.
addEventListener
(
k
,
events
.
onEvent
,
events
);
}
};
}
class
Events
extends
HashObject
{
constructor
(){
super
();
}
invoke
(
name
,
e
)
{
}
onEvent
(
e
){
console
.
log
(
this
.
instanceId
,
e
.
type
,
e
.
currentTarget
.
name
);
//this.events.invoke('awake');
}
destroy
():
void
{
}
}
src/zeroing/
script-manager
.ts
→
src/zeroing/
decorators/scripts
.ts
View file @
4beb6018
...
...
@@ -3,8 +3,8 @@
*
* 脚本功能
*/
import
{
Container
}
from
"../2d/display"
;
import
{
Event
}
from
"../2d/events"
;
import
{
Container
}
from
"../
../
2d/display"
;
import
{
Event
}
from
"../
../
2d/events"
;
const
scriptDefs
=
{};
...
...
src/zeroing/index.ts
View file @
4beb6018
...
...
@@ -6,7 +6,8 @@ export * from './GameStage'
export
*
from
'./StackContainer'
export
*
from
'./nodes'
export
*
from
'./assets-manager'
export
*
from
'./auto-adjust'
export
*
from
'./script-manager'
export
*
from
'./view-interpreter'
export
*
from
'./launcher'
export
*
from
'./decorators/auto-adjust'
export
*
from
'./decorators/scripts'
export
*
from
'./decorators/events'
src/zeroing/launcher.ts
View file @
4beb6018
...
...
@@ -3,7 +3,7 @@
*/
import
{
Stage
}
from
"../2d/display"
;
import
{
GameStage
,
RENDERER_TYPE
,
StageScaleMode
}
from
".."
;
import
{
GameStage
,
R
ect
,
R
ENDERER_TYPE
,
StageScaleMode
}
from
".."
;
export
function
launch
(
config
,
onAssetsProgress
,
onAssetsComplete
)
{
const
{
containerID
,
designWidth
,
designHeight
,
frameRate
,
scaleMode
,
rendererType
,}
=
config
.
launchOptions
;
...
...
src/zeroing/nodes/Image.ts
View file @
4beb6018
...
...
@@ -3,7 +3,7 @@
*/
import
{
Sprite
}
from
"../../2d/display"
;
import
Texture
from
"../../2d/texture/Texture"
;
import
{
getAssetByUUID
}
from
"../assets-manager"
;
import
{
getAssetBy
Name
,
getAssetBy
UUID
}
from
"../assets-manager"
;
import
{
dataCenter
}
from
"../data-center"
;
import
{
ESCAPE_REG_EXP
}
from
"../utils"
;
...
...
@@ -28,11 +28,18 @@ export class Image extends Sprite {
private
updateSource
()
{
let
url
=
this
.
_source
;
if
(
this
.
_source
.
indexOf
(
assetScheme
)
===
0
)
{
let
uuid
=
this
.
_source
.
replace
(
assetScheme
,
''
);
if
(
url
.
indexOf
(
'://'
)
>=
0
){
//如果是有协议的地址
if
(
url
.
indexOf
(
assetScheme
)
===
0
)
{
let
uuid
=
url
.
replace
(
assetScheme
,
''
);
const
assetConfig
=
getAssetByUUID
(
uuid
);
url
=
assetConfig
.
url
;
}
}
else
{
//否则就使用素材名
const
assetConfig
=
getAssetByName
(
url
);
if
(
assetConfig
){
url
=
assetConfig
.
url
;
}
}
this
.
texture
=
Texture
.
fromImage
(
url
);
}
...
...
types/2d/display/Container.d.ts
View file @
4beb6018
...
...
@@ -7,7 +7,8 @@ export default class Container extends DisplayObject {
children
:
any
[];
containerUpdateTransform
:
any
;
constructor
();
afterConstructor
():
void
;
applyAutoAdjust
():
void
;
applyScripts
():
void
;
onChildrenChange
(
index
:
any
):
void
;
addChild
(
child
:
DisplayObject
):
DisplayObject
;
addChildAt
(
child
:
DisplayObject
,
index
:
number
):
DisplayObject
;
...
...
types/2d/display/DisplayObject.d.ts
View file @
4beb6018
...
...
@@ -50,16 +50,16 @@ export declare class DisplayObject extends EventDispatcher {
alpha
:
number
;
x
:
number
;
y
:
number
;
readonly
worldMatrix
:
import
(
"../../../../../
duibaGame
/renderingengine/src/2d/math/Matrix"
).
Matrix
;
readonly
localMatrix
:
import
(
"../../../../../
duibaGame
/renderingengine/src/2d/math/Matrix"
).
Matrix
;
position
:
import
(
"../../../../../
duibaGame
/renderingengine/src/2d/math/ObservablePoint"
).
ObservablePoint
;
scale
:
import
(
"../../../../../
duibaGame
/renderingengine/src/2d/math/ObservablePoint"
).
ObservablePoint
;
readonly
worldMatrix
:
import
(
"../../../../../
../../../Users/rockyl/WorkSpaces/VisualEditor
/renderingengine/src/2d/math/Matrix"
).
Matrix
;
readonly
localMatrix
:
import
(
"../../../../../
../../../Users/rockyl/WorkSpaces/VisualEditor
/renderingengine/src/2d/math/Matrix"
).
Matrix
;
position
:
import
(
"../../../../../
../../../Users/rockyl/WorkSpaces/VisualEditor
/renderingengine/src/2d/math/ObservablePoint"
).
ObservablePoint
;
scale
:
import
(
"../../../../../
../../../Users/rockyl/WorkSpaces/VisualEditor
/renderingengine/src/2d/math/ObservablePoint"
).
ObservablePoint
;
scaleX
:
number
;
scaleY
:
number
;
anchor
:
import
(
"../../../../../
duibaGame
/renderingengine/src/2d/math/ObservablePoint"
).
ObservablePoint
;
anchor
:
import
(
"../../../../../
../../../Users/rockyl/WorkSpaces/VisualEditor
/renderingengine/src/2d/math/ObservablePoint"
).
ObservablePoint
;
anchorX
:
number
;
anchorY
:
number
;
skew
:
import
(
"../../../../../
duibaGame
/renderingengine/src/2d/math/ObservablePoint"
).
ObservablePoint
;
skew
:
import
(
"../../../../../
../../../Users/rockyl/WorkSpaces/VisualEditor
/renderingengine/src/2d/math/ObservablePoint"
).
ObservablePoint
;
rotation
:
number
;
readonly
worldVisible
:
boolean
;
mask
:
Graphics
;
...
...
types/2d/loader/Loader.d.ts
View file @
4beb6018
...
...
@@ -7,8 +7,10 @@ export declare class Loader extends EventDispatcher {
_req
:
XMLHttpRequest
;
constructor
();
loadSheet
(
callback
:
Function
,
url
:
string
):
void
;
loadRaw
(
callback
:
Function
,
url
:
string
,
type
:
'text'
|
'json'
):
void
;
loadJson
(
callback
:
Function
,
url
:
string
):
void
;
loadTexture
(
url
:
string
,
uuid
?:
any
):
void
;
loadText
(
callback
:
Function
,
url
:
string
):
void
;
loadTexture
(
callback
:
Function
,
url
:
string
):
void
;
loadImage
(
callback
:
Function
,
url
:
string
,
crossOrigin
?:
boolean
):
HTMLImageElement
;
loadSvga
(
callback
:
(
suc
:
boolean
,
data
:
VideoEntity
)
=>
void
,
url
:
string
):
void
;
cache
(
name
:
string
,
data
:
any
):
void
;
...
...
types/2d/ui/index.d.ts
View file @
4beb6018
export
{
IScrollListItem
}
from
"./ScrollList"
;
export
{
ScrollList
}
from
"./ScrollList"
;
export
{
ScrollPage
}
from
"./ScrollPage"
;
export
{
Button
}
from
"./Button"
;
types/zeroing/index.d.ts
View file @
4beb6018
export
*
from
'./GameStage'
;
export
*
from
'./StackContainer'
;
export
*
from
'./shapes'
;
export
*
from
'./nodes'
;
export
*
from
'./assets-manager'
;
export
*
from
'./auto-adjust'
;
export
*
from
'./script-manager'
;
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