Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
duiba-egret-games
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
wildfirecode13
duiba-egret-games
Commits
de78d61c
Commit
de78d61c
authored
Nov 07, 2018
by
wildfirecode
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
e30ced12
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
76 additions
and
25 deletions
+76
-25
MainBase.ts
egret/libs/new_wx/MainBase.ts
+32
-6
loadAtlas.ts
egret/libs/new_wx/ctrls/loadAtlas.ts
+0
-16
sceneCtrl.ts
egret/libs/new_wx/ctrls/sceneCtrl.ts
+29
-3
layers.ts
egret/libs/new_wx/views/layers.ts
+15
-0
No files found.
egret/libs/new_wx/MainBase.ts
View file @
de78d61c
...
...
@@ -84,12 +84,6 @@ export default class MainBase extends eui.UILayer {
DataManager
.
ins
.
gameCfgData
=
window
[
'CFG'
];
DataManager
.
ins
.
gameCfgData
.
gameInfo
.
gameId
=
window
[
"gameId"
];
setTimeout
(()
=>
{
console
.
log
(
'stageHeight'
,
this
.
stage
.
stageHeight
);
console
.
log
(
'height'
,
this
.
stage
.
height
);
},
2000
);
layers
.
init
(
this
);
Loading
.
init
(
layers
.
topLayer
);
PanelCtrl
.
instance
.
init
(
layers
.
popupLayer
);
...
...
@@ -99,6 +93,8 @@ export default class MainBase extends eui.UILayer {
this
.
registerModules
();
this
.
loadFirstScreen
();
this
.
loadAtlas
();
this
.
getData
();
RES
.
setMaxLoadingThread
(
10
);
this
.
runGame
().
catch
(
e
=>
{
...
...
@@ -106,6 +102,35 @@ export default class MainBase extends eui.UILayer {
})
}
loadAtlas
()
{
if
(
!
window
[
'development'
])
{
const
urlJSON
=
getResPath
()
+
"resource/TextureMerger/loading.json"
;
const
request
=
new
egret
.
HttpRequest
();
request
.
open
(
urlJSON
,
egret
.
HttpMethod
.
GET
);
request
.
send
();
const
url
=
getResPath
()
+
"resource/TextureMerger/loading.png"
;
const
imageLoader
=
new
egret
.
ImageLoader
();
imageLoader
.
load
(
url
);
}
}
loadFirstScreen
()
{
const
onImageLoaded
=
(
e
:
egret
.
Event
)
=>
{
const
imageLoader
:
egret
.
ImageLoader
=
e
.
currentTarget
;
const
bitmapData
:
egret
.
BitmapData
=
imageLoader
.
data
;
const
texture
=
new
egret
.
Texture
();
texture
.
_setBitmapData
(
bitmapData
);
const
bitmap
=
new
egret
.
Bitmap
(
texture
);
layers
.
addFirstBackground
(
bitmap
);
}
const
imageLoader
=
new
egret
.
ImageLoader
();
imageLoader
.
once
(
egret
.
Event
.
COMPLETE
,
onImageLoaded
,
this
);
const
url
=
getResPath
()
+
"resource/assets/startScene/bg.jpg"
imageLoader
.
load
(
url
);
}
private
async
runGame
()
{
await
this
.
loadResource
()
this
.
createGameScene
();
...
...
@@ -139,6 +164,7 @@ export default class MainBase extends eui.UILayer {
* Create scene interface
*/
protected
createGameScene
()
{
layers
.
removeFirstBackground
();
SceneCtrl
.
instance
.
change
(
ModuleTypes
.
START_SCENE
);
}
}
\ No newline at end of file
egret/libs/new_wx/ctrls/loadAtlas.ts
deleted
100644 → 0
View file @
e30ced12
const
loadAtlas
=
(
name
:
string
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
RES
.
getResByUrl
(
`resource/TextureMerger/
${
name
}
.json`
,
(
sheet
:
egret
.
SpriteSheet
)
=>
{
resolve
(
this
);
},
this
,
RES
.
ResourceItem
.
TYPE_SHEET
);
});
}
// const loadAtlas = (name: string) => {
// return new Promise((resolve, reject) => {
// RES.getResByUrl(`resource/TextureMerger/${name}.json`, (sheet: egret.SpriteSheet) => {
// resolve(this);
// }, this, RES.ResourceItem.TYPE_SHEET);
// });
// }
\ No newline at end of file
egret/libs/new_wx/ctrls/sceneCtrl.ts
View file @
de78d61c
import
{
ModuleTypes
}
from
"../types/sceneTypes"
;
import
Scene
from
"../components/Scene"
;
import
Loading
from
"../components/Loading"
;
export
default
class
SceneCtrl
{
private
_parent
:
egret
.
Sprite
;
private
_currentScene
:
Scene
;
private
_mask
:
egret
.
Sprite
;
static
_instance
:
SceneCtrl
;
static
get
instance
()
{
...
...
@@ -12,18 +14,42 @@ export default class SceneCtrl {
this
.
_parent
=
parent
;
}
change
(
type
:
ModuleTypes
)
{
change
(
type
:
ModuleTypes
,
data
?)
{
const
cls
=
this
.
_sceneClassMap
[
type
];
const
scene
:
Scene
=
new
cls
();
if
(
!
window
[
'development'
])
{
Loading
.
instace
.
show
();
RES
.
getResByUrl
(
`
${
scene
.
skinKey
.
toLowerCase
()}
_json`
,
(
sheet
:
egret
.
SpriteSheet
)
=>
{
Loading
.
instace
.
hide
();
this
.
showAfterLoadAtlas
(
scene
,
data
);
},
this
,
RES
.
ResourceItem
.
TYPE_SHEET
);
}
else
{
this
.
showAfterLoadAtlas
(
scene
,
data
);
}
}
showAfterLoadAtlas
(
scene
:
Scene
,
data
)
{
if
(
this
.
_currentScene
)
{
this
.
_currentScene
.
destroy
();
this
.
_parent
.
removeChild
(
this
.
_currentScene
);
}
const
cls
=
this
.
_sceneClassMap
[
type
];
const
scene
:
Scene
=
new
cls
();
scene
.
loadSkin
();
scene
.
start
();
this
.
addToStage
(
scene
);
}
addMask
()
{
if
(
!
this
.
_mask
)
{
this
.
_mask
=
new
egret
.
Sprite
();
this
.
_mask
.
touchEnabled
=
true
;
this
.
_mask
.
graphics
.
beginFill
(
0
,
.
7
);
this
.
_mask
.
graphics
.
drawRect
(
0
,
0
,
750
,
1624
);
this
.
_mask
.
graphics
.
endFill
();
}
this
.
_mask
.
alpha
=
1
;
this
.
_parent
.
addChild
(
this
.
_mask
);
}
private
addToStage
(
scene
:
Scene
)
{
this
.
_currentScene
=
scene
;
this
.
_parent
.
addChild
(
scene
);
...
...
egret/libs/new_wx/views/layers.ts
View file @
de78d61c
...
...
@@ -2,16 +2,31 @@ class Layers extends eui.UILayer {
private
_topLayer
:
egret
.
Sprite
;
private
_popupLayer
:
egret
.
Sprite
;
private
_sceneLayer
:
egret
.
Sprite
;
private
_bottomLayer
:
egret
.
Sprite
;
init
(
root
:
eui
.
UILayer
)
{
root
.
addChild
(
this
);
this
.
_topLayer
=
new
egret
.
Sprite
();
this
.
_popupLayer
=
new
egret
.
Sprite
();
this
.
_sceneLayer
=
new
egret
.
Sprite
();
this
.
_bottomLayer
=
new
egret
.
Sprite
();
this
.
addChild
(
this
.
_bottomLayer
);
this
.
addChild
(
this
.
_sceneLayer
);
this
.
addChild
(
this
.
_popupLayer
);
this
.
addChild
(
this
.
_topLayer
);
}
_bg
:
egret
.
Bitmap
;
addFirstBackground
(
bitmap
:
egret
.
Bitmap
):
any
{
this
.
_bg
=
bitmap
;
this
.
_bottomLayer
.
addChild
(
bitmap
);
}
removeFirstBackground
():
any
{
if
(
this
.
_bg
)
this
.
_bottomLayer
.
removeChild
(
this
.
_bg
);
this
.
_bg
=
null
;
}
get
topLayer
()
{
return
this
.
_topLayer
}
get
popupLayer
()
{
return
this
.
_popupLayer
}
get
sceneLayer
()
{
return
this
.
_sceneLayer
}
...
...
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