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
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
82 additions
and
55 deletions
+82
-55
control.jpg
fe/resource/assets/control.jpg
+0
-0
default.res.json
fe/resource/default.res.json
+23
-15
Controller.ts
fe/src/Controller.ts
+59
-40
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"
:[
"groups"
:
[
{
{
"keys"
:
"bg_jpg,egret_icon_png,description_json"
,
"keys"
:
"bg_jpg,egret_icon_png,description_json,control_jpg"
,
"name"
:
"preload"
"name"
:
"preload"
}],
}
"resources"
:[
],
"resources"
:
[
{
{
"name"
:
"bg_jpg"
,
"name"
:
"bg_jpg"
,
"type"
:
"image"
,
"type"
:
"image"
,
"url"
:
"assets/bg.jpg"
"url"
:
"assets/bg.jpg"
},
},
{
{
"name"
:
"egret_icon_png"
,
"name"
:
"egret_icon_png"
,
"type"
:
"image"
,
"type"
:
"image"
,
"url"
:
"assets/egret_icon.png"
"url"
:
"assets/egret_icon.png"
},
},
{
{
"name"
:
"description_json"
,
"name"
:
"description_json"
,
"type"
:
"json"
,
"type"
:
"json"
,
"url"
:
"config/description.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 {
...
@@ -4,59 +4,78 @@ class Controller extends egret.Sprite {
this
.
init
()
this
.
init
()
}
}
private
speed
=
10
private
control
=
new
egret
.
Bitmap
()
private
speedX
=
0
private
panel
=
new
egret
.
Shape
()
private
speedY
=
0
private
pointtt
=
new
egret
.
Shape
()
private
p1
:
egret
.
Point
=
new
egret
.
Point
();
private
p2
:
egret
.
Point
=
new
egret
.
Point
();
private
up
=
new
egret
.
Shape
()
private
control
=
new
egret
.
Shape
();
private
down
=
new
egret
.
Shape
()
private
pointtt
=
new
egret
.
Shape
();
private
left
=
new
egret
.
Shape
()
private
controlCenter
=
new
egret
.
Point
(
1100
,
450
)
private
right
=
new
egret
.
Shape
(
)
// 初始化(给开始按钮绑定点击事件)
// 初始化(给开始按钮绑定点击事件)
private
init
()
{
private
init
()
{
this
.
control
.
graphics
.
beginFill
(
0xFF3866
,
1
);
this
.
control
.
graphics
.
drawCircle
(
1100
,
450
,
90
);
this
.
panel
.
graphics
.
beginFill
(
0x353E5D
,
1
)
this
.
control
.
graphics
.
endFill
();
this
.
panel
.
graphics
.
drawRect
(
1008
,
0
,
326
,
750
)
this
.
addChild
(
this
.
control
);
this
.
panel
.
graphics
.
endFill
()
this
.
addChild
(
this
.
panel
)
this
.
pointtt
.
graphics
.
beginFill
(
0xFF0000
,
1
)
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
.
pointtt
.
graphics
.
endFill
()
this
.
addChild
(
this
.
pointtt
)
this
.
addChild
(
this
.
pointtt
)
this
.
touchEnabled
=
true
let
texture
:
egret
.
Texture
=
RES
.
getRes
(
"control_jpg"
)
this
.
addEventListener
(
egret
.
TouchEvent
.
TOUCH_BEGIN
,
this
.
controlTouchBegin
,
this
)
this
.
control
.
texture
=
texture
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
)
}
private
onEnterFrame
(
e
:
egret
.
Event
){
let
controlContainer
=
new
egret
.
Sprite
()
if
(
this
.
touchEnd
){
this
.
addChild
(
controlContainer
)
return
controlContainer
.
x
=
1040
}
controlContainer
.
y
=
450
this
.
pointtt
.
x
+=
this
.
speedX
controlContainer
.
addChild
(
this
.
control
)
this
.
pointtt
.
y
+=
this
.
speedY
}
private
touchEnd
=
false
this
.
up
.
graphics
.
beginFill
(
0xFF00FF
,
1
)
private
controlTouchBegin
(
e
:
egret
.
TouchEvent
){
this
.
up
.
graphics
.
drawRect
(
93
,
0
,
80
,
80
)
this
.
touchEnd
=
false
this
.
up
.
graphics
.
endFill
()
}
this
.
up
.
touchEnabled
=
true
this
.
up
.
addEventListener
(
egret
.
TouchEvent
.
TOUCH_BEGIN
,
this
.
controlTouchBegin
,
this
)
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
)
private
controlTouchMove
(
e
:
egret
.
TouchEvent
){
this
.
right
.
graphics
.
beginFill
(
0xFF00FF
,
1
)
var
angle
=
Math
.
atan2
(
e
.
stageY
-
this
.
controlCenter
.
y
,
e
.
stageX
-
this
.
controlCenter
.
x
)
this
.
right
.
graphics
.
drawRect
(
186
,
93
,
80
,
80
)
// console.error(e)
this
.
right
.
graphics
.
endFill
()
this
.
speedX
=
Math
.
cos
(
angle
)
*
this
.
speed
;
this
.
right
.
touchEnabled
=
true
this
.
speedY
=
Math
.
sin
(
angle
)
*
this
.
speed
;
this
.
right
.
addEventListener
(
egret
.
TouchEvent
.
TOUCH_BEGIN
,
this
.
controlTouchBegin
,
this
)
// 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
){
private
delta
=
72
this
.
touchEnd
=
true
private
controlTouchBegin
(
e
:
egret
.
TouchEvent
){
// this.removeEventListener(egret.Event.ENTER_FRAME, this.onEnterFrame, this);
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
()
{
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