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
b1c28df0
Commit
b1c28df0
authored
Oct 10, 2018
by
wildfirecode
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
ccde8b83
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
56 additions
and
73 deletions
+56
-73
index.html
egret/index.html
+12
-4
index.ts
egret/libs/tc/index.ts
+0
-33
GFun.ts
egret/libs/tc/util/GFun.ts
+9
-13
MainBase.ts
egret/libs/tl/MainBase.ts
+20
-0
Box.ts
egret/src/startScene/Box.ts
+1
-3
Monkey.ts
egret/src/startScene/Monkey.ts
+0
-2
StartScene.ts
egret/src/startScene/StartScene.ts
+14
-18
No files found.
egret/index.html
View file @
b1c28df0
...
...
@@ -25,8 +25,8 @@
<body>
<div
style=
"margin: auto;width: 100%;height: 100%;"
class=
"egret-player"
data-entry-class=
"Main"
data-orientation=
"auto"
data-scale-mode=
"showAll"
data-frame-rate=
"60"
data-content-width=
"750"
data-content-height=
"1624"
data-multi-fingered=
"2"
data-show-fps=
"false"
data-show-log=
"false"
data-show-fps-style=
"x:0,y:0,size:12,textColor:0xffffff,bgAlpha:0.9"
>
data-scale-mode=
"showAll"
data-frame-rate=
"60"
data-content-width=
"750"
data-content-height=
"1624"
data-
multi-fingered=
"2"
data-
show-fps=
"false"
data-show-log=
"false"
data-show-fps-style=
"x:0,y:0,size:12,textColor:0xffffff,bgAlpha:0.9"
>
</div>
<script
src=
"libs/modules/egret/egret.js"
></script>
...
...
@@ -42,9 +42,17 @@
<!-- <script src="default.thm.js"></script> -->
<script
src=
"output.js"
></script>
<script>
var
debug
=
1
;
var
debug
=
1
;
var
moneyHandSize
=
40
;
var
type
=
'woodbox'
;
var
boxmap
=
{
coin
:
0
,
gift
:
0
,
gift2
:
0
,
woodbox
:
1
,
//木宝箱
silverbox
:
3
,
//银宝箱
goldenbox
:
5
,
//金宝箱
};
var
gameId
=
1
;
var
CFG
=
{
appInfo
:
{
...
...
egret/libs/tc/index.ts
View file @
b1c28df0
// import { GLang } from './util/GLang';
// import { INetData } from './interface/INetData';
// import { GTime } from './util/GTime';
// import { GPool } from './util/GPool';
// import { GMath } from './util/GMath';
// import { GFun,getImgURL } from './util/GFun';
// import { GDispatcher } from './util/GDispatcher';
// import { GConsole } from './util/GConsole';
// import { GCache } from './util/GCache';
// import { ABPanelManager } from './manager/ABPanelManager';
// import { IModuleData } from './interface/IModuleData';
// import { IDestroy } from './interface/IDestroy';
// import { TimeFormat } from './enum/TimeFormat';
// import { ResPriority } from './enum/ResPriority';
// import { ModuleType } from './enum/ModuleType';
// import { LayoutType } from './enum/LayoutType';
// import { ABModule } from "./component/ABModule";
// import { IData } from './interface/IData';
// import { ABAnimationManager } from './manager/ABAnimationManager';
// import { ABAudioManager } from './manager/ABAudioManager';
// import { ABResManager } from './manager/ABResManager';
// import { ABSceneManager } from './manager/ABSceneManager';
// import { ABStageManager } from './manager/ABStageManager';
// import { ABDataManager } from './manager/ABDataManager';
// import { ABModuleManager } from './manager/ABModuleManager';
// import { ABNetManager } from './manager/ABNetManager';
// import { ABVideoManager } from './manager/ABVideoManager';
// export {
// ABModule, LayoutType, ModuleType, ResPriority, TimeFormat, IData, IDestroy, INetData,
// IModuleData, ABAnimationManager, ABAudioManager, ABDataManager, ABModuleManager, ABNetManager,
// ABPanelManager, ABResManager, ABSceneManager, ABStageManager, ABVideoManager, GCache, GConsole,
// GDispatcher, GFun, GMath, GPool, GTime, GLang,getImgURL
// }
export
const
a
=
1
\ No newline at end of file
egret/libs/tc/util/GFun.ts
View file @
b1c28df0
...
...
@@ -69,30 +69,26 @@ export class GFun {
}
}
const
check_webp_feature
=
(
callback
)
=>
{
export
const
check_webp_feature
=
(
)
=>
{
const
_support_webp_
=
localStorage
.
getItem
(
'_support_webp_'
);
if
(
_support_webp_
!==
null
)
{
return
callback
(
_support_webp_
===
'1'
)
return
_support_webp_
===
'1'
;
}
const
img
=
new
Image
();
img
.
onload
=
function
()
{
const
result
=
(
img
.
width
>
0
)
&&
(
img
.
height
>
0
);
callback
(
result
);
localStorage
.
setItem
(
'_support_webp_'
,
result
?
'1'
:
'0'
)
};
img
.
onerror
=
function
()
{
callback
(
false
);
localStorage
.
setItem
(
'_support_webp_'
,
'0'
)
};
img
.
src
=
"data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA"
;
return
false
;
}
export
const
getImgURL
=
(
url
:
string
):
any
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
check_webp_feature
((
isSupport
)
=>
{
if
(
isSupport
)
url
+=
'?x-oss-process=image/format,webp'
;
resolve
(
url
);
})
})
}
\ No newline at end of file
// export const getImgURL = (url: string): any => {
// const isSupport = check_webp_feature();
// if (isSupport)
// return url + '?x-oss-process=image/format,webp';
// return url;
// }
\ No newline at end of file
egret/libs/tl/MainBase.ts
View file @
b1c28df0
...
...
@@ -7,8 +7,27 @@ import { DataManager } from "../tw/manager/DataManager";
import
{
NetManager
}
from
"../tw/manager/NetManager"
;
import
AssetAdapter
from
"./adapter/AssetAdapter"
;
import
ThemeAdapter
from
"./adapter/ThemeAdapter"
;
import
{
check_webp_feature
}
from
"../tc/util/GFun"
;
export
default
class
MainBase
extends
eui
.
UILayer
{
constructor
()
{
super
();
check_webp_feature
();
}
private
injectRES
()
{
if
(
RES
.
fileSystem
[
'getFileOld'
])
return
;
RES
.
fileSystem
[
'getFileOld'
]
=
RES
.
fileSystem
.
getFile
;
window
[
'RES'
].
fileSystem
.
getFile
=
function
(
filename
:
string
)
{
var
result
=
RES
.
fileSystem
[
'getFileOld'
](
filename
);
if
(
result
&&
result
.
url
)
{
result
=
JSON
.
parse
(
JSON
.
stringify
(
result
));
result
.
url
=
result
.
url
.
replace
(
'.png'
,
'.png?x-oss-process=image/format,webp'
);
result
.
url
=
result
.
url
.
replace
(
'.jpg'
,
'.jpg?x-oss-process=image/format,webp'
);
}
return
result
;
}
}
protected
createChildren
():
void
{
super
.
createChildren
();
egret
.
lifecycle
.
addLifecycleListener
((
context
)
=>
{
...
...
@@ -59,6 +78,7 @@ export default class MainBase extends eui.UILayer {
try
{
await
RES
.
loadConfig
(
"default.res.json"
,
getResPath
()
+
"resource/"
);
await
this
.
loadTheme
();
this
.
injectRES
();
}
catch
(
e
)
{
console
.
error
(
e
);
...
...
egret/src/startScene/Box.ts
View file @
b1c28df0
import
{
getImgURL
}
from
"../../libs/tc/util/GFun"
;
import
{
getResPath
}
from
"../utils"
;
export
default
class
Box
extends
egret
.
Sprite
{
...
...
@@ -10,7 +9,6 @@ export default class Box extends egret.Sprite {
async
createBg
()
{
let
url
=
getResPath
()
+
`resource/assets/startScene/
${
this
.
_type
}
.png`
;
url
=
await
getImgURL
(
url
);
return
new
Promise
((
resolve
)
=>
{
RES
.
getResByUrl
(
url
,
(
picData
)
=>
{
const
pic
=
new
egret
.
Bitmap
(
picData
);
...
...
@@ -22,5 +20,5 @@ export default class Box extends egret.Sprite {
});
}
get
type
()
{
return
this
.
_type
}
get
type
()
{
return
this
.
_type
}
}
\ No newline at end of file
egret/src/startScene/Monkey.ts
View file @
b1c28df0
import
{
getImgURL
}
from
"../../libs/tc/util/GFun"
;
import
{
getResPath
}
from
"../utils"
;
export
default
class
Monkey
extends
egret
.
Sprite
{
...
...
@@ -57,7 +56,6 @@ export default class Monkey extends egret.Sprite {
async
createBg
()
{
let
url
=
getResPath
()
+
`resource/assets/startScene/monkey.png`
;
url
=
await
getImgURL
(
url
);
return
new
Promise
((
resolve
)
=>
{
RES
.
getResByUrl
(
url
,
(
picData
)
=>
{
const
pic
=
new
egret
.
Bitmap
(
picData
);
...
...
egret/src/startScene/StartScene.ts
View file @
b1c28df0
import
{
getImgURL
}
from
"../../libs/tc/util/GFun"
;
import
{
GamePlayModel
}
from
"../../libs/tw/model/game/GamePlayModel"
;
import
{
getResPath
}
from
"../utils"
;
import
Scene
from
"../views/Scene"
;
...
...
@@ -6,6 +5,8 @@ import Box from "./Box";
import
BoxType
from
"./BoxType"
;
import
Monkey
from
"./Monkey"
;
import
{
NetManager
}
from
"../../libs/tw/manager/NetManager"
;
import
PanelCtrl
from
"../ctrls/panelCtrl"
;
import
{
ModuleTypes
}
from
"../types/sceneTypes"
;
const
{
TouchEvent
}
=
egret
;
export
default
class
StartScene
extends
Scene
{
...
...
@@ -17,7 +18,7 @@ export default class StartScene extends Scene {
const
pic
=
new
egret
.
Bitmap
(
picData
);
this
.
addChild
(
pic
);
const
box
=
new
Box
(
window
[
'type'
]
);
const
box
=
new
Box
(
BoxType
.
coin
);
this
.
addChild
(
box
);
box
.
x
=
box
.
stage
.
stageWidth
/
2
;
box
.
y
=
box
.
stage
.
stageHeight
/
2
;
...
...
@@ -35,24 +36,21 @@ export default class StartScene extends Scene {
this
.
_shape
=
new
egret
.
Shape
();
this
.
addChild
(
this
.
_shape
);
}
const
map
=
{
woodbox
:
1
,
silverbox
:
3
,
goldenbox
:
5
,
};
const
model
=
new
GamePlayModel
();
model
.
update
();
NetManager
.
ins
.
getInfo
(()
=>
{
model
.
doStart
(()
=>
{
model
.
submit
(()
=>
{
},
map
[
box
.
type
])
},
false
);
});
// box.addEventListener(egret.TouchEvent.TOUCH_TAP, () => {
// }, this);
box
.
touchEnabled
=
true
;
box
.
addEventListener
(
egret
.
TouchEvent
.
TOUCH_BEGIN
,
()
=>
{
NetManager
.
ins
.
getInfo
(()
=>
{
model
.
doStart
(()
=>
{
model
.
submit
(()
=>
{
},
window
[
'boxmap'
][
box
.
type
])
},
false
);
});
NetManager
.
ins
.
getRule
(()
=>
{
PanelCtrl
.
instance
.
show
(
ModuleTypes
.
RULE_PANEL
);
})
},
this
);
}
onPointUpdate
(
e
:
egret
.
Event
)
{
...
...
@@ -67,10 +65,8 @@ export default class StartScene extends Scene {
this
.
_shape
.
graphics
.
endFill
();
}
}
async
getBg
()
{
let
url
=
getResPath
()
+
'resource/assets/startScene/bg.jpg'
;
url
=
await
getImgURL
(
url
);
return
new
Promise
((
resolve
)
=>
{
RES
.
getResByUrl
(
url
,
(
picData
)
=>
{
resolve
(
picData
)
...
...
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