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
28b0350e
authored
Jul 07, 2020
by
李楚霏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
调整
parent
798d5fc9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
68 deletions
+56
-68
rescureMen/assets/scene/test.fire
+22
-24
rescureMen/assets/script/hook.ts
+34
-44
No files found.
rescureMen/assets/scene/test.fire
View file @
28b0350e
...
@@ -2339,7 +2339,7 @@
...
@@ -2339,7 +2339,7 @@
},
},
"_enabled": true,
"_enabled": true,
"tag": 0,
"tag": 0,
"_density": 1
000
0,
"_density": 1
7
0,
"_sensor": false,
"_sensor": false,
"_friction": 1,
"_friction": 1,
"_restitution": 0.1,
"_restitution": 0.1,
...
@@ -2364,8 +2364,6 @@
...
@@ -2364,8 +2364,6 @@
"__id__": 40
"__id__": 40
},
},
"_enabled": true,
"_enabled": true,
"label": null,
"text": "hello",
"_id": "a7LuEyw79BAYxThj2PaotL"
"_id": "a7LuEyw79BAYxThj2PaotL"
},
},
{
{
...
@@ -2742,7 +2740,7 @@
...
@@ -2742,7 +2740,7 @@
},
},
"_enabled": true,
"_enabled": true,
"tag": 0,
"tag": 0,
"_density":
4
50,
"_density":
2
50,
"_sensor": false,
"_sensor": false,
"_friction": 0.2,
"_friction": 0.2,
"_restitution": 0,
"_restitution": 0,
...
@@ -2949,7 +2947,7 @@
...
@@ -2949,7 +2947,7 @@
},
},
"_enabled": true,
"_enabled": true,
"tag": 0,
"tag": 0,
"_density":
40
0,
"_density":
22
0,
"_sensor": false,
"_sensor": false,
"_friction": 0.2,
"_friction": 0.2,
"_restitution": 0,
"_restitution": 0,
...
@@ -3156,7 +3154,7 @@
...
@@ -3156,7 +3154,7 @@
},
},
"_enabled": true,
"_enabled": true,
"tag": 0,
"tag": 0,
"_density":
35
0,
"_density":
20
0,
"_sensor": false,
"_sensor": false,
"_friction": 0.2,
"_friction": 0.2,
"_restitution": 0,
"_restitution": 0,
...
@@ -3363,7 +3361,7 @@
...
@@ -3363,7 +3361,7 @@
},
},
"_enabled": true,
"_enabled": true,
"tag": 0,
"tag": 0,
"_density":
30
0,
"_density":
12
0,
"_sensor": false,
"_sensor": false,
"_friction": 0.2,
"_friction": 0.2,
"_restitution": 0,
"_restitution": 0,
...
@@ -3570,7 +3568,7 @@
...
@@ -3570,7 +3568,7 @@
},
},
"_enabled": true,
"_enabled": true,
"tag": 0,
"tag": 0,
"_density":
25
0,
"_density":
11
0,
"_sensor": false,
"_sensor": false,
"_friction": 0.2,
"_friction": 0.2,
"_restitution": 0,
"_restitution": 0,
...
@@ -3777,7 +3775,7 @@
...
@@ -3777,7 +3775,7 @@
},
},
"_enabled": true,
"_enabled": true,
"tag": 0,
"tag": 0,
"_density":
2
00,
"_density":
1
00,
"_sensor": false,
"_sensor": false,
"_friction": 0.2,
"_friction": 0.2,
"_restitution": 0,
"_restitution": 0,
...
@@ -3984,7 +3982,7 @@
...
@@ -3984,7 +3982,7 @@
},
},
"_enabled": true,
"_enabled": true,
"tag": 0,
"tag": 0,
"_density":
15
0,
"_density":
9
0,
"_sensor": false,
"_sensor": false,
"_friction": 0.2,
"_friction": 0.2,
"_restitution": 0,
"_restitution": 0,
...
@@ -4191,7 +4189,7 @@
...
@@ -4191,7 +4189,7 @@
},
},
"_enabled": true,
"_enabled": true,
"tag": 0,
"tag": 0,
"_density":
10
0,
"_density":
8
0,
"_sensor": false,
"_sensor": false,
"_friction": 0.2,
"_friction": 0.2,
"_restitution": 0,
"_restitution": 0,
...
@@ -4398,7 +4396,7 @@
...
@@ -4398,7 +4396,7 @@
},
},
"_enabled": true,
"_enabled": true,
"tag": 0,
"tag": 0,
"_density":
10
0,
"_density":
7
0,
"_sensor": false,
"_sensor": false,
"_friction": 0.2,
"_friction": 0.2,
"_restitution": 0,
"_restitution": 0,
...
@@ -4605,7 +4603,7 @@
...
@@ -4605,7 +4603,7 @@
},
},
"_enabled": true,
"_enabled": true,
"tag": 0,
"tag": 0,
"_density":
10
0,
"_density":
6
0,
"_sensor": false,
"_sensor": false,
"_friction": 0.2,
"_friction": 0.2,
"_restitution": 0,
"_restitution": 0,
...
@@ -4812,7 +4810,7 @@
...
@@ -4812,7 +4810,7 @@
},
},
"_enabled": true,
"_enabled": true,
"tag": 0,
"tag": 0,
"_density":
10
0,
"_density":
5
0,
"_sensor": false,
"_sensor": false,
"_friction": 0.2,
"_friction": 0.2,
"_restitution": 0,
"_restitution": 0,
...
@@ -5019,7 +5017,7 @@
...
@@ -5019,7 +5017,7 @@
},
},
"_enabled": true,
"_enabled": true,
"tag": 0,
"tag": 0,
"_density":
10
0,
"_density":
4
0,
"_sensor": false,
"_sensor": false,
"_friction": 0.2,
"_friction": 0.2,
"_restitution": 0,
"_restitution": 0,
...
@@ -5226,7 +5224,7 @@
...
@@ -5226,7 +5224,7 @@
},
},
"_enabled": true,
"_enabled": true,
"tag": 0,
"tag": 0,
"_density":
10
0,
"_density":
3
0,
"_sensor": false,
"_sensor": false,
"_friction": 0.2,
"_friction": 0.2,
"_restitution": 0,
"_restitution": 0,
...
@@ -5433,7 +5431,7 @@
...
@@ -5433,7 +5431,7 @@
},
},
"_enabled": true,
"_enabled": true,
"tag": 0,
"tag": 0,
"_density":
10
0,
"_density":
2
0,
"_sensor": false,
"_sensor": false,
"_friction": 0.2,
"_friction": 0.2,
"_restitution": 0,
"_restitution": 0,
...
@@ -5574,8 +5572,8 @@
...
@@ -5574,8 +5572,8 @@
"__type__": "TypedArray",
"__type__": "TypedArray",
"ctor": "Float64Array",
"ctor": "Float64Array",
"array": [
"array": [
188.
852
,
188.
143
,
-2
36.019
,
-2
17.587
,
0,
0,
0,
0,
0,
0,
...
@@ -5640,7 +5638,7 @@
...
@@ -5640,7 +5638,7 @@
},
},
"_enabled": true,
"_enabled": true,
"tag": 0,
"tag": 0,
"_density":
10
0,
"_density":
2
0,
"_sensor": false,
"_sensor": false,
"_friction": 0.2,
"_friction": 0.2,
"_restitution": 0,
"_restitution": 0,
...
@@ -5648,7 +5646,7 @@
...
@@ -5648,7 +5646,7 @@
"_offset": {
"_offset": {
"__type__": "cc.Vec2",
"__type__": "cc.Vec2",
"x": 0,
"x": 0,
"y":
-25
"y":
0
},
},
"_size": {
"_size": {
"__type__": "cc.Size",
"__type__": "cc.Size",
...
@@ -5789,8 +5787,8 @@
...
@@ -5789,8 +5787,8 @@
"__type__": "TypedArray",
"__type__": "TypedArray",
"ctor": "Float64Array",
"ctor": "Float64Array",
"array": [
"array": [
1
79.03
,
1
88.246
,
-
465.16
2,
-
366.62
2,
0,
0,
0,
0,
0,
0,
...
@@ -6105,7 +6103,7 @@
...
@@ -6105,7 +6103,7 @@
},
},
"_enabled": true,
"_enabled": true,
"tag": 0,
"tag": 0,
"_density":
2
,
"_density":
4
,
"_sensor": false,
"_sensor": false,
"_friction": 1,
"_friction": 1,
"_restitution": 0,
"_restitution": 0,
...
...
rescureMen/assets/script/hook.ts
View file @
28b0350e
...
@@ -10,39 +10,40 @@ const {ccclass, property} = cc._decorator;
...
@@ -10,39 +10,40 @@ const {ccclass, property} = cc._decorator;
@
ccclass
@
ccclass
export
default
class
NewClass
extends
cc
.
Component
{
export
default
class
NewClass
extends
cc
.
Component
{
@
property
(
cc
.
Label
)
label
:
cc
.
Label
=
null
;
@
property
text
:
string
=
'hello'
;
startPoint
:
any
;
startPoint
:
any
;
rigidBody
:
any
;
rigidBody
:
any
;
tween
:
any
;
tween
:
any
;
startCollision
:
boolean
=
false
;
points
:
any
=
[];
nodePos
:
cc
.
Vec2
;
dir
:
cc
.
Vec3
;
// LIFE-CYCLE CALLBACKS:
// LIFE-CYCLE CALLBACKS:
onPreSolve
(
contact
,
selfCollider
,
otherCollider
)
{
onPreSolve
(
contact
,
selfCollider
,
otherCollider
)
{
if
(
otherCollider
.
node
.
name
.
includes
(
'disk'
))
{
if
(
otherCollider
.
node
.
name
.
includes
(
'disk'
))
{
this
.
moveEnd
();
// this.moveEnd();
this
.
startCollision
=
true
;
this
.
scheduleOnce
(()
=>
{
this
.
scheduleOnce
(()
=>
{
console
.
error
(
'1'
);
this
.
rigidBody
.
type
=
cc
.
RigidBodyType
.
Dynamic
;
this
.
rigidBody
.
type
=
cc
.
RigidBodyType
.
Dynamic
;
otherCollider
.
node
.
getComponent
(
cc
.
RigidBody
).
type
=
cc
.
RigidBodyType
.
Kinematic
;
otherCollider
.
node
.
getComponent
(
cc
.
RigidBody
).
type
=
cc
.
RigidBodyType
.
Kinematic
;
const
joint
=
this
.
node
.
get
Component
(
cc
.
WeldJoint
);
let
joint
=
this
.
node
.
add
Component
(
cc
.
WeldJoint
);
joint
.
enabled
=
true
;
joint
.
connectedAnchor
=
cc
.
v2
(
-
51.8
,
0.4
)
;
joint
.
connectedBody
=
otherCollider
.
node
;
joint
.
connectedBody
=
otherCollider
.
node
.
getComponent
(
cc
.
RigidBody
)
;
}
)
}
,
0
);
// joint.anchor = cc.v2(-51.7, -1.1);
// joint.anchor = cc.v2(-51.7, -1.1);
}
}
}
}
onPostSolve
(
contact
,
selfCollider
,
otherCollider
)
{
onPostSolve
(
contact
,
selfCollider
,
otherCollider
)
{
this
.
scheduleOnc
e
(()
=>
{
// this.schedul
e(()=>{
this
.
rigidBody
.
type
=
cc
.
RigidBodyType
.
Kinematic
;
//
this.rigidBody.type = cc.RigidBodyType.Kinematic;
otherCollider
.
node
.
getComponent
(
cc
.
RigidBody
).
type
=
cc
.
RigidBodyType
.
Dynamic
;
//
otherCollider.node.getComponent(cc.RigidBody).type = cc.RigidBodyType.Dynamic;
})
// },0);
}
}
onLoad
()
{
onLoad
()
{
this
.
dir
=
cc
.
v3
(
this
.
node
.
position
.
x
,
this
.
node
.
position
.
y
,
0
);
this
.
rigidBody
=
this
.
node
.
getComponent
(
cc
.
RigidBody
);
this
.
rigidBody
=
this
.
node
.
getComponent
(
cc
.
RigidBody
);
this
.
rigidBody
.
type
=
cc
.
RigidBodyType
.
Kinematic
;
this
.
rigidBody
.
type
=
cc
.
RigidBodyType
.
Kinematic
;
this
.
initEvent
();
this
.
initEvent
();
...
@@ -56,25 +57,16 @@ export default class NewClass extends cc.Component {
...
@@ -56,25 +57,16 @@ export default class NewClass extends cc.Component {
}
}
_touchStartEvent
(
event
:
cc
.
Event
.
EventTouch
)
{
_touchStartEvent
(
event
:
cc
.
Event
.
EventTouch
)
{
this
.
startPoint
=
event
.
getPrevious
Location
();
// this.startPoint = event.getStart
Location();
}
}
_touchMoveEvent
(
event
:
cc
.
Event
.
EventTouch
)
{
_touchMoveEvent
(
event
:
cc
.
Event
.
EventTouch
)
{
// this.points.push(event.getLocation());
var
touches
=
event
.
getTouches
();
// if (this.points.length > 20) {
let
oldPos
=
this
.
node
.
parent
.
convertToNodeSpaceAR
(
touches
[
0
].
getStartLocation
());
// this.points.shift();
let
newPos
=
this
.
node
.
parent
.
convertToNodeSpaceAR
(
touches
[
0
].
getLocation
());
// }
// let subPos = oldPos.sub(newPos);
// const averagePoint = new cc.Vec2(0, 0);
// let dir = cc.v3(this.nodePos.x - subPos.x, this.nodePos.y - subPos.y, 0);
// this.points.forEach((point) => {
this
.
dir
=
cc
.
v3
(
newPos
.
x
,
newPos
.
y
,
0
);
// averagePoint.x += point.x;
// this.move(dir);
// 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);
this
.
move
(
dir
);
}
}
_touchEndEvent
(
event
:
cc
.
Event
.
EventTouch
)
{
_touchEndEvent
(
event
:
cc
.
Event
.
EventTouch
)
{
...
@@ -88,25 +80,23 @@ export default class NewClass extends cc.Component {
...
@@ -88,25 +80,23 @@ export default class NewClass extends cc.Component {
}
}
move
(
dir
)
{
move
(
dir
)
{
// this.node.position = dir;
this
.
tween
=
cc
.
tween
(
this
.
node
)
.
to
(
0.7
,
{
position
:
dir
})
.
start
()
// this.rigidBody.awake = true;
// cc.director.getPhysicsManager().enabled = false;
}
}
moveEnd
()
{
moveEnd
()
{
if
(
this
.
tween
)
{
this
.
tween
.
stop
();
}
// cc.director.getPhysicsManager().enabled = true;
}
}
start
()
{
start
()
{
}
}
// update (dt) {
update
(
dt
)
{
// }
const
oldPos
=
cc
.
v3
(
this
.
node
.
position
.
x
,
this
.
node
.
position
.
y
,
0
);
let
targetPos
=
this
.
dir
.
clone
();
let
subPos
=
targetPos
.
sub
(
oldPos
);
let
distance
=
subPos
.
mag
();
if
(
distance
>
100
)
{
targetPos
=
oldPos
.
clone
().
add
(
targetPos
.
sub
(
oldPos
.
clone
()).
normalizeSelf
().
mul
(
100
));
}
this
.
node
.
position
=
this
.
node
.
position
.
clone
().
lerp
(
targetPos
,
4
*
dt
);
}
}
}
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