I said “last post”. It’s the updated version that kinda fixes that problem. But here’s your code updated. (Not trying to sound harsh here haha)
local function shoot(event) local speed = 2 -- Just increase this for faster speed. local xFly = event.x - player.x local yFly = event.y - player.y local diff = xFly \* yFly local normX = xFly / diff local normY = yFly / diff local bullet = display.newCircle( player.x, player.y, 10 ) physics.addBody(bullet, "dynamic") bullet.gravityScale = 0 bullet.isBullet = true bullet:setLinearVelocity(xFly \* speed, yFly \* speed) return true end
This does the same as my code, except that it’s speed is doubled haha
Why are you calculating normX and normY when it’s not used in the code?
Besides that, I still have the problem with the speed.
When I click near the players ship, the missles are fired at lower speed, as when I click further away from the ship.
Let me explain this by an example:
I click 500 pixels above the ship. The missle takes 1 second to reach this location
I click 100 pixels above the ship. The missle takes 1 second to reach this location.
But when I click 100 pixels above the ship, the missle should take 200 ms to reach this location, not 1000 ms.
So the missle should fire always at the same speed, regardless where I click on the screen
How can I fix this?
Thanks and regards 