第一次写博客 导致紧张吓得我直接贴代码
cc.Class({
extends: cc.Component,
properties: {
selecNode: {
default: null,
type: cc.Node
},
item: {
default: null,
type: cc.Prefab
},
radius: 0, //半径
pCenter: cc.Vec2, //圆心
angleInterval: 0, //每个预制体之间的间隔角度
angleFx: 0, //阻力系数
speedMin: 0.1, //最小转速
itemNum: 0, //预制体个数
//滑动的最终角度,用来设置最小角度和最大角度
angleMin: 0,
angleMax: 0,
beginVec: cc.Vec2,
touchVec: cc.Vec2,
backNum: 0,
oldVec: 0,//记录上一次角度的位置
beginPoint: cc.Vec2, //开始的位置
movePoint: cc.Vec2,
guanxing: cc.repeatForever,
count: cc.repeatForever,
angleDx: null,
angleS: 0,
time: 0,
angleSpeed: 0,
stopTime: 0,
angleDx_Save: null,
direction: 0,
beRotation: 0,
Speed: 0,
i: 0
},
// use this for initialization
onLoad: function () {
this.initSelecScene();
},
buttonEvent: function (event, data) {
if (data === 'back') {
cc.director.loadScene('MainScene');
}
},
initSelecScene: function () {
this.initData();
this.loadUI();
this.loadTouchStartEvent();
this.loadTouchEndEvent();
this.loadTouchMoveEvent();
this.updateItemAngle();
},
initData: function () {
this.selecNode.rotation = 47;
this.radius = 1600;
this.pCenter = cc.v2(this.radius, this.radius);
this.angleInterval = 6;
this.angleFx = 1 / 6;
this.speedMin = 0.1;
this.itemNum = 6;
this.angleMin = 47;
this.angleMax = -2;
this.backNum = 3;
this.Speed = 1.9;
},
loadUI: function () {
for (var i = 0; i < this.itemNum; ++i)