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
ed387b38
Commit
ed387b38
authored
May 05, 2018
by
Shawn Wang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
control update
parent
c7c4ac86
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
89 additions
and
62 deletions
+89
-62
control.jpg
fe/resource/assets/control.jpg
+0
-0
default.res.json
fe/resource/default.res.json
+29
-21
Controller.ts
fe/src/Controller.ts
+60
-41
No files found.
fe/resource/assets/control.jpg
0 → 100644
View file @
ed387b38
22.9 KB
fe/resource/default.res.json
View file @
ed387b38
{
"groups"
:[
{
"keys"
:
"bg_jpg,egret_icon_png,description_json"
,
"name"
:
"preload"
}],
"resources"
:[
{
"name"
:
"bg_jpg"
,
"type"
:
"image"
,
"url"
:
"assets/bg.jpg"
},
{
"name"
:
"egret_icon_png"
,
"type"
:
"image"
,
"url"
:
"assets/egret_icon.png"
},
{
"name"
:
"description_json"
,
"type"
:
"json"
,
"url"
:
"config/description.json"
}]
"groups"
:
[
{
"keys"
:
"bg_jpg,egret_icon_png,description_json,control_jpg"
,
"name"
:
"preload"
}
],
"resources"
:
[
{
"name"
:
"bg_jpg"
,
"type"
:
"image"
,
"url"
:
"assets/bg.jpg"
},
{
"name"
:
"egret_icon_png"
,
"type"
:
"image"
,
"url"
:
"assets/egret_icon.png"
},
{
"name"
:
"description_json"
,
"type"
:
"json"
,
"url"
:
"config/description.json"
},
{
"name"
:
"control_jpg"
,
"type"
:
"image"
,
"url"
:
"assets/control.jpg"
}
]
}
\ No newline at end of file
fe/src/Controller.ts
View file @
ed387b38
...
...
@@ -4,59 +4,78 @@ class Controller extends egret.Sprite {
this
.
init
()
}
private
speed
=
10
private
speedX
=
0
private
speedY
=
0
private
p1
:
egret
.
Point
=
new
egret
.
Point
();
private
p2
:
egret
.
Point
=
new
egret
.
Point
();
private
control
=
new
egret
.
Shape
();
private
pointtt
=
new
egret
.
Shape
();
private
controlCenter
=
new
egret
.
Point
(
1100
,
450
)
private
control
=
new
egret
.
Bitmap
()
private
panel
=
new
egret
.
Shape
()
private
pointtt
=
new
egret
.
Shape
()
// 初始化(给开始按钮绑定点击事件)
private
up
=
new
egret
.
Shape
()
private
down
=
new
egret
.
Shape
()
private
left
=
new
egret
.
Shape
()
private
right
=
new
egret
.
Shape
()
// 初始化(给开始按钮绑定点击事件)
private
init
()
{
this
.
control
.
graphics
.
beginFill
(
0xFF3866
,
1
);
this
.
control
.
graphics
.
drawCircle
(
1100
,
450
,
90
);
this
.
control
.
graphics
.
endFill
();
this
.
addChild
(
this
.
control
);
this
.
panel
.
graphics
.
beginFill
(
0x353E5D
,
1
)
this
.
panel
.
graphics
.
drawRect
(
1008
,
0
,
326
,
750
)
this
.
panel
.
graphics
.
endFill
()
this
.
addChild
(
this
.
panel
)
this
.
pointtt
.
graphics
.
beginFill
(
0xFF0000
,
1
)
this
.
pointtt
.
graphics
.
drawCircle
(
1100
,
450
,
10
)
this
.
pointtt
.
graphics
.
drawCircle
(
667
,
375
,
15
)
this
.
pointtt
.
graphics
.
endFill
()
this
.
addChild
(
this
.
pointtt
)
let
texture
:
egret
.
Texture
=
RES
.
getRes
(
"control_jpg"
)
this
.
control
.
texture
=
texture
this
.
touchEnabled
=
true
this
.
addEventListener
(
egret
.
TouchEvent
.
TOUCH_BEGIN
,
this
.
controlTouchBegin
,
this
)
this
.
addEventListener
(
egret
.
TouchEvent
.
TOUCH_MOVE
,
this
.
controlTouchMove
,
this
)
this
.
addEventListener
(
egret
.
TouchEvent
.
TOUCH_END
,
this
.
controlTouchEnd
,
this
)
this
.
addEventListener
(
egret
.
Event
.
ENTER_FRAME
,
this
.
onEnterFrame
,
this
)
}
let
controlContainer
=
new
egret
.
Sprite
()
this
.
addChild
(
controlContainer
)
controlContainer
.
x
=
1040
controlContainer
.
y
=
450
controlContainer
.
addChild
(
this
.
control
)
private
onEnterFrame
(
e
:
egret
.
Event
){
if
(
this
.
touchEnd
){
return
}
this
.
pointtt
.
x
+=
this
.
speedX
this
.
pointtt
.
y
+=
this
.
speedY
}
this
.
up
.
graphics
.
beginFill
(
0xFF00FF
,
1
)
this
.
up
.
graphics
.
drawRect
(
93
,
0
,
80
,
80
)
this
.
up
.
graphics
.
endFill
()
this
.
up
.
touchEnabled
=
true
this
.
up
.
addEventListener
(
egret
.
TouchEvent
.
TOUCH_BEGIN
,
this
.
controlTouchBegin
,
this
)
private
touchEnd
=
false
private
controlTouchBegin
(
e
:
egret
.
TouchEvent
){
this
.
touchEnd
=
false
}
this
.
down
.
graphics
.
beginFill
(
0xFF00FF
,
1
)
this
.
down
.
graphics
.
drawRect
(
93
,
186
,
80
,
80
)
this
.
down
.
graphics
.
endFill
()
this
.
down
.
touchEnabled
=
true
this
.
down
.
addEventListener
(
egret
.
TouchEvent
.
TOUCH_BEGIN
,
this
.
controlTouchBegin
,
this
)
this
.
left
.
graphics
.
beginFill
(
0xFF00FF
,
1
)
this
.
left
.
graphics
.
drawRect
(
0
,
93
,
80
,
80
)
this
.
left
.
graphics
.
endFill
()
this
.
left
.
touchEnabled
=
true
this
.
left
.
addEventListener
(
egret
.
TouchEvent
.
TOUCH_BEGIN
,
this
.
controlTouchBegin
,
this
)
this
.
right
.
graphics
.
beginFill
(
0xFF00FF
,
1
)
this
.
right
.
graphics
.
drawRect
(
186
,
93
,
80
,
80
)
this
.
right
.
graphics
.
endFill
()
this
.
right
.
touchEnabled
=
true
this
.
right
.
addEventListener
(
egret
.
TouchEvent
.
TOUCH_BEGIN
,
this
.
controlTouchBegin
,
this
)
private
controlTouchMove
(
e
:
egret
.
TouchEvent
){
var
angle
=
Math
.
atan2
(
e
.
stageY
-
this
.
controlCenter
.
y
,
e
.
stageX
-
this
.
controlCenter
.
x
)
// console.error(e)
this
.
speedX
=
Math
.
cos
(
angle
)
*
this
.
speed
;
this
.
speedY
=
Math
.
sin
(
angle
)
*
this
.
speed
;
// console.error(this.speedX)
// console.error(e.stageX)
controlContainer
.
addChild
(
this
.
up
)
controlContainer
.
addChild
(
this
.
down
)
controlContainer
.
addChild
(
this
.
left
)
controlContainer
.
addChild
(
this
.
right
)
}
private
controlTouchEnd
(
e
:
egret
.
TouchEvent
){
this
.
touchEnd
=
true
// this.removeEventListener(egret.Event.ENTER_FRAME, this.onEnterFrame, this);
private
delta
=
72
private
controlTouchBegin
(
e
:
egret
.
TouchEvent
){
if
(
e
.
currentTarget
===
this
.
up
){
this
.
pointtt
.
y
+=
this
.
delta
}
else
if
(
e
.
currentTarget
===
this
.
down
){
this
.
pointtt
.
y
-=
this
.
delta
}
else
if
(
e
.
currentTarget
===
this
.
left
){
this
.
pointtt
.
x
-=
this
.
delta
}
else
if
(
e
.
currentTarget
===
this
.
right
){
this
.
pointtt
.
x
+=
this
.
delta
}
}
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