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

问题描述

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

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

        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 (将#修改为@)