Commit 70b92bde by 李楚霏

研究马达关节

parent 860742c6
...@@ -84,13 +84,13 @@ ...@@ -84,13 +84,13 @@
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 15 "__id__": 17
}, },
{ {
"__id__": 16 "__id__": 18
}, },
{ {
"__id__": 17 "__id__": 19
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -180,7 +180,7 @@ ...@@ -180,7 +180,7 @@
"array": [ "array": [
0, 0,
0, 0,
572.4427919015139, 371.6221153255573,
0, 0,
0, 0,
0, 0,
...@@ -351,6 +351,12 @@ ...@@ -351,6 +351,12 @@
}, },
{ {
"__id__": 10 "__id__": 10
},
{
"__id__": 15
},
{
"__id__": 16
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -441,7 +447,7 @@ ...@@ -441,7 +447,7 @@
"__id__": 7 "__id__": 7
}, },
"_enabled": true, "_enabled": true,
"_type": 2, "_type": 1,
"_allowSleep": true, "_allowSleep": true,
"_gravityScale": 1, "_gravityScale": 1,
"_linearDamping": 0, "_linearDamping": 0,
...@@ -468,12 +474,12 @@ ...@@ -468,12 +474,12 @@
"_enabled": true, "_enabled": true,
"anchor": { "anchor": {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",
"x": 29, "x": 1,
"y": -39 "y": -31
}, },
"connectedAnchor": { "connectedAnchor": {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",
"x": 3, "x": 38,
"y": 0 "y": 0
}, },
"connectedBody": { "connectedBody": {
...@@ -482,12 +488,12 @@ ...@@ -482,12 +488,12 @@
"collideConnected": false, "collideConnected": false,
"_linearOffset": { "_linearOffset": {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",
"x": 0, "x": 30,
"y": 0 "y": 0
}, },
"_angularOffset": 0, "_angularOffset": 0,
"_maxForce": 1, "_maxForce": 10,
"_maxTorque": 1, "_maxTorque": 200,
"_correctionFactor": 0.3, "_correctionFactor": 0.3,
"_id": "40EQRA9TRE+rFRdgMnGLW8" "_id": "40EQRA9TRE+rFRdgMnGLW8"
}, },
...@@ -499,7 +505,7 @@ ...@@ -499,7 +505,7 @@
"__id__": 12 "__id__": 12
}, },
"_enabled": true, "_enabled": true,
"_type": 2, "_type": 1,
"_allowSleep": true, "_allowSleep": true,
"_gravityScale": 1, "_gravityScale": 1,
"_linearDamping": 0, "_linearDamping": 0,
...@@ -518,7 +524,7 @@ ...@@ -518,7 +524,7 @@
}, },
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
"_name": "gear", "_name": "gear1",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 2 "__id__": 2
...@@ -559,8 +565,8 @@ ...@@ -559,8 +565,8 @@
"__type__": "TypedArray", "__type__": "TypedArray",
"ctor": "Float64Array", "ctor": "Float64Array",
"array": [ "array": [
-59.201, -207.592,
29.6, -92.126,
0, 0,
0, 0,
0, 0,
...@@ -617,37 +623,69 @@ ...@@ -617,37 +623,69 @@
"_id": "d899sMlPZKyrzwmjLmpXSy" "_id": "d899sMlPZKyrzwmjLmpXSy"
}, },
{ {
"__type__": "cc.MotorJoint", "__type__": "cc.PhysicsBoxCollider",
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 12 "__id__": 12
}, },
"_enabled": true, "_enabled": true,
"anchor": { "tag": 0,
"__type__": "cc.Vec2", "_density": 1,
"x": -30, "_sensor": false,
"y": -24 "_friction": 0.2,
}, "_restitution": 0,
"connectedAnchor": { "body": null,
"_offset": {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",
"x": 0, "x": 0,
"y": 0 "y": 0
}, },
"connectedBody": { "_size": {
"__id__": 9 "__type__": "cc.Size",
"width": 30,
"height": 30
}, },
"collideConnected": false, "_id": "b1GoUkKj5DJZ6aJKJtsrcU"
"_linearOffset": { },
{
"__type__": "cc.PhysicsBoxCollider",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 7
},
"_enabled": true,
"tag": 0,
"_density": 1,
"_sensor": false,
"_friction": 0.2,
"_restitution": 0,
"body": null,
"_offset": {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",
"x": 0, "x": 0.6,
"y": 0 "y": 0
}, },
"_angularOffset": 0, "_size": {
"_maxForce": 1, "__type__": "cc.Size",
"_maxTorque": 1, "width": 30,
"_correctionFactor": 0.3, "height": 30
"_id": "78Y9S/FiZMZr80gpkUwDx0" },
"_id": "5fqfCs7LBL+IbOXJB113Tk"
},
{
"__type__": "f8d7b/0hj9IhpmWwu6imtTe",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 7
},
"_enabled": true,
"label": null,
"target": null,
"text": "hello",
"_id": "d5YHYCIbNEwI7HelCAj6Oc"
}, },
{ {
"__type__": "cc.Canvas", "__type__": "cc.Canvas",
......
// 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 {
@property(cc.Label)
label: cc.Label = null;
@property
target: cc.Node = null;
@property
text: string = 'hello';
rigidBody: cc.RigidBody;
motor: cc.MotorJoint;
// LIFE-CYCLE CALLBACKS:
onLoad () {
this.rigidBody = this.node.getComponent(cc.RigidBody);
this.motor = this.node.getComponent(cc.MotorJoint);
this.motor.connectedBody
}
start () {
}
update (dt) {
// this.rigidBody.angularVelocity = 200;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment