第一种方式:
onElMove(event:EventTouch){
console.info("onMove");
this.e1.setWorldPosition(event.getUILocation().x,event.getUILocation().y,0);
}
这种方式有缺陷,因为当手指落下时,点击的位置不是Node的中心位置时,移动前会出现一个跳跃的行为,这种使得操作不连贯,效果很不好。
第二种方式: 通过偏移量(getUIDelta)来决定Node的位置,这种才是最好的方式 。
cc.Class({
extends: cc.Component,
start() {
// 获取DragonBones实例
this.dragonBonesNode = this.getComponent(cc.DragonBonesComponent);
// 获取节点的collider组件
this.collider = this.node.getComponent(cc.Collider);
// 如果没有collider组件,则添加一个box collider
if (!this.collider) {
this.collider = this.node.addComponent(cc.BoxCollider);
}
// 注册触摸事件
this.node.on(cc.Node.EventType.TOUCH_START, this.onTouchStart, this);
this.node.on(cc.Node.EventType.TOUCH_MOVE, this.onTouchMove, this);
this.node.on(cc.Node.EventT

最低0.47元/天 解锁文章
1611

被折叠的 条评论
为什么被折叠?



