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
ccde8b83
Commit
ccde8b83
authored
Oct 10, 2018
by
wildfirecode
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
efd335fc
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
211 additions
and
15 deletions
+211
-15
.DS_Store
egret/.DS_Store
+0
-0
index.html
egret/index.html
+4
-1
coin.png
egret/resource/assets/startScene/coin.png
+0
-0
gift.png
egret/resource/assets/startScene/gift.png
+0
-0
gift2.png
egret/resource/assets/startScene/gift2.png
+0
-0
goldenbox.png
egret/resource/assets/startScene/goldenbox.png
+0
-0
monkey.png
egret/resource/assets/startScene/monkey.png
+0
-0
silverbox.png
egret/resource/assets/startScene/silverbox.png
+0
-0
woodbox.png
egret/resource/assets/startScene/woodbox.png
+0
-0
default.res.json
egret/resource/default.res.json
+29
-4
MyExmlPlugin.ts
egret/scripts/MyExmlPlugin.ts
+6
-1
Box.ts
egret/src/startScene/Box.ts
+26
-0
BoxType.ts
egret/src/startScene/BoxType.ts
+8
-0
Monkey.ts
egret/src/startScene/Monkey.ts
+69
-0
StartScene.ts
egret/src/startScene/StartScene.ts
+69
-9
No files found.
egret/.DS_Store
View file @
ccde8b83
No preview for this file type
egret/index.html
View file @
ccde8b83
...
...
@@ -25,7 +25,7 @@
<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=
"
3
0"
data-content-width=
"750"
data-content-height=
"1624"
data-multi-fingered=
"2"
data-scale-mode=
"showAll"
data-frame-rate=
"
6
0"
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>
...
...
@@ -42,6 +42,9 @@
<!-- <script src="default.thm.js"></script> -->
<script
src=
"output.js"
></script>
<script>
var
debug
=
1
;
var
moneyHandSize
=
40
;
var
type
=
'woodbox'
;
var
gameId
=
1
;
var
CFG
=
{
appInfo
:
{
...
...
egret/resource/assets/startScene/coin.png
0 → 100644
View file @
ccde8b83
11 KB
egret/resource/assets/startScene/gift.png
0 → 100644
View file @
ccde8b83
23.5 KB
egret/resource/assets/startScene/gift2.png
0 → 100644
View file @
ccde8b83
25.7 KB
egret/resource/assets/startScene/goldenbox.png
0 → 100644
View file @
ccde8b83
32 KB
egret/resource/assets/startScene/monkey
/monkey
.png
→
egret/resource/assets/startScene/monkey.png
View file @
ccde8b83
File moved
egret/resource/assets/startScene/silverbox.png
0 → 100644
View file @
ccde8b83
37.8 KB
egret/resource/assets/startScene/woodbox.png
0 → 100644
View file @
ccde8b83
40.6 KB
egret/resource/default.res.json
View file @
ccde8b83
...
...
@@ -17,8 +17,8 @@
"name"
:
"rule"
},
{
"
keys"
:
"monkey_png
"
,
"
name"
:
"start_monkey
"
"
name"
:
"preload
"
,
"
keys"
:
"gift2_png,coin_png,gift_png,goldenbox_png,silverbox_png,woodbox_png
"
}
],
"resources"
:
[
...
...
@@ -78,9 +78,34 @@
"name"
:
"bg_jpg"
},
{
"
url"
:
"assets/startScene/monkey/monkey.
png"
,
"
name"
:
"gift2_
png"
,
"type"
:
"image"
,
"name"
:
"monkey_png"
"url"
:
"assets/startScene/gift2.png"
},
{
"name"
:
"coin_png"
,
"type"
:
"image"
,
"url"
:
"assets/startScene/coin.png"
},
{
"name"
:
"gift_png"
,
"type"
:
"image"
,
"url"
:
"assets/startScene/gift.png"
},
{
"name"
:
"goldenbox_png"
,
"type"
:
"image"
,
"url"
:
"assets/startScene/goldenbox.png"
},
{
"name"
:
"silverbox_png"
,
"type"
:
"image"
,
"url"
:
"assets/startScene/silverbox.png"
},
{
"name"
:
"woodbox_png"
,
"type"
:
"image"
,
"url"
:
"assets/startScene/woodbox.png"
}
]
}
\ No newline at end of file
egret/scripts/MyExmlPlugin.ts
View file @
ccde8b83
...
...
@@ -9,7 +9,12 @@ export class MyExmlPlugin extends ExmlPlugin2 implements plugins.Command {
async
onFile
(
file
:
plugins
.
File
)
{
const
excludes
=
[
'coin.png'
,
'goBtn.png'
,
'gift.png'
,
'gift2.png'
,
'goldenbox.png'
,
'silverbox.png'
,
'woodbox.png'
,
'monkey.png'
,
];
if
(
excludes
.
indexOf
(
file
.
basename
)
!=
-
1
)
{
return
file
;
...
...
egret/src/startScene/Box.ts
0 → 100644
View file @
ccde8b83
import
{
getImgURL
}
from
"../../libs/tc/util/GFun"
;
import
{
getResPath
}
from
"../utils"
;
export
default
class
Box
extends
egret
.
Sprite
{
private
_type
:
string
;
constructor
(
type
)
{
super
();
this
.
_type
=
type
;
}
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
);
this
.
addChild
(
pic
);
this
.
anchorOffsetX
=
picData
.
textureWidth
/
2
;
this
.
anchorOffsetY
=
picData
.
textureHeight
/
2
;
resolve
(
pic
)
},
this
,
RES
.
ResourceItem
.
TYPE_IMAGE
);
});
}
get
type
(){
return
this
.
_type
}
}
\ No newline at end of file
egret/src/startScene/BoxType.ts
0 → 100644
View file @
ccde8b83
export
default
class
BoxType
{
static
coin
=
'coin'
static
gift
=
'coin'
static
gift2
=
'coin'
static
goldenbox
=
'coin'
static
silverbox
=
'coin'
static
woodbox
=
'coin'
}
\ No newline at end of file
egret/src/startScene/Monkey.ts
0 → 100644
View file @
ccde8b83
import
{
getImgURL
}
from
"../../libs/tc/util/GFun"
;
import
{
getResPath
}
from
"../utils"
;
export
default
class
Monkey
extends
egret
.
Sprite
{
private
h
=
525
;
private
w
=
265
;
private
h0
=
8
;
private
w0
=
118
;
private
h1
=
23
;
private
w1
=
29
;
private
r1
;
private
len
;
constructor
()
{
super
();
this
.
anchorOffsetX
=
113
;
this
.
anchorOffsetY
=
8
;
const
a
=
this
.
w0
-
this
.
w1
;
const
b
=
this
.
h
-
this
.
h0
-
this
.
h1
;
this
.
r1
=
Math
.
tan
(
a
/
b
)
/
Math
.
PI
*
180
;
this
.
len
=
Math
.
sqrt
(
a
*
a
+
b
*
b
);
this
.
createBg
();
}
startShaking
()
{
this
.
addEventListener
(
egret
.
Event
.
ENTER_FRAME
,
this
.
onEnterFrame
,
this
);
}
stopShaking
()
{
this
.
addEventListener
(
egret
.
Event
.
ENTER_FRAME
,
this
.
onEnterFrame
,
this
);
}
reset
()
{
this
.
rotation
=
0
;
this
.
_dir
=
1
;
}
private
static
RANGE
=
30
;
private
_shakeSpeed
=
.
5
;
private
_dir
=
1
;
onEnterFrame
()
{
this
.
rotation
+=
this
.
_shakeSpeed
*
this
.
_dir
;
if
(
this
.
rotation
>
Monkey
.
RANGE
)
this
.
_dir
=
-
1
;
if
(
this
.
rotation
<
-
Monkey
.
RANGE
)
this
.
_dir
=
1
;
this
.
dispatchEvent
(
new
egret
.
Event
(
'pointUpdate'
,
false
,
false
,
this
.
getPoint
()))
}
getPoint
()
{
const
r
=
(
this
.
r1
+
this
.
rotation
)
/
180
*
Math
.
PI
;
const
a
=
Math
.
sin
(
r
)
*
this
.
len
;
const
b
=
Math
.
cos
(
r
)
*
this
.
len
;
const
y
=
b
;
const
x
=
-
a
;
return
new
egret
.
Point
(
x
,
y
);
}
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
);
this
.
addChild
(
pic
);
resolve
(
pic
)
},
this
,
RES
.
ResourceItem
.
TYPE_IMAGE
);
});
}
}
\ No newline at end of file
egret/src/startScene/StartScene.ts
View file @
ccde8b83
import
{
getImgURL
}
from
"../../libs/tc/util/GFun"
;
import
Scene
from
"../views/Scene
"
;
import
{
GamePlayModel
}
from
"../../libs/tw/model/game/GamePlayModel
"
;
import
{
getResPath
}
from
"../utils"
;
import
Scene
from
"../views/Scene"
;
import
Box
from
"./Box"
;
import
BoxType
from
"./BoxType"
;
import
Monkey
from
"./Monkey"
;
import
{
NetManager
}
from
"../../libs/tw/manager/NetManager"
;
const
{
TouchEvent
}
=
egret
;
export
default
class
StartScene
extends
Scene
{
start
(
data
?)
{
this
.
createBg
();
private
_monkey
:
Monkey
;
private
_shape
:
egret
.
Shape
;
async
start
(
data
?)
{
const
picData
:
any
=
await
this
.
getBg
();
const
pic
=
new
egret
.
Bitmap
(
picData
);
this
.
addChild
(
pic
);
const
box
=
new
Box
(
window
[
'type'
]);
this
.
addChild
(
box
);
box
.
x
=
box
.
stage
.
stageWidth
/
2
;
box
.
y
=
box
.
stage
.
stageHeight
/
2
;
await
box
.
createBg
();
const
monkey
=
new
Monkey
();
this
.
addChild
(
monkey
);
monkey
.
startShaking
();
monkey
.
addEventListener
(
'pointUpdate'
,
this
.
onPointUpdate
,
this
)
monkey
.
x
=
369
;
monkey
.
y
=
70
;
this
.
_monkey
=
monkey
;
if
(
window
[
'debug'
])
{
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);
}
onPointUpdate
(
e
:
egret
.
Event
)
{
const
point
=
e
.
data
as
egret
.
Point
;
if
(
window
[
'debug'
])
{
this
.
_shape
.
graphics
.
clear
();
this
.
_shape
.
graphics
.
beginFill
(
0xff0000
);
const
size
=
window
[
'moneyHandSize'
];
const
x
=
point
.
x
+
this
.
_monkey
.
x
;
const
y
=
point
.
y
+
this
.
_monkey
.
y
;
this
.
_shape
.
graphics
.
drawRect
(
x
-
size
/
2
,
y
-
size
/
2
,
size
,
size
);
this
.
_shape
.
graphics
.
endFill
();
}
}
async
create
Bg
()
{
async
get
Bg
()
{
let
url
=
getResPath
()
+
'resource/assets/startScene/bg.jpg'
;
url
=
await
getImgURL
(
url
);
RES
.
getResByUrl
(
url
,
(
picData
)
=>
{
const
pic
=
new
egret
.
Bitmap
(
picData
);
this
.
addChild
(
pic
);
},
this
,
RES
.
ResourceItem
.
TYPE_IMAGE
);
url
=
await
getImgURL
(
url
);
return
new
Promise
((
resolve
)
=>
{
RES
.
getResByUrl
(
url
,
(
picData
)
=>
{
resolve
(
picData
)
},
this
,
RES
.
ResourceItem
.
TYPE_IMAGE
);
});
}
protected
get
skinKey
()
{
return
'Start'
}
...
...
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