Commit 70b92bde by 李楚霏

研究马达关节

parent 860742c6
......@@ -84,13 +84,13 @@
"_active": true,
"_components": [
{
"__id__": 15
"__id__": 17
},
{
"__id__": 16
"__id__": 18
},
{
"__id__": 17
"__id__": 19
}
],
"_prefab": null,
......@@ -180,7 +180,7 @@
"array": [
0,
0,
572.4427919015139,
371.6221153255573,
0,
0,
0,
......@@ -351,6 +351,12 @@
},
{
"__id__": 10
},
{
"__id__": 15
},
{
"__id__": 16
}
],
"_prefab": null,
......@@ -441,7 +447,7 @@
"__id__": 7
},
"_enabled": true,
"_type": 2,
"_type": 1,
"_allowSleep": true,
"_gravityScale": 1,
"_linearDamping": 0,
......@@ -468,12 +474,12 @@
"_enabled": true,
"anchor": {
"__type__": "cc.Vec2",
"x": 29,
"y": -39
"x": 1,
"y": -31
},
"connectedAnchor": {
"__type__": "cc.Vec2",
"x": 3,
"x": 38,
"y": 0
},
"connectedBody": {
......@@ -482,12 +488,12 @@
"collideConnected": false,
"_linearOffset": {
"__type__": "cc.Vec2",
"x": 0,
"x": 30,
"y": 0
},
"_angularOffset": 0,
"_maxForce": 1,
"_maxTorque": 1,
"_maxForce": 10,
"_maxTorque": 200,
"_correctionFactor": 0.3,
"_id": "40EQRA9TRE+rFRdgMnGLW8"
},
......@@ -499,7 +505,7 @@
"__id__": 12
},
"_enabled": true,
"_type": 2,
"_type": 1,
"_allowSleep": true,
"_gravityScale": 1,
"_linearDamping": 0,
......@@ -518,7 +524,7 @@
},
{
"__type__": "cc.Node",
"_name": "gear",
"_name": "gear1",
"_objFlags": 0,
"_parent": {
"__id__": 2
......@@ -559,8 +565,8 @@
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
-59.201,
29.6,
-207.592,
-92.126,
0,
0,
0,
......@@ -617,37 +623,69 @@
"_id": "d899sMlPZKyrzwmjLmpXSy"
},
{
"__type__": "cc.MotorJoint",
"__type__": "cc.PhysicsBoxCollider",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 12
},
"_enabled": true,
"anchor": {
"__type__": "cc.Vec2",
"x": -30,
"y": -24
},
"connectedAnchor": {
"tag": 0,
"_density": 1,
"_sensor": false,
"_friction": 0.2,
"_restitution": 0,
"body": null,
"_offset": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"connectedBody": {
"__id__": 9
"_size": {
"__type__": "cc.Size",
"width": 30,
"height": 30
},
"collideConnected": false,
"_linearOffset": {
"_id": "b1GoUkKj5DJZ6aJKJtsrcU"
},
{
"__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",
"x": 0,
"x": 0.6,
"y": 0
},
"_angularOffset": 0,
"_maxForce": 1,
"_maxTorque": 1,
"_correctionFactor": 0.3,
"_id": "78Y9S/FiZMZr80gpkUwDx0"
"_size": {
"__type__": "cc.Size",
"width": 30,
"height": 30
},
"_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",
......
// 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