Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
李楚霏
/
RescureMenDemo
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
2f6ddd04
authored
Jul 05, 2020
by
李楚霏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
调整
parent
554fcf01
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
23 deletions
+49
-23
rescureMen/assets/scene/test.fire
+0
-0
rescureMen/assets/script/gear.ts
+2
-9
rescureMen/assets/script/joyStick.ts
+14
-14
rescureMen/assets/script/staticGear.ts
+33
-0
No files found.
rescureMen/assets/scene/test.fire
View file @
2f6ddd04
This diff is collapsed.
Click to expand it.
rescureMen/assets/script/gear.ts
View file @
2f6ddd04
...
...
@@ -8,29 +8,22 @@
import
clientEvent
from
"./clientEvent"
;
const
{
ccclass
,
property
}
=
cc
.
_decorator
;
@
ccclass
export
default
class
NewClass
extends
cc
.
Component
{
@
property
(
cc
.
Label
)
label
:
cc
.
Label
=
null
;
@
property
(
cc
.
Node
)
target
:
cc
.
Node
=
null
;
@
property
text
:
string
=
'hello'
;
rigidBody
:
cc
.
RigidBody
;
motor
:
cc
.
MotorJoint
;
collider
:
cc
.
Circle
Collider
;
collider
:
cc
.
PhysicsPolygon
Collider
;
// LIFE-CYCLE CALLBACKS:
onLoad
()
{
this
.
rigidBody
=
this
.
node
.
getComponent
(
cc
.
RigidBody
);
this
.
motor
=
this
.
node
.
getComponent
(
cc
.
MotorJoint
);
// this.motor.connectedBody
this
.
collider
=
this
.
node
.
getComponent
(
cc
.
Circle
Collider
);
this
.
collider
=
this
.
node
.
getComponent
(
cc
.
PhysicsPolygon
Collider
);
const
collisionManager
=
cc
.
director
.
getCollisionManager
();
collisionManager
.
enabled
=
true
;
}
...
...
rescureMen/assets/script/joyStick.ts
View file @
2f6ddd04
...
...
@@ -35,20 +35,20 @@ export default class NewClass extends cc.Component {
this
.
startPoint
=
event
.
getStartLocation
();
}
_touchMoveEvent
(
event
:
cc
.
Event
.
EventTouch
)
{
this
.
points
.
push
(
event
.
getLocation
());
if
(
this
.
points
.
length
>
20
)
{
this
.
points
.
shift
();
}
const
averagePoint
=
new
cc
.
Vec2
(
0
,
0
);
this
.
points
.
forEach
((
point
)
=>
{
averagePoint
.
x
+=
point
.
x
;
averagePoint
.
y
+=
point
.
y
;
})
averagePoint
.
multiplyScalar
(
1
/
this
.
points
.
length
);
const
delta
=
new
cc
.
Vec2
(
event
.
getLocation
().
x
-
averagePoint
.
x
,
event
.
getLocation
().
y
-
averagePoint
.
y
);
let
dir
=
delta
;
// let dir = event.getLocation(
);
//
this.points.push(event.getLocation());
//
if (this.points.length > 20) {
//
this.points.shift();
//
}
//
const averagePoint = new cc.Vec2(0, 0);
//
this.points.forEach((point) => {
//
averagePoint.x += point.x;
//
averagePoint.y += point.y;
//
})
//
averagePoint.multiplyScalar(1 / this.points.length);
//
const delta = new cc.Vec2(event.getLocation().x - averagePoint.x, event.getLocation().y - averagePoint.y);
//
let dir = delta;
let
dir
=
cc
.
v2
(
event
.
getLocation
().
x
-
this
.
startPoint
.
x
,
event
.
getLocation
().
y
-
this
.
startPoint
.
y
);
clientEvent
.
dispatchEvent
(
'move'
,
dir
);
}
_touchEndEvent
(
event
:
cc
.
Event
.
EventTouch
)
{
...
...
rescureMen/assets/script/staticGear.ts
0 → 100644
View file @
2f6ddd04
// Learn TypeScript:
// - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
const
{
ccclass
,
property
}
=
cc
.
_decorator
;
@
ccclass
export
default
class
NewClass
extends
cc
.
Component
{
rigidBody
:
cc
.
RigidBody
;
collider
:
cc
.
PhysicsPolygonCollider
;
// LIFE-CYCLE CALLBACKS:
onLoad
()
{
this
.
rigidBody
=
this
.
node
.
getComponent
(
cc
.
RigidBody
);
// this.motor.connectedBody
this
.
collider
=
this
.
node
.
getComponent
(
cc
.
PhysicsPolygonCollider
);
const
collisionManager
=
cc
.
director
.
getCollisionManager
();
collisionManager
.
enabled
=
true
;
}
start
()
{
}
update
(
dt
)
{
this
.
rigidBody
.
angularVelocity
=
200
;
}
}
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