Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
crazyflirt
Project
Overview
Details
Activity
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
Shawn Wang
crazyflirt
Commits
8e0554a7
Commit
8e0554a7
authored
May 05, 2018
by
Matt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add map
parent
7196a511
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
95 additions
and
5 deletions
+95
-5
Map.ts
fe/src/Map.ts
+43
-0
MapGrid.ts
fe/src/MapGrid.ts
+31
-0
Store.ts
fe/src/Store.ts
+18
-3
GameScene.ts
fe/src/scenes/GameScene.ts
+3
-2
No files found.
fe/src/Map.ts
0 → 100644
View file @
8e0554a7
const
gridWidth
=
72
const
gridHeight
=
72
const
gridsInX
=
14
const
gridsInY
=
10
class
Map
extends
egret
.
Sprite
{
private
grids
:
any
=
[]
public
constructor
()
{
super
();
this
.
init
()
}
// 初始化(给开始按钮绑定点击事件)
private
init
()
{
console
.
log
(
'Map.init'
)
for
(
let
i
=
0
;
i
<
gridsInY
;
i
++
)
{
this
.
grids
.
push
([])
for
(
let
j
=
0
;
j
<
gridsInX
;
j
++
)
{
const
grid
=
new
MapGrid
()
grid
.
x
=
j
*
gridWidth
grid
.
y
=
i
*
gridHeight
this
.
grids
[
i
].
push
(
grid
)
this
.
addChild
(
grid
)
}
}
if
(
Store
.
isCatcher
())
{
const
mask
=
new
egret
.
Shape
()
mask
.
x
=
100
mask
.
y
=
100
mask
.
graphics
.
lineStyle
(
10
,
0x00ff00
);
mask
.
graphics
.
beginFill
(
0xff0000
,
1
);
mask
.
graphics
.
drawCircle
(
0
,
0
,
50
);
mask
.
graphics
.
endFill
();
mask
.
touchEnabled
=
false
this
.
mask
=
mask
}
// put display object to this scene
}
public
release
()
{
// 移除事件
}
}
\ No newline at end of file
fe/src/MapGrid.ts
0 → 100644
View file @
8e0554a7
class
MapGrid
extends
egret
.
Sprite
{
private
bg
:
egret
.
Bitmap
=
new
egret
.
Bitmap
()
public
constructor
()
{
super
();
this
.
init
()
}
// 初始化(给开始按钮绑定点击事件)
private
init
()
{
console
.
log
(
'Map.init'
)
this
.
bg
.
texture
=
RES
.
getRes
(
'grid_jpg'
)
this
.
addChild
(
this
.
bg
)
this
.
bg
.
touchEnabled
=
true
this
.
bg
.
addEventListener
(
egret
.
TouchEvent
.
TOUCH_BEGIN
,
this
.
onTouchTap
,
this
)
}
private
onTouchTap
()
{
console
.
log
(
this
,
this
.
parent
)
if
(
Store
.
isCatcher
())
{
console
.
log
(
this
,
this
.
parent
)
// const map = SceneManager.getInstance().gameScene.map
}
}
public
release
()
{
// 移除事件
}
}
\ No newline at end of file
fe/src/Store.ts
View file @
8e0554a7
const
_state
=
{}
let
_state
=
{
role
:
null
,
cid
:
null
,
roomId
:
null
,
}
class
Store
{
static
getState
()
{
return
_state
}
static
onMessage
(
message
)
{
const
{
payload
}
=
message
switch
(
message
.
type
)
{
case
'start'
:
case
'game_ready'
:
const
{
cid
,
room_id
,
payload
:
{
role
}
}
=
payload
_state
=
{
...
_state
,
cid
,
role
,
roomId
:
room_id
,
}
break
;
default
:
...
...
@@ -16,4 +25,9 @@ class Store {
}
return
_state
}
static
isCatcher
()
{
return
true
return
_state
.
role
===
'ghost'
}
}
\ No newline at end of file
fe/src/scenes/GameScene.ts
View file @
8e0554a7
class
GameScene
extends
egret
.
Sprite
{
private
controller
:
egret
.
Sprite
public
map
public
constructor
()
{
super
();
this
.
init
()
...
...
@@ -15,7 +15,8 @@ class GameScene extends egret.Sprite {
this
.
controller
=
new
Controller
()
this
.
addChild
(
this
.
controller
)
this
.
controller
.
addEventListener
(
"position_change"
,
this
.
onPositionChange
,
this
)
this
.
map
=
new
Map
()
this
.
addChild
(
this
.
map
)
this
.
addChild
(
this
.
me
)
}
...
...
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