Commit 2f6ddd04 by 李楚霏

调整

parent 554fcf01
...@@ -75,25 +75,22 @@ ...@@ -75,25 +75,22 @@
"__id__": 5 "__id__": 5
}, },
{ {
"__id__": 8 "__id__": 7
},
{
"__id__": 10
}, },
{ {
"__id__": 16 "__id__": 14
} }
], ],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 20 "__id__": 19
}, },
{ {
"__id__": 21 "__id__": 20
}, },
{ {
"__id__": 22 "__id__": 21
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -183,7 +180,7 @@ ...@@ -183,7 +180,7 @@
"array": [ "array": [
0, 0,
0, 0,
573.7012350663882, 357.72409695043984,
0, 0,
0, 0,
0, 0,
...@@ -244,153 +241,6 @@ ...@@ -244,153 +241,6 @@
}, },
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
"_name": "joyStick",
"_objFlags": 0,
"_parent": {
"__id__": 2
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 6
},
{
"__id__": 7
}
],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 720,
"height": 1280
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "d2h2ShBatItJOqNhnibdTb"
},
{
"__type__": "3b6caruSLNAnp8j/pNXOWou",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 5
},
"_enabled": false,
"label": null,
"text": "hello",
"_id": "8bUf4RweZFWZ3TnM08/0Ig"
},
{
"__type__": "cc.Button",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 5
},
"_enabled": true,
"_normalMaterial": null,
"_grayMaterial": null,
"duration": 0.1,
"zoomScale": 1.2,
"clickEvents": [],
"_N$interactable": true,
"_N$enableAutoGrayEffect": false,
"_N$transition": 0,
"transition": 0,
"_N$normalColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_N$pressedColor": {
"__type__": "cc.Color",
"r": 211,
"g": 211,
"b": 211,
"a": 255
},
"pressedColor": {
"__type__": "cc.Color",
"r": 211,
"g": 211,
"b": 211,
"a": 255
},
"_N$hoverColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"hoverColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_N$disabledColor": {
"__type__": "cc.Color",
"r": 124,
"g": 124,
"b": 124,
"a": 255
},
"_N$normalSprite": null,
"_N$pressedSprite": null,
"pressedSprite": null,
"_N$hoverSprite": null,
"hoverSprite": null,
"_N$disabledSprite": null,
"_N$target": {
"__id__": 5
},
"_id": "0aEgKUAvpMsKyUXJZb+pyX"
},
{
"__type__": "cc.Node",
"_name": "bg", "_name": "bg",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
...@@ -400,7 +250,7 @@ ...@@ -400,7 +250,7 @@
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 9 "__id__": 6
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -456,7 +306,7 @@ ...@@ -456,7 +306,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 8 "__id__": 5
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
...@@ -494,19 +344,22 @@ ...@@ -494,19 +344,22 @@
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 11 "__id__": 8
}, },
{ {
"__id__": 12 "__id__": 9
}, },
{ {
"__id__": 13 "__id__": 10
}, },
{ {
"__id__": 14 "__id__": 11
}, },
{ {
"__id__": 19 "__id__": 12
},
{
"__id__": 13
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -562,7 +415,7 @@ ...@@ -562,7 +415,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 10 "__id__": 7
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
...@@ -594,7 +447,7 @@ ...@@ -594,7 +447,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 10 "__id__": 7
}, },
"_enabled": true, "_enabled": true,
"_type": 1, "_type": 1,
...@@ -615,77 +468,260 @@ ...@@ -615,77 +468,260 @@
"_id": "fc/er1Rl9D2oRl/jtSXWGX" "_id": "fc/er1Rl9D2oRl/jtSXWGX"
}, },
{ {
"__type__": "cc.CircleCollider", "__type__": "f8d7b/0hj9IhpmWwu6imtTe",
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 10 "__id__": 7
}, },
"_enabled": true, "_enabled": true,
"tag": 0, "target": null,
"_offset": { "_id": "eeittg4eRA+aMGnKaTJury"
"__type__": "cc.Vec2",
"x": 0,
"y": 0
}, },
"_radius": 15, {
"_id": "4a7L41jTlP4a0BkoZEqTAf" "__type__": "3b6caruSLNAnp8j/pNXOWou",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 7
},
"_enabled": true,
"label": null,
"text": "hello",
"_id": "f0wrcnc+pIVY/c0/Uf6AXN"
}, },
{ {
"__type__": "cc.RevoluteJoint", "__type__": "cc.Button",
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 10 "__id__": 7
}, },
"_enabled": true, "_enabled": true,
"anchor": { "_normalMaterial": null,
"__type__": "cc.Vec2", "_grayMaterial": null,
"x": 0, "duration": 0.1,
"y": 0 "zoomScale": 1.2,
"clickEvents": [],
"_N$interactable": true,
"_N$enableAutoGrayEffect": false,
"_N$transition": 0,
"transition": 0,
"_N$normalColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
}, },
"connectedAnchor": { "_N$pressedColor": {
"__type__": "cc.Vec2", "__type__": "cc.Color",
"x": 0, "r": 211,
"y": 0 "g": 211,
"b": 211,
"a": 255
}, },
"connectedBody": { "pressedColor": {
"__id__": 15 "__type__": "cc.Color",
"r": 211,
"g": 211,
"b": 211,
"a": 255
}, },
"collideConnected": false, "_N$hoverColor": {
"_maxMotorTorque": 100, "__type__": "cc.Color",
"_motorSpeed": 100, "r": 255,
"_enableLimit": false, "g": 255,
"_enableMotor": true, "b": 255,
"referenceAngle": 0, "a": 255
"lowerAngle": 0, },
"upperAngle": 0, "hoverColor": {
"_id": "9bft1/UTtJOqrFIUvJxer4" "__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_N$disabledColor": {
"__type__": "cc.Color",
"r": 124,
"g": 124,
"b": 124,
"a": 255
},
"_N$normalSprite": null,
"_N$pressedSprite": null,
"pressedSprite": null,
"_N$hoverSprite": null,
"hoverSprite": null,
"_N$disabledSprite": null,
"_N$target": {
"__id__": 7
},
"_id": "48ENLxk1dDw5ZmE8E9ss8n"
}, },
{ {
"__type__": "cc.RigidBody", "__type__": "cc.PhysicsPolygonCollider",
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 16 "__id__": 7
}, },
"_enabled": true, "_enabled": true,
"_type": 1, "tag": 0,
"_allowSleep": true, "_density": 1,
"_gravityScale": 1, "_sensor": false,
"_linearDamping": 0, "_friction": 0.2,
"_angularDamping": 0, "_restitution": 0,
"_linearVelocity": { "body": null,
"_offset": {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",
"x": 0, "x": 0,
"y": 0 "y": 0
}, },
"_angularVelocity": 0, "points": [
"_fixedRotation": false, {
"enabledContactListener": false, "__type__": "cc.Vec2",
"bullet": false, "x": -13.9,
"awakeOnLoad": true, "y": -14.2
"_id": "6bb1a8XjRMgbwExmweTiv3" },
{
"__type__": "cc.Vec2",
"x": -10.9,
"y": -17.9
},
{
"__type__": "cc.Vec2",
"x": -3.1,
"y": -11.7
},
{
"__type__": "cc.Vec2",
"x": 2.5,
"y": -12.1
},
{
"__type__": "cc.Vec2",
"x": 8.5,
"y": -17.2
},
{
"__type__": "cc.Vec2",
"x": 11.9,
"y": -14.8
},
{
"__type__": "cc.Vec2",
"x": 7.8,
"y": -9.7
},
{
"__type__": "cc.Vec2",
"x": 10.8,
"y": -5.5
},
{
"__type__": "cc.Vec2",
"x": 19.8,
"y": -7.1
},
{
"__type__": "cc.Vec2",
"x": 20.8,
"y": -2.8
},
{
"__type__": "cc.Vec2",
"x": 11.9,
"y": 0.3
},
{
"__type__": "cc.Vec2",
"x": 11.2,
"y": 4.3
},
{
"__type__": "cc.Vec2",
"x": 18,
"y": 10.7
},
{
"__type__": "cc.Vec2",
"x": 15.8,
"y": 14.2
},
{
"__type__": "cc.Vec2",
"x": 7.9,
"y": 9.3
},
{
"__type__": "cc.Vec2",
"x": 2.4,
"y": 12.3
},
{
"__type__": "cc.Vec2",
"x": 1.8,
"y": 18.8
},
{
"__type__": "cc.Vec2",
"x": -2,
"y": 18.8
},
{
"__type__": "cc.Vec2",
"x": -3.4,
"y": 12.4
},
{
"__type__": "cc.Vec2",
"x": -8.2,
"y": 10.1
},
{
"__type__": "cc.Vec2",
"x": -14.4,
"y": 14.4
},
{
"__type__": "cc.Vec2",
"x": -16.8,
"y": 11
},
{
"__type__": "cc.Vec2",
"x": -12.1,
"y": 5.9
},
{
"__type__": "cc.Vec2",
"x": -12.1,
"y": 0.7
},
{
"__type__": "cc.Vec2",
"x": -20.9,
"y": -0.1
},
{
"__type__": "cc.Vec2",
"x": -20.4,
"y": -4.3
},
{
"__type__": "cc.Vec2",
"x": -11.6,
"y": -4.6
},
{
"__type__": "cc.Vec2",
"x": -8.8,
"y": -8.5
}
],
"_id": "d0HID9ez1MdIb7PkKP48vV"
}, },
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
...@@ -698,10 +734,13 @@ ...@@ -698,10 +734,13 @@
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 17 "__id__": 15
}, },
{ {
"__id__": 15 "__id__": 16
},
{
"__id__": 17
}, },
{ {
"__id__": 18 "__id__": 18
...@@ -730,7 +769,7 @@ ...@@ -730,7 +769,7 @@
"__type__": "TypedArray", "__type__": "TypedArray",
"ctor": "Float64Array", "ctor": "Float64Array",
"array": [ "array": [
47.682, 181.901,
60.046, 60.046,
0, 0,
0, 0,
...@@ -760,7 +799,7 @@ ...@@ -760,7 +799,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 16 "__id__": 14
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
...@@ -788,34 +827,202 @@ ...@@ -788,34 +827,202 @@
"_id": "d899sMlPZKyrzwmjLmpXSy" "_id": "d899sMlPZKyrzwmjLmpXSy"
}, },
{ {
"__type__": "cc.CircleCollider", "__type__": "cc.RigidBody",
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 16 "__id__": 14
},
"_enabled": true,
"_type": 1,
"_allowSleep": true,
"_gravityScale": 1,
"_linearDamping": 0,
"_angularDamping": 0,
"_linearVelocity": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_angularVelocity": 200,
"_fixedRotation": false,
"enabledContactListener": false,
"bullet": false,
"awakeOnLoad": true,
"_id": "6bb1a8XjRMgbwExmweTiv3"
},
{
"__type__": "cc.PhysicsPolygonCollider",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 14
}, },
"_enabled": true, "_enabled": true,
"tag": 0, "tag": 0,
"_density": 1,
"_sensor": false,
"_friction": 0.2,
"_restitution": 0,
"body": null,
"_offset": { "_offset": {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",
"x": 0, "x": 0,
"y": 0 "y": 0
}, },
"_radius": 15, "points": [
"_id": "42P+6j9N5LXYWkcyzM1PV3" {
"__type__": "cc.Vec2",
"x": -13.9,
"y": -14.2
},
{
"__type__": "cc.Vec2",
"x": -10.9,
"y": -17.9
},
{
"__type__": "cc.Vec2",
"x": -3.1,
"y": -11.7
},
{
"__type__": "cc.Vec2",
"x": 2.5,
"y": -12.1
},
{
"__type__": "cc.Vec2",
"x": 8.5,
"y": -17.2
},
{
"__type__": "cc.Vec2",
"x": 11.9,
"y": -14.8
},
{
"__type__": "cc.Vec2",
"x": 7.8,
"y": -9.7
},
{
"__type__": "cc.Vec2",
"x": 10.8,
"y": -5.5
}, },
{ {
"__type__": "9f879YGuoROFrLJrd9nEcLA", "__type__": "cc.Vec2",
"x": 19.8,
"y": -7.1
},
{
"__type__": "cc.Vec2",
"x": 20.8,
"y": -2.8
},
{
"__type__": "cc.Vec2",
"x": 11.9,
"y": 0.3
},
{
"__type__": "cc.Vec2",
"x": 11.2,
"y": 4.3
},
{
"__type__": "cc.Vec2",
"x": 18,
"y": 10.7
},
{
"__type__": "cc.Vec2",
"x": 15.8,
"y": 14.2
},
{
"__type__": "cc.Vec2",
"x": 7.9,
"y": 9.3
},
{
"__type__": "cc.Vec2",
"x": 2.4,
"y": 12.3
},
{
"__type__": "cc.Vec2",
"x": 1.8,
"y": 18.8
},
{
"__type__": "cc.Vec2",
"x": -2,
"y": 18.8
},
{
"__type__": "cc.Vec2",
"x": -3.4,
"y": 12.4
},
{
"__type__": "cc.Vec2",
"x": -8.2,
"y": 10.1
},
{
"__type__": "cc.Vec2",
"x": -14.4,
"y": 14.4
},
{
"__type__": "cc.Vec2",
"x": -16.8,
"y": 11
},
{
"__type__": "cc.Vec2",
"x": -12.1,
"y": 5.9
},
{
"__type__": "cc.Vec2",
"x": -12.1,
"y": 0.7
},
{
"__type__": "cc.Vec2",
"x": -20.9,
"y": -0.1
},
{
"__type__": "cc.Vec2",
"x": -20.4,
"y": -4.3
},
{
"__type__": "cc.Vec2",
"x": -11.6,
"y": -4.6
},
{
"__type__": "cc.Vec2",
"x": -8.8,
"y": -8.5
}
],
"_id": "f86k+L/d1Aqqi7ptHNUblC"
},
{
"__type__": "2c6b8qg2xxDYqGamkELYi6D",
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 10 "__id__": 14
}, },
"_enabled": true, "_enabled": true,
"label": null, "_id": "9cv0WAoLxHf4IeqEhbbIGf"
"target": null,
"text": "hello",
"_id": "aaTLhHzJRDvbZhDslxn9T5"
}, },
{ {
"__type__": "cc.Canvas", "__type__": "cc.Canvas",
...@@ -862,13 +1069,13 @@ ...@@ -862,13 +1069,13 @@
"_id": "29zXboiXFBKoIV4PQ2liTe" "_id": "29zXboiXFBKoIV4PQ2liTe"
}, },
{ {
"__type__": "1a6bcOcZghGVogtysviFCX0", "__type__": "f69d1tXlplDb5zzCXRfk+k+",
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 2 "__id__": 2
}, },
"_enabled": true, "_enabled": true,
"_id": "53H/nqM0ZFU4TErvg9jH2/" "_id": "57dqsHQipKZ5YKT5d0lC8D"
} }
] ]
\ No newline at end of file
...@@ -8,29 +8,22 @@ ...@@ -8,29 +8,22 @@
import clientEvent from "./clientEvent"; import clientEvent from "./clientEvent";
const {ccclass, property} = cc._decorator; 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(cc.Node) @property(cc.Node)
target: cc.Node = null; target: cc.Node = null;
@property
text: string = 'hello';
rigidBody: cc.RigidBody; rigidBody: cc.RigidBody;
motor: cc.MotorJoint; motor: cc.MotorJoint;
collider: cc.CircleCollider; collider: cc.PhysicsPolygonCollider;
// LIFE-CYCLE CALLBACKS: // LIFE-CYCLE CALLBACKS:
onLoad () { onLoad () {
this.rigidBody = this.node.getComponent(cc.RigidBody); this.rigidBody = this.node.getComponent(cc.RigidBody);
this.motor = this.node.getComponent(cc.MotorJoint);
// this.motor.connectedBody // this.motor.connectedBody
this.collider =this.node.getComponent(cc.CircleCollider); this.collider =this.node.getComponent(cc.PhysicsPolygonCollider);
const collisionManager = cc.director.getCollisionManager(); const collisionManager = cc.director.getCollisionManager();
collisionManager.enabled = true; collisionManager.enabled = true;
} }
......
...@@ -35,20 +35,20 @@ export default class NewClass extends cc.Component { ...@@ -35,20 +35,20 @@ export default class NewClass extends cc.Component {
this.startPoint = event.getStartLocation(); this.startPoint = event.getStartLocation();
} }
_touchMoveEvent(event: cc.Event.EventTouch) { _touchMoveEvent(event: cc.Event.EventTouch) {
this.points.push(event.getLocation()); // this.points.push(event.getLocation());
if (this.points.length > 20) { // if (this.points.length > 20) {
this.points.shift(); // this.points.shift();
} // }
const averagePoint = new cc.Vec2(0, 0); // const averagePoint = new cc.Vec2(0, 0);
this.points.forEach((point) => { // this.points.forEach((point) => {
averagePoint.x += point.x; // averagePoint.x += point.x;
averagePoint.y += point.y; // averagePoint.y += point.y;
}) // })
averagePoint.multiplyScalar(1 / this.points.length); // averagePoint.multiplyScalar(1 / this.points.length);
const delta = new cc.Vec2(event.getLocation().x - averagePoint.x, event.getLocation().y - averagePoint.y); // const delta = new cc.Vec2(event.getLocation().x - averagePoint.x, event.getLocation().y - averagePoint.y);
let dir = delta; // let dir = delta;
// let dir = event.getLocation(); let dir = cc.v2( event.getLocation().x - this.startPoint.x, event.getLocation().y - this.startPoint.y);
clientEvent.dispatchEvent('move', dir); clientEvent.dispatchEvent('move', dir);
} }
_touchEndEvent(event: cc.Event.EventTouch) { _touchEndEvent(event: cc.Event.EventTouch) {
......
// 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;
}
}
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