Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
db-game-template
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
崔立强
db-game-template
Commits
52847873
Commit
52847873
authored
Sep 17, 2018
by
wildfirecode
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update readme
parent
a988bbd1
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
34 additions
and
352 deletions
+34
-352
README.md
README.md
+34
-18
bricks.ts
egret/scripts/bricks/bricks.ts
+0
-64
config.android.ts
egret/scripts/config.android.ts
+0
-38
config.bricks.ts
egret/scripts/config.bricks.ts
+0
-55
config.ios.ts
egret/scripts/config.ios.ts
+0
-38
config.wxgame.ts
egret/scripts/config.wxgame.ts
+0
-57
wxgame.ts
egret/scripts/wxgame/wxgame.ts
+0
-82
No files found.
README.md
View file @
52847873
...
...
@@ -36,10 +36,39 @@ npm run buildExml
-
demo皮肤 https://mng.duiba.com.cn/DuibaNgameBrick/edit/476
-
demo线上url http://activity-2.m.duiba.com.cn/ngame/index?id=3122353&dbnewopen&dpm=1.5.677.4&dcm=202.3122353.4.677
## 备注
项目创建和维护流程
## 项目结构介绍
### .vscode
vscode调试配置文件,需要提前安装chrome debugger插件。
### egret
egret相关根目录。特别说明:暂时无法把其中文件放到根目录,后续优化。
-
bin-release 发布文件目录,oss提交根目录
-
libs库文件夹
-
resource对应egret的resource
-
scripts为发布相关脚本
-
src源码目录。
-
template勿删。
-
autoMerger.js生成图集合并的项目配置文件。
-
egretProperties.json,egret项目配置
-
index.html,入口文件。
-
project.json,同以前,后续考虑优化掉。
-
publish.js oss发布文件。
-
tsconfig.json ,ts配置。
-
wingProperties.json,egret wing配置。
### mock
mock配置,同以前。
### .buildrc.js
构建配置
### .npmrc
npm源配置。
### build.js
构建脚本。
## 说明
### 自动化图集合并说明
不会合并组内的jpg。一般jpg都是外部加载,合入png图集,会显著增加png图集的体积
## 项目创建和维护流程
1.
先建立一个分支
...
...
@@ -72,17 +101,4 @@ git branch -D kickball-20180910
git push origin :kickball-20180910
如果不需backup后面要维护,那么留着分支,不必合并到主分支。这样可以避免频繁提交导致的频繁git pull,提升效率。
发布到线上
全发布 :npm run build
[
项目名称
]
。比如npm run build kickball-egret
仅仅发布src下的TS代码:npm run buildTS
[
项目名称
]
。比如npm run buildTS kickball-egret
仅仅发布exmls文件:npm run buildExml
[
项目名称
]
。比如npm run buildExml kickball-egret。
自动化图集合并说明
不会合并组内的jpg。一般jpg都是外部加载,合入png图集,会显著增加png图集的体积
\ No newline at end of file
如果不需backup后面要维护,那么留着分支,不必合并到主分支。这样可以避免频繁提交导致的频繁git pull,提升效率。
\ No newline at end of file
egret/scripts/bricks/bricks.ts
deleted
100644 → 0
View file @
a988bbd1
import
*
as
fs
from
'fs'
;
import
*
as
path
from
'path'
;
type
ManifestConfig
=
{
initial
:
string
[],
game
:
string
[]
}
export
class
BricksPlugin
implements
plugins
.
Command
{
constructor
()
{
}
async
onFile
(
file
:
plugins
.
File
)
{
const
filename
=
file
.
basename
;
if
(
filename
==
'manifest.json'
)
{
const
contents
=
file
.
contents
.
toString
();
const
jsonData
:
ManifestConfig
=
JSON
.
parse
(
contents
);
let
content
=
''
;
content
+=
`BK.Script.loadlib("GameRes://js/promise.js");\n`
;
for
(
let
item
of
jsonData
.
initial
)
{
if
(
item
!=
'js/promise.js'
&&
item
!=
'js/promise.min.js'
)
{
content
+=
`BK.Script.loadlib("GameRes://
${
item
}
");\n`
}
}
for
(
let
item
of
jsonData
.
game
)
{
content
+=
`BK.Script.loadlib("GameRes://
${
item
}
");\n`
}
content
+=
`BK.Script.loadlib("GameRes://egret.bricks.js");\n`
file
.
path
=
file
.
dirname
+
'/manifest.js'
file
.
contents
=
new
Buffer
(
content
);
}
else
if
(
filename
==
'main.js'
)
{
const
content
=
file
.
contents
.
toString
();
let
result
=
content
.
replace
(
/RES
\.
loadConfig
\(
"resource
\/
default
\.
res
\.
json", "resource
\/
"
\)
/gm
,
'RES.loadConfig("GameRes://resource/default.res.json", "GameRes://resource/")'
);
result
=
result
.
replace
(
/eui
\.
Theme
\(
"resource
\/
default
\.
thm
\.
json", _this
\.
stage
\)
/gm
,
'eui.Theme("GameRes://resource/default.thm.json", _this.stage)'
);
result
+=
";global.Main = Main;"
;
file
.
path
=
file
.
dirname
+
'/main.js'
file
.
contents
=
new
Buffer
(
result
);
}
else
if
(
filename
==
'promise.js'
)
{
return
null
;
}
return
file
;
}
async
onFinish
(
pluginContext
:
plugins
.
CommandContext
)
{
//同步index.html 配置到main.js
let
mainJSPath
=
path
.
join
(
pluginContext
.
outputDir
,
'main.js'
);
let
mainJSContent
=
fs
.
readFileSync
(
mainJSPath
,
{
encoding
:
"utf8"
});
let
projectConfig
=
pluginContext
.
buildConfig
.
projectConfig
;
mainJSContent
=
mainJSContent
.
replace
(
/frameRate: 30/gm
,
`frameRate:
${
projectConfig
.
frameRate
}
`
);
mainJSContent
=
mainJSContent
.
replace
(
/contentWidth: 640/gm
,
`contentWidth:
${
projectConfig
.
contentWidth
}
`
);
mainJSContent
=
mainJSContent
.
replace
(
/contentHeight: 1136/gm
,
`contentHeight:
${
projectConfig
.
contentHeight
}
`
);
mainJSContent
=
mainJSContent
.
replace
(
/entryClassName: "Main"/gm
,
`entryClassName:
${
projectConfig
.
entryClassName
}
`
);
mainJSContent
=
mainJSContent
.
replace
(
/scaleMode: "showAll"/gm
,
`scaleMode:
${
projectConfig
.
scaleMode
}
`
);
mainJSContent
=
mainJSContent
.
replace
(
/orientation: "auto"/gm
,
`orientation:
${
projectConfig
.
orientation
}
`
);
fs
.
writeFileSync
(
mainJSPath
,
mainJSContent
);
}
}
declare
var
egret
;
\ No newline at end of file
egret/scripts/config.android.ts
deleted
100644 → 0
View file @
a988bbd1
/// 阅读 api.d.ts 查看文档
///<reference path="api.d.ts"/>
import
*
as
path
from
'path'
;
import
{
UglifyPlugin
,
CompilePlugin
,
ManifestPlugin
,
ExmlPlugin
,
EmitResConfigFilePlugin
,
TextureMergerPlugin
}
from
'built-in'
;
import
{
BricksPlugin
}
from
'./bricks/bricks'
;
import
{
CustomPlugin
}
from
'./myplugin'
;
import
*
as
defaultConfig
from
'./config'
;
const
config
:
ResourceManagerConfig
=
{
buildConfig
:
(
params
)
=>
{
const
{
target
,
command
,
projectName
,
version
}
=
params
;
const
outputDir
=
`../
${
projectName
}
_android/assets/game`
;
return
{
outputDir
,
commands
:
[
// new CompilePlugin({ libraryType: "debug", defines: { DEBUG: false, RELEASE: true } }),
new
ExmlPlugin
(
'commonjs'
),
// 非 EUI 项目关闭此设置
new
CompilePlugin
({
libraryType
:
"release"
,
defines
:
{
DEBUG
:
false
,
RELEASE
:
true
}
}),
new
UglifyPlugin
([{
sources
:
[
"main.js"
],
target
:
"main.min.js"
}]),
new
ManifestPlugin
({
output
:
'manifest.json'
})
]
}
},
mergeSelector
:
defaultConfig
.
mergeSelector
,
typeSelector
:
defaultConfig
.
typeSelector
}
export
=
config
;
egret/scripts/config.bricks.ts
deleted
100644 → 0
View file @
a988bbd1
/// 阅读 api.d.ts 查看文档
///<reference path="api.d.ts"/>
import
*
as
path
from
'path'
;
import
{
UglifyPlugin
,
CompilePlugin
,
ManifestPlugin
,
ExmlPlugin
,
EmitResConfigFilePlugin
,
TextureMergerPlugin
,
CleanPlugin
}
from
'built-in'
;
import
{
BricksPlugin
}
from
'./bricks/bricks'
;
import
{
CustomPlugin
}
from
'./myplugin'
;
import
*
as
defaultConfig
from
'./config'
;
const
config
:
ResourceManagerConfig
=
{
buildConfig
:
(
params
)
=>
{
const
{
target
,
command
,
projectName
,
version
}
=
params
;
const
outputDir
=
`../
${
projectName
}
_bricks/PublicBrickEngineGame/Res`
;
if
(
command
==
'build'
)
{
return
{
outputDir
,
commands
:
[
new
CompilePlugin
({
libraryType
:
"debug"
,
defines
:
{
DEBUG
:
true
,
RELEASE
:
false
}
}),
new
ExmlPlugin
(
'commonjs'
),
// 非 EUI 项目关闭此设置
new
ManifestPlugin
({
output
:
'manifest.json'
}),
new
BricksPlugin
()
]
}
}
else
if
(
command
==
'publish'
)
{
console
.
log
(
'执行publish'
)
return
{
outputDir
,
commands
:
[
new
CompilePlugin
({
libraryType
:
"debug"
,
defines
:
{
DEBUG
:
true
,
RELEASE
:
false
}
}),
new
ExmlPlugin
(
'commonjs'
),
// 非 EUI 项目关闭此设置
new
ManifestPlugin
({
output
:
'manifest.json'
}),
new
UglifyPlugin
([{
sources
:
[
"main.js"
],
target
:
"js/main.min.js"
}
]),
new
BricksPlugin
(),
]
}
}
else
{
throw
`unknown command :
${
params
.
command
}
`
;
}
},
mergeSelector
:
defaultConfig
.
mergeSelector
,
typeSelector
:
defaultConfig
.
typeSelector
}
export
=
config
;
egret/scripts/config.ios.ts
deleted
100644 → 0
View file @
a988bbd1
/// 阅读 api.d.ts 查看文档
///<reference path="api.d.ts"/>
import
*
as
path
from
'path'
;
import
{
UglifyPlugin
,
CompilePlugin
,
ManifestPlugin
,
ExmlPlugin
,
EmitResConfigFilePlugin
,
TextureMergerPlugin
}
from
'built-in'
;
import
{
BricksPlugin
}
from
'./bricks/bricks'
;
import
{
CustomPlugin
}
from
'./myplugin'
;
import
*
as
defaultConfig
from
'./config'
;
const
config
:
ResourceManagerConfig
=
{
buildConfig
:
(
params
)
=>
{
const
{
target
,
command
,
projectName
,
version
}
=
params
;
const
outputDir
=
`../
${
projectName
}
_ios/assets/game`
;
return
{
outputDir
,
commands
:
[
new
CompilePlugin
({
libraryType
:
"debug"
,
defines
:
{
DEBUG
:
false
,
RELEASE
:
true
}
}),
new
ExmlPlugin
(
'commonjs'
),
// 非 EUI 项目关闭此设置
new
CompilePlugin
({
libraryType
:
"release"
,
defines
:
{
DEBUG
:
false
,
RELEASE
:
true
}
}),
new
UglifyPlugin
([{
sources
:
[
"main.js"
],
target
:
"main.min.js"
}]),
new
ManifestPlugin
({
output
:
'manifest.json'
})
]
}
},
mergeSelector
:
defaultConfig
.
mergeSelector
,
typeSelector
:
defaultConfig
.
typeSelector
}
export
=
config
;
egret/scripts/config.wxgame.ts
deleted
100644 → 0
View file @
a988bbd1
/// 阅读 api.d.ts 查看文档
///<reference path="api.d.ts"/>
import
*
as
path
from
'path'
;
import
{
UglifyPlugin
,
CompilePlugin
,
ManifestPlugin
,
ExmlPlugin
,
EmitResConfigFilePlugin
,
TextureMergerPlugin
,
CleanPlugin
}
from
'built-in'
;
import
{
WxgamePlugin
}
from
'./wxgame/wxgame'
;
import
{
CustomPlugin
}
from
'./myplugin'
;
import
*
as
defaultConfig
from
'./config'
;
const
config
:
ResourceManagerConfig
=
{
buildConfig
:
(
params
)
=>
{
const
{
target
,
command
,
projectName
,
version
}
=
params
;
const
outputDir
=
`../
${
projectName
}
_wxgame`
;
if
(
command
==
'build'
)
{
return
{
outputDir
,
commands
:
[
new
CleanPlugin
({
matchers
:
[
"js"
,
"resource"
]
}),
new
CompilePlugin
({
libraryType
:
"debug"
,
defines
:
{
DEBUG
:
true
,
RELEASE
:
false
}
}),
new
ExmlPlugin
(
'commonjs'
),
// 非 EUI 项目关闭此设置
new
WxgamePlugin
(),
new
ManifestPlugin
({
output
:
'manifest.js'
})
]
}
}
else
if
(
command
==
'publish'
)
{
return
{
outputDir
,
commands
:
[
new
CleanPlugin
({
matchers
:
[
"js"
,
"resource"
]
}),
new
CompilePlugin
({
libraryType
:
"release"
,
defines
:
{
DEBUG
:
false
,
RELEASE
:
true
}
}),
new
ExmlPlugin
(
'commonjs'
),
// 非 EUI 项目关闭此设置
new
WxgamePlugin
(),
new
UglifyPlugin
([{
sources
:
[
"main.js"
],
target
:
"main.min.js"
}
]),
new
ManifestPlugin
({
output
:
'manifest.js'
})
]
}
}
else
{
throw
`unknown command :
${
params
.
command
}
`
;
}
},
mergeSelector
:
defaultConfig
.
mergeSelector
,
typeSelector
:
defaultConfig
.
typeSelector
}
export
=
config
;
egret/scripts/wxgame/wxgame.ts
deleted
100644 → 0
View file @
a988bbd1
import
*
as
fs
from
'fs'
;
import
*
as
path
from
'path'
;
export
class
WxgamePlugin
implements
plugins
.
Command
{
constructor
()
{
}
async
onFile
(
file
:
plugins
.
File
)
{
if
(
file
.
extname
==
'.js'
)
{
const
filename
=
file
.
origin
;
if
(
filename
==
"libs/modules/promise/promise.js"
||
filename
==
'libs/modules/promise/promise.min.js'
)
{
return
null
;
}
if
(
filename
==
'libs/modules/egret/egret.js'
||
filename
==
'libs/modules/egret/egret.min.js'
)
{
let
content
=
file
.
contents
.
toString
();
content
+=
`;window.egret = egret;`
;
content
=
content
.
replace
(
/definition = __global/
,
"definition = window"
);
file
.
contents
=
new
Buffer
(
content
);
}
else
{
let
content
=
file
.
contents
.
toString
();
if
(
filename
==
"libs/modules/res/res.js"
||
filename
==
'libs/modules/res/res.min.js'
||
filename
==
'libs/modules/assetsmanager/assetsmanager.min.js'
||
filename
==
'libs/modules/assetsmanager/assetsmanager.js'
)
{
content
+=
";window.RES = RES;"
}
if
(
filename
==
"libs/modules/eui/eui.js"
||
filename
==
'libs/modules/eui/eui.min.js'
)
{
content
+=
";window.eui = eui;"
}
if
(
filename
==
'libs/modules/dragonBones/dragonBones.js'
||
filename
==
'libs/modules/dragonBones/dragonBones.min.js'
)
{
content
+=
';window.dragonBones = dragonBones'
;
}
content
=
"var egret = window.egret;"
+
content
;
if
(
filename
==
'main.js'
)
{
content
+=
";window.Main = Main;"
}
file
.
contents
=
new
Buffer
(
content
);
}
}
return
file
;
}
async
onFinish
(
pluginContext
:
plugins
.
CommandContext
)
{
//同步 index.html 配置到 game.js
const
gameJSPath
=
path
.
join
(
pluginContext
.
outputDir
,
"game.js"
);
if
(
!
fs
.
existsSync
(
gameJSPath
))
{
console
.
log
(
`
${
gameJSPath
}
不存在,请先使用 Launcher 发布微信小游戏`
);
return
;
}
let
gameJSContent
=
fs
.
readFileSync
(
gameJSPath
,
{
encoding
:
"utf8"
});
const
projectConfig
=
pluginContext
.
buildConfig
.
projectConfig
;
const
optionStr
=
`entryClassName:
${
projectConfig
.
entryClassName
}
,\n\t\t`
+
`orientation:
${
projectConfig
.
orientation
}
,\n\t\t`
+
`frameRate:
${
projectConfig
.
frameRate
}
,\n\t\t`
+
`scaleMode:
${
projectConfig
.
scaleMode
}
,\n\t\t`
+
`contentWidth:
${
projectConfig
.
contentWidth
}
,\n\t\t`
+
`contentHeight:
${
projectConfig
.
contentHeight
}
,\n\t\t`
+
`showFPS:
${
projectConfig
.
showFPS
}
,\n\t\t`
+
`fpsStyles:
${
projectConfig
.
fpsStyles
}
,\n\t\t`
+
`showLog:
${
projectConfig
.
showLog
}
,\n\t\t`
+
`maxTouches:
${
projectConfig
.
maxTouches
}
,`
;
const
reg
=
/
\/\/
----auto option start----
[\s\S]
*
\/\/
----auto option end----/
;
const
replaceStr
=
'
\
/
\
/----auto option start----
\
n
\
t
\
t'
+
optionStr
+
'
\
n
\
t
\
t
\
/
\
/----auto option end----'
;
gameJSContent
=
gameJSContent
.
replace
(
reg
,
replaceStr
);
fs
.
writeFileSync
(
gameJSPath
,
gameJSContent
);
//修改横竖屏
let
orientation
;
if
(
projectConfig
.
orientation
==
'"landscape"'
)
{
orientation
=
"landscape"
;
}
else
{
orientation
=
"portrait"
;
}
const
gameJSONPath
=
path
.
join
(
pluginContext
.
outputDir
,
"game.json"
);
let
gameJSONContent
=
JSON
.
parse
(
fs
.
readFileSync
(
gameJSONPath
,
{
encoding
:
"utf8"
}));
gameJSONContent
.
deviceOrientation
=
orientation
;
fs
.
writeFileSync
(
gameJSONPath
,
JSON
.
stringify
(
gameJSONContent
,
null
,
"
\
t"
));
}
}
\ No newline at end of file
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