Quantcast
Channel: Cocos中文社区 - 最新主题
Viewing all articles
Browse latest Browse all 88851

TouchMove回调事件内做旋转问题

$
0
0

@wangqin696 写道:

//拖动
dragMove: function (event) {
event.getLocation();
let hero_x = this.node.x;
let hero_y = this.node.y;
//旋转角度计算
let rotationAngle = cc.pToAngle(cc.pSub(cc.v2(hero_x, hero_y),
cc.v2(this.xx, this.yy)));
this.xx = this.node.x;//更新记录x
this.yy = this.node.y; //更新记录y
let heroRotation1 = rotationAngle === 0 ? this.node.rotation : 90 - rotationAngle / (2 * Math.PI) * 360;
// this.node.rotation = heroRotation1;//这个可以实时调整Node的角度
this.node.runAction(cc.rotateTo(0.1, heroRotation1));//这个只能滑动停止时旋转角度
com.rotation = heroRotation1;
//不移出屏幕
let minX = -this.node.parent.width / 2 + this.node.width / 2;
let maxX = -minX;
let minY = -this.node.parent.height / 2 + this.node.height / 2;
let maxY = -minY;
let delta = event.touch.getDelta();
if (delta.x === 0 && delta.y === 0) {
return;
}
hero_y += delta.y;
hero_x += delta.x;
if (hero_x < minX) {
hero_x = minX;
}
if (hero_x > maxX) {
hero_x = maxX;
}
if (hero_y < minY) {
hero_y = minY;
}
if (hero_y > maxY) {
hero_y = maxY;
}
//拖动Node进行移动
this.node.runAction(cc.moveTo(0.4, hero_x, hero_y));
},

问题: this.node.rotation = heroRotation1;//这个可以实时调整Node的角度但是
this.node.runAction(cc.rotateTo(0.1, heroRotation1));//这个只能滑动停止时旋转角度
有什么可以解决这个问题吗?哪位大神知道!
主要目的是我在移动物体时,物体头部调整:要按照我移动的方向

帖子: 1

参与者: 1

阅读整个主题


Viewing all articles
Browse latest Browse all 88851

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>