- Creator 版本:
求助在cocos3.x版本怎么实现物体拖动
我的思路报错了
如图:
呜呜呜,球球各位大佬
let pos=event.getUILocation();
this.node.setPosition(cc.v3(pos.x,pos.y))
鼠标放上去看报错原因啊。
没报错了,但是为啥我一拖就不见了,无图层遮挡。。。教教我,大大佬佬
你用的是世界坐标,需要坐标转换一下
哈?他不是getUILocation吗
?
拖2D的还是拖3D的?
2d。。。
touchMove(event: EventTouch) {
const location = event.getUILocation();
this.testNode.setWorldPosition(location.x, location.y, 0);
}
差不多这样
呜呜呜!谢谢!!!!!
onTouchStart(event: EventTouch)
{
let TouchPos = event.getLocation()
let Touchpos3 = new Vec3(TouchPos.x, TouchPos.y)
let TheCamera = this.camera;
let WorldPos = new Vec3;
TheCamera.camera.screenToWorld(WorldPos, Touchpos3)
let realPos = this.role.parent.getComponent(UITransform).convertToNodeSpaceAR(WorldPos)
this.role.position = realPos
}