Commit 2f6ddd04 by 李楚霏

调整

parent 554fcf01
......@@ -75,25 +75,22 @@
"__id__": 5
},
{
"__id__": 8
},
{
"__id__": 10
"__id__": 7
},
{
"__id__": 16
"__id__": 14
}
],
"_active": true,
"_components": [
{
"__id__": 20
"__id__": 19
},
{
"__id__": 21
"__id__": 20
},
{
"__id__": 22
"__id__": 21
}
],
"_prefab": null,
......@@ -183,7 +180,7 @@
"array": [
0,
0,
573.7012350663882,
357.72409695043984,
0,
0,
0,
......@@ -244,153 +241,6 @@
},
{
"__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",
"_objFlags": 0,
"_parent": {
......@@ -400,7 +250,7 @@
"_active": true,
"_components": [
{
"__id__": 9
"__id__": 6
}
],
"_prefab": null,
......@@ -456,7 +306,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 8
"__id__": 5
},
"_enabled": true,
"_materials": [
......@@ -494,19 +344,22 @@
"_active": true,
"_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,
......@@ -562,7 +415,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 10
"__id__": 7
},
"_enabled": true,
"_materials": [
......@@ -594,7 +447,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 10
"__id__": 7
},
"_enabled": true,
"_type": 1,
......@@ -615,77 +468,260 @@
"_id": "fc/er1Rl9D2oRl/jtSXWGX"
},
{
"__type__": "cc.CircleCollider",
"__type__": "f8d7b/0hj9IhpmWwu6imtTe",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 10
"__id__": 7
},
"_enabled": true,
"tag": 0,
"_offset": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
"target": null,
"_id": "eeittg4eRA+aMGnKaTJury"
},
{
"__type__": "3b6caruSLNAnp8j/pNXOWou",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 7
},
"_radius": 15,
"_id": "4a7L41jTlP4a0BkoZEqTAf"
"_enabled": true,
"label": null,
"text": "hello",
"_id": "f0wrcnc+pIVY/c0/Uf6AXN"
},
{
"__type__": "cc.RevoluteJoint",
"__type__": "cc.Button",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 10
"__id__": 7
},
"_enabled": true,
"anchor": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
"_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
},
"connectedAnchor": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
"_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__": 7
},
"connectedBody": {
"__id__": 15
},
"collideConnected": false,
"_maxMotorTorque": 100,
"_motorSpeed": 100,
"_enableLimit": false,
"_enableMotor": true,
"referenceAngle": 0,
"lowerAngle": 0,
"upperAngle": 0,
"_id": "9bft1/UTtJOqrFIUvJxer4"
"_id": "48ENLxk1dDw5ZmE8E9ss8n"
},
{
"__type__": "cc.RigidBody",
"__type__": "cc.PhysicsPolygonCollider",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 16
"__id__": 7
},
"_enabled": true,
"_type": 1,
"_allowSleep": true,
"_gravityScale": 1,
"_linearDamping": 0,
"_angularDamping": 0,
"_linearVelocity": {
"tag": 0,
"_density": 1,
"_sensor": false,
"_friction": 0.2,
"_restitution": 0,
"body": null,
"_offset": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_angularVelocity": 0,
"_fixedRotation": false,
"enabledContactListener": false,
"bullet": false,
"awakeOnLoad": true,
"_id": "6bb1a8XjRMgbwExmweTiv3"
"points": [
{
"__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__": "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",
......@@ -698,10 +734,13 @@
"_active": true,
"_components": [
{
"__id__": 17
"__id__": 15
},
{
"__id__": 15
"__id__": 16
},
{
"__id__": 17
},
{
"__id__": 18
......@@ -730,7 +769,7 @@
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
47.682,
181.901,
60.046,
0,
0,
......@@ -760,7 +799,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 16
"__id__": 14
},
"_enabled": true,
"_materials": [
......@@ -788,34 +827,202 @@
"_id": "d899sMlPZKyrzwmjLmpXSy"
},
{
"__type__": "cc.CircleCollider",
"__type__": "cc.RigidBody",
"_name": "",
"_objFlags": 0,
"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,
"tag": 0,
"_density": 1,
"_sensor": false,
"_friction": 0.2,
"_restitution": 0,
"body": null,
"_offset": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_radius": 15,
"_id": "42P+6j9N5LXYWkcyzM1PV3"
"points": [
{
"__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__": "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__": "9f879YGuoROFrLJrd9nEcLA",
"__type__": "2c6b8qg2xxDYqGamkELYi6D",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 10
"__id__": 14
},
"_enabled": true,
"label": null,
"target": null,
"text": "hello",
"_id": "aaTLhHzJRDvbZhDslxn9T5"
"_id": "9cv0WAoLxHf4IeqEhbbIGf"
},
{
"__type__": "cc.Canvas",
......@@ -862,13 +1069,13 @@
"_id": "29zXboiXFBKoIV4PQ2liTe"
},
{
"__type__": "1a6bcOcZghGVogtysviFCX0",
"__type__": "f69d1tXlplDb5zzCXRfk+k+",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 2
},
"_enabled": true,
"_id": "53H/nqM0ZFU4TErvg9jH2/"
"_id": "57dqsHQipKZ5YKT5d0lC8D"
}
]
\ No newline at end of file
......@@ -8,29 +8,22 @@
import clientEvent from "./clientEvent";
const {ccclass, property} = cc._decorator;
@ccclass
export default class NewClass extends cc.Component {
@property(cc.Label)
label: cc.Label = null;
@property(cc.Node)
target: cc.Node = null;
@property
text: string = 'hello';
rigidBody: cc.RigidBody;
motor: cc.MotorJoint;
collider: cc.CircleCollider;
collider: cc.PhysicsPolygonCollider;
// LIFE-CYCLE CALLBACKS:
onLoad () {
this.rigidBody = this.node.getComponent(cc.RigidBody);
this.motor = this.node.getComponent(cc.MotorJoint);
// this.motor.connectedBody
this.collider =this.node.getComponent(cc.CircleCollider);
this.collider =this.node.getComponent(cc.PhysicsPolygonCollider);
const collisionManager = cc.director.getCollisionManager();
collisionManager.enabled = true;
}
......
......@@ -35,22 +35,22 @@ export default class NewClass extends cc.Component {
this.startPoint = event.getStartLocation();
}
_touchMoveEvent(event: cc.Event.EventTouch) {
this.points.push(event.getLocation());
if (this.points.length > 20) {
this.points.shift();
}
const averagePoint = new cc.Vec2(0, 0);
this.points.forEach((point) => {
averagePoint.x += point.x;
averagePoint.y += point.y;
})
averagePoint.multiplyScalar(1 / this.points.length);
// this.points.push(event.getLocation());
// if (this.points.length > 20) {
// this.points.shift();
// }
// const averagePoint = new cc.Vec2(0, 0);
// this.points.forEach((point) => {
// averagePoint.x += point.x;
// 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 = event.getLocation();
// 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);
}
}
_touchEndEvent(event: cc.Event.EventTouch) {
this.points = [];
}
......
// 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