微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

朝箭头的方向角拍摄二维物体

如何解决朝箭头的方向角拍摄二维物体

所以我尝试编写一个对象,该对象将在箭头的方向角处被射击,但由于某些原因,它无法按预期工作(基本上只是向错误的方向射击)。我可以帮忙吗?

顺便说一句,这是我使用的代码

        if v.shootSnot then -- if the snot has been shot
         local name = flyingBird.name .. "a" .. _G.math.random() -- pick a name
         v.targetAngle =  _G.math.rad(v.pointerangle) - _G.math.pi / 2-- sets the target angle
         createSnot(name,v,v.targetAngle) -- creates the object
         local obj = objects.world[name]
         obj.xxVel,obj.yyVel = _G.math.cos(v.targetAngle),(_G.math.sin(v.targetAngle))
         setVeLocity(name,obj.xVel * 75,-(obj.yVel * 75)) -- shoots the object
         v.shootSnot = false
         v.snotShot = true
        elseif not v.shootSnot and not v.snotShot then -- else
        if v.pointerangle == nil then
         v.pointerangle = 0
        end
        v.pointerangle = v.pointerangle + dt -- rotate the pointer/arrow
        local w,h = _G.res.getSpriteBounds(v.sprite)
        local x,y = physicsToWorldTransform(v.x,v.y)
        drawSpriteOverWorld(x,y,"ORIGO",v.pointerangle)
        end

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。