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
166ff661
authored
4 years ago
by
李楚霏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
调整
parent
28b0350e
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
10 additions
and
24 deletions
+10
-24
rescureMen/assets/scene/test.fire
+0
-0
rescureMen/assets/script/gear.ts
+9
-22
rescureMen/assets/script/hook.ts
+0
-1
rescureMen/assets/script/rope.ts
+1
-1
No files found.
rescureMen/assets/scene/test.fire
View file @
166ff661
This diff is collapsed.
Click to expand it.
rescureMen/assets/script/gear.ts
View file @
166ff661
...
@@ -18,23 +18,18 @@ export default class NewClass extends cc.Component {
...
@@ -18,23 +18,18 @@ export default class NewClass extends cc.Component {
collider
:
cc
.
PhysicsPolygonCollider
;
collider
:
cc
.
PhysicsPolygonCollider
;
startPoint
:
cc
.
Vec2
;
startPoint
:
cc
.
Vec2
;
tween
:
any
;
tween
:
any
;
points
:
cc
.
Vec2
;
// LIFE-CYCLE CALLBACKS:
// LIFE-CYCLE CALLBACKS:
onPreSolve
(
contact
,
selfCollider
,
otherCollider
)
{
onPreSolve
(
contact
,
selfCollider
,
otherCollider
)
{
// console.error(otherCollider.node.name);
// console.error(contact);
// if (otherCollider && otherCollider.node.getComponent(cc.MotorJoint)) {
const
worldManifold
=
contact
.
getWorldManifold
();
// // this.rigidBody.awake = false;
this
.
points
=
worldManifold
.
normal
;
// console.error(selfCollider.name);
// otherCollider.node.addComponent(cc.MotorJoint);
// const motor = otherCollider.node.getComponent(cc.MotorJoint);
// motor.connectedBody = this.node;
// motor.maxTorque = -200;
// }
// const motorJoint =this.node.getComponent(cc.MotorJoint);
// motorJoint.connectedBody = otherCollider.node;
// console.error(motorJoint.connectedBody.name);
if
(
otherCollider
.
node
.
name
.
includes
(
'staticGear'
))
{
if
(
otherCollider
.
node
.
name
.
includes
(
'staticGear'
))
{
this
.
rigidBody
.
angularVelocity
=
-
otherCollider
.
node
.
getComponent
(
cc
.
RigidBody
).
angularVelocity
;
this
.
scheduleOnce
(()
=>
{
this
.
node
.
position
=
cc
.
v3
(
this
.
points
.
x
,
this
.
points
.
y
,
0
);
this
.
rigidBody
.
angularVelocity
=
-
otherCollider
.
node
.
getComponent
(
cc
.
RigidBody
).
angularVelocity
;
},
0
);
}
}
}
}
...
@@ -48,8 +43,6 @@ export default class NewClass extends cc.Component {
...
@@ -48,8 +43,6 @@ export default class NewClass extends cc.Component {
}
}
onEnable
()
{
onEnable
()
{
clientEvent
.
on
(
'move'
,
this
.
move
,
this
);
clientEvent
.
on
(
'moveEnd'
,
this
.
moveEnd
,
this
);
}
}
initEvent
()
{
initEvent
()
{
...
@@ -92,17 +85,11 @@ export default class NewClass extends cc.Component {
...
@@ -92,17 +85,11 @@ export default class NewClass extends cc.Component {
}
}
move
(
dir
)
{
move
(
dir
)
{
console
.
error
(
'move'
);
this
.
node
.
position
=
dir
;
this
.
tween
=
cc
.
tween
(
this
.
node
)
.
to
(
1
,
{
position
:
dir
})
.
start
()
// this.node.position = dir;
// this.rigidBody.awake = true;
// this.rigidBody.awake = true;
cc
.
director
.
getPhysicsManager
().
enabled
=
false
;
cc
.
director
.
getPhysicsManager
().
enabled
=
false
;
}
}
moveEnd
()
{
moveEnd
()
{
console
.
error
(
'moveEnd'
);
this
.
tween
.
stop
();
cc
.
director
.
getPhysicsManager
().
enabled
=
true
;
cc
.
director
.
getPhysicsManager
().
enabled
=
true
;
}
}
...
...
This diff is collapsed.
Click to expand it.
rescureMen/assets/script/hook.ts
View file @
166ff661
...
@@ -61,7 +61,6 @@ export default class NewClass extends cc.Component {
...
@@ -61,7 +61,6 @@ export default class NewClass extends cc.Component {
}
}
_touchMoveEvent
(
event
:
cc
.
Event
.
EventTouch
)
{
_touchMoveEvent
(
event
:
cc
.
Event
.
EventTouch
)
{
var
touches
=
event
.
getTouches
();
var
touches
=
event
.
getTouches
();
let
oldPos
=
this
.
node
.
parent
.
convertToNodeSpaceAR
(
touches
[
0
].
getStartLocation
());
let
newPos
=
this
.
node
.
parent
.
convertToNodeSpaceAR
(
touches
[
0
].
getLocation
());
let
newPos
=
this
.
node
.
parent
.
convertToNodeSpaceAR
(
touches
[
0
].
getLocation
());
// let subPos = oldPos.sub(newPos);
// let subPos = oldPos.sub(newPos);
// let dir = cc.v3(this.nodePos.x - subPos.x, this.nodePos.y - subPos.y, 0);
// let dir = cc.v3(this.nodePos.x - subPos.x, this.nodePos.y - subPos.y, 0);
...
...
This diff is collapsed.
Click to expand it.
rescureMen/assets/script/rope.ts
View file @
166ff661
...
@@ -32,7 +32,7 @@ export default class NewClass extends cc.Component {
...
@@ -32,7 +32,7 @@ export default class NewClass extends cc.Component {
// const motorJoint =this.node.getComponent(cc.MotorJoint);
// const motorJoint =this.node.getComponent(cc.MotorJoint);
// motorJoint.connectedBody = otherCollider.node;
// motorJoint.connectedBody = otherCollider.node;
// console.error(motorJoint.connectedBody.name);
// console.error(motorJoint.connectedBody.name);
this
.
rigidBody
.
linearVelocity
=
cc
.
v2
(
0
,
otherCollider
.
node
.
getComponent
(
cc
.
RigidBody
).
angularVelocity
*
3
);
this
.
rigidBody
.
linearVelocity
=
cc
.
v2
(
0
,
-
otherCollider
.
node
.
getComponent
(
cc
.
RigidBody
).
angularVelocity
*
3
);
}
}
onPostSolve
(
contact
,
selfCollider
,
otherCollider
)
{
onPostSolve
(
contact
,
selfCollider
,
otherCollider
)
{
this
.
rigidBody
.
linearVelocity
=
cc
.
v2
(
0
,
0
);
this
.
rigidBody
.
linearVelocity
=
cc
.
v2
(
0
,
0
);
...
...
This diff is collapsed.
Click to expand it.
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