求教,求教!!!有没有大佬睡醒了
不懂你的会闪是什么意思,我觉得就根据向量然后反射来做就可以呀
实例化小球
InitBulletNumArr(s: number, node: Node) {
for (let i = 0; i < s; i++) {
let p = instantiate(node)
p.setParent(this.node)
p.active = false
this.LineBulletArr.push(p)
}
this.LineBullet.active = false
}
update函数中的CanDraw代表可以画线
update(deltaTime: number) {
if (this.Pao1.getComponent(Pao1).isScFlag == false && this.BulletArr.getComponent(BulletArr).count == 0) {
this.CanDraw = true
}
else if (this.Pao1.getComponent(Pao1).isScFlag == true && this.BulletArr.getComponent(BulletArr).count > 0) {
this.CanDraw = false
}
if (this.CanDraw) {
let angle = this.node.eulerAngles.z * 2 / 360 * Math.PI;
//计算基于Y轴的方向向量
let dir = v2(Math.cos(angle), Math.sin(angle));
//方向向量进行单位化
dir.normalize()
for (let i = 0; i < this.BulletNum; i++) {
if (this.LineBulletArr[i].getWorldPosition().x < -18) {
let t = this.LineBulletArr[i].getWorldPosition
this.LineBulletArr[i].setPosition(i * 50 * dir.y, i * 50 * dir.x, 0)
this.LineBulletArr[i].setWorldPosition(-(this.LineBulletArr[i].getWorldPosition().x + 20), this.LineBulletArr[i].getWorldPosition().y, 0)
if (this.LineBulletArr[i].active == false) {
this.LineBulletArr[i].active = true
}
}
else if (this.LineBulletArr[i].getWorldPosition().x > 700) {
this.LineBulletArr[i].setPosition(i * 50 * dir.y, i * 50 * dir.x, 0)
this.LineBulletArr[i].setWorldPosition(1424 - this.LineBulletArr[i].getWorldPosition().x, this.LineBulletArr[i].getWorldPosition().y, 0)
if (this.LineBulletArr[i].active == false) {
this.LineBulletArr[i].active = true
}
}
else {
this.LineBulletArr[i].setPosition(i * 50 * dir.y, i * 50 * dir.x, 0)
if (this.LineBulletArr[i].active == false) {
this.LineBulletArr[i].active = true
}
}
}
}
if (!this.CanDraw) {
for (let i = 0; i < this.BulletNum; i++) {
if (this.LineBulletArr[i].active != false) {
this.LineBulletArr[i].active = false
}
}
}
}
就是折射出来的小球会拼命的闪
当时刚接触cocos绞尽脑汁就将就着这样
你画出的线是还会自己往前移动的那种么
我感觉应该不用再update里面画吧,你触摸开始时候以及移动时候调下方法刷新不就可以。
对,这个方法我要舍弃了。移动时让它复现,但是我不知道怎么用射线检测
不用射线检测,单纯向量就可以算。
写的不错,他是我的了~
感谢大佬,这个函数的转换逻辑是怎么实现的
let relativeResults = new ComonSceneFunc().AimLineDest(relativeVec,
1000, new Vec2(dest.x, dest.y));
还有genneraterAimPoint()传进来的两个参数代表啥

genneraterAimPoint(aimVec: Vec2, results: (Vec3 | Vec2)[])
好嘞,多谢多谢
小狐狸,你的方法也分享一起给我学学呀
单纯向量不闪怎么实现
我没现成的代码,我得写demo才行,看看周末吧,急着要么
好啊,不急不急






我我第一次触摸的results传不进去