Not sure about the official answer, but have run across this as well.
I see a couple options for the gunfire, e.g. if pressing the attack, you get to do so at the shortest range.
Otherwise, measure the range from the aircraft, at its endpoint in the move, from the vessel, and conduct firing from there, if it turns away from the vessel, instead of firing over it.
Same applies for the return fire.
As for fire from the ship/boat, if it is flown over, permit firing from both sides of the vessel, or twice, e.g. front and rear arcs of the aircraft, as it flies over it. Of course, the aircraft can fire both front and rear guns, assuming it has any of the latter, as it does so, too.
Check the Narrow Seas Yahoo Group. Can't recall which version of the QRS is posted in the files section, but it may help. Light guns don't do damage to some areas of vessels, due to their armor protection.