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
4af542f5
Commit
4af542f5
authored
May 05, 2018
by
Mike Zhu
Browse files
Options
Browse Files
Download
Plain Diff
fix conflict in Stores
parents
81da815d
ee5f3c96
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
143 additions
and
13 deletions
+143
-13
Guy.ts
fe/src/Guy.ts
+43
-0
Map.ts
fe/src/Map.ts
+43
-0
MapGrid.ts
fe/src/MapGrid.ts
+31
-0
Store.ts
fe/src/Store.ts
+19
-3
GameScene.ts
fe/src/scenes/GameScene.ts
+7
-10
No files found.
fe/src/Guy.ts
0 → 100644
View file @
4af542f5
class
Guy
extends
egret
.
Sprite
{
public
constructor
()
{
super
()
this
.
init
()
}
private
avatar
=
new
egret
.
Bitmap
()
private
imageLoader
=
new
egret
.
ImageLoader
()
private
init
()
{
this
.
avatar
.
width
=
72
this
.
avatar
.
height
=
72
this
.
imageLoader
.
addEventListener
(
egret
.
Event
.
COMPLETE
,
this
.
loadCompleteHandler
,
this
)
this
.
imageLoader
.
load
(
"http://www.insajderi.com/wp-content/uploads/2018/01/asdja.jpg"
)
this
.
addChild
(
this
.
avatar
)
}
private
loadCompleteHandler
()
{
let
texture
=
new
egret
.
Texture
()
texture
.
_setBitmapData
(
this
.
imageLoader
.
data
)
this
.
avatar
.
texture
=
texture
}
private
step
=
72
public
applyDelta
(
delta
){
this
.
x
+=
this
.
step
*
delta
.
x
this
.
y
+=
this
.
step
*
delta
.
y
if
(
this
.
x
<=
0
){
this
.
x
=
0
}
if
(
this
.
y
<=
0
){
this
.
y
=
0
}
if
(
this
.
y
>=
72
*
9
){
this
.
y
=
72
*
9
}
if
(
this
.
x
>=
72
*
13
){
this
.
x
=
72
*
13
}
}
}
\ No newline at end of file
fe/src/Map.ts
0 → 100644
View file @
4af542f5
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 @
4af542f5
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 @
4af542f5
let
_state
:
any
=
{}
let
_state
:
any
=
{
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
;
case
'setUserInfo'
:
...
...
@@ -18,4 +28,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 @
4af542f5
class
GameScene
extends
egret
.
Sprite
{
private
controller
:
egret
.
Sprite
public
map
public
constructor
()
{
super
();
this
.
init
()
}
private
pointtt
=
new
egret
.
Shape
()
private
me
=
new
Guy
()
// 初始化(给开始按钮绑定点击事件)
private
init
()
{
...
...
@@ -15,17 +15,14 @@ class GameScene extends egret.Sprite {
this
.
controller
=
new
Controller
()
this
.
addChild
(
this
.
controller
)
this
.
controller
.
addEventListener
(
"position_change"
,
this
.
onPositionChange
,
this
)
this
.
pointtt
.
graphics
.
beginFill
(
0xFF0000
,
1
)
this
.
pointtt
.
graphics
.
drawCircle
(
667
,
375
,
15
)
this
.
pointtt
.
graphics
.
endFill
()
this
.
addChild
(
this
.
pointtt
)
this
.
map
=
new
Map
()
this
.
addChild
(
this
.
map
)
this
.
addChild
(
this
.
me
)
}
private
step
=
72
private
onPositionChange
(
delta
){
this
.
pointtt
.
x
+=
this
.
step
*
delta
.
data
.
x
this
.
pointtt
.
y
+=
this
.
step
*
delta
.
data
.
y
this
.
me
.
applyDelta
(
delta
.
data
)
}
public
release
()
{
...
...
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