Shooting projectiles

Hi all, so as I’m learning how to code, I’ve went through some tutorials but am stuck on a little part(s).

So my game so far looks roughly like this: (The square is rotating constantly)

gq7ffi8.png

My code is as follows: 

display.setStatusBar(display.HiddenStatusBar) local background = display.newImage("bg.png") local square = display.newImage( "maze.png" ) local cannon = display.newImage( "cannon.png") local physics = require('physics') physics.start() physics.setGravity(0, 0) cannon.xScale = 0.3 cannon.yScale = 0.3 cannon.x = -625 cannon.y = 1150 background.x = display.contentCentaerX background.y = display.contentCenterY background.xScale = 2 background.yScale = 2 square.x = 800 square.y = display.contentCenterY square.xScale = 2 square.yScale = 2 local function animate( event ) square.rotation = square.rotation + 1 end Runtime:addEventListener( "enterFrame", animate );

I’m trying to figure out how exactly can I make (cannonball.png) shoot out of the cannon on touch;

It could be in a fixed direction, or if possible wherever the user clicks.

Any assistance is appreciated,

Ali.

Here are some links I found when searching for “projectile” in the forums:

http://forums.coronalabs.com/topic/39666-projectile-trajectory-prediction-line/

http://forums.coronalabs.com/topic/37120-calculating-velocity-and-angle-to-hit-target/

http://forums.coronalabs.com/topic/29931-projectile-help/

http://forums.coronalabs.com/topic/27939-shooting-projectile-in-direction-of-touch/

And here are some more resources from the general Corona knowledge base:

http://www.coronalabs.com/blog/2013/02/19/more-physics-tricks-explained/

http://developer.coronalabs.com/code/trajectory-plotting

http://developer.coronalabs.com/code/how-make-angry-birds-catapult

http://developer.coronalabs.com/code/predictive-aiming-tower-defense

Here are some links I found when searching for “projectile” in the forums:

http://forums.coronalabs.com/topic/39666-projectile-trajectory-prediction-line/

http://forums.coronalabs.com/topic/37120-calculating-velocity-and-angle-to-hit-target/

http://forums.coronalabs.com/topic/29931-projectile-help/

http://forums.coronalabs.com/topic/27939-shooting-projectile-in-direction-of-touch/

And here are some more resources from the general Corona knowledge base:

http://www.coronalabs.com/blog/2013/02/19/more-physics-tricks-explained/

http://developer.coronalabs.com/code/trajectory-plotting

http://developer.coronalabs.com/code/how-make-angry-birds-catapult

http://developer.coronalabs.com/code/predictive-aiming-tower-defense