properties: {
main:cc.Node
},
// use this for initialization
onLoad: function () {
this._init()
},
_init:function(){
var that = this;
var listener = {
event: cc.EventListener.TOUCH_ONE_BY_ONE,
onTouchBegan: function (touches, event) {
var touche = touches.getLocation();
var rpg = that.main.convertToWorldSpace(cc.p(that.node.x,that.node.y))
var touch1 = touche.x - rpg.x
var touch2 = touche.y - rpg.y
var jsc = Math.atan(touch1/touch2)*180/Math.PI
if(touch1<0)
if(touch2<0)
jsc = 180 + Math.abs(jsc)
jsc = 180 + Math.abs(jsc)
var re = cc.rotateTo(0.5,jsc-90);
that.node.runAction(re)
return true;
}
}
cc.eventManager.addListener(listener,this.node)
},
main:cc.Node
},
// use this for initialization
onLoad: function () {
this._init()
},
_init:function(){
var that = this;
var listener = {
event: cc.EventListener.TOUCH_ONE_BY_ONE,
onTouchBegan: function (touches, event) {
var touche = touches.getLocation();
var rpg = that.main.convertToWorldSpace(cc.p(that.node.x,that.node.y))
var touch1 = touche.x - rpg.x
var touch2 = touche.y - rpg.y
var jsc = Math.atan(touch1/touch2)*180/Math.PI
if(touch1<0)
if(touch2<0)
jsc = 180 + Math.abs(jsc)
jsc = 180 + Math.abs(jsc)
var re = cc.rotateTo(0.5,jsc-90);
that.node.runAction(re)
return true;
}
}
cc.eventManager.addListener(listener,this.node)
},