Ok, so i’ve started making a game, i’m still relatively new to lua, and this is my code so far:
display.setStatusBar( display.HiddenStatusBar ) --Hide status bar…
local physics = require (“physics”) --Require the physics library…
physics.start(); --start the physics engine
physics.setGravity( 0, 0 ) --Set gravity to 0
local background = display.newImage (“Grassland.png”)
local cannon
local cannonball
local cannonball = display.newGroup()
local shot = {}
cannon = display.newImage( “cannon.png”, 200, 217, true )
cannonbarral = display.newImage( “cannonbarral.png”, 200, 220, true )
function charge()
gCircle.rotation = gCircle.rotation - 3
impulse = impulse - 0.2
if(gCircle.rotation < -46) then
gCircle.rotation = -46
impulse = -3.2
end
end
function shot:touch(e)
if(e.phase == ‘ended’) then
Runtime:removeEventListener(‘enterFrame’, charge)
gCircle.isVisible = false
gCircle.rotation = 0
end
local cannonball = display.newImage(‘cannonball.png’, 84, 220)
physics.addBody(cannonball, {density = 1, friction = 0, bounce = 0})
cannonball:insert(cannonball)
cannonball:applyLinearImpulse(dir, impulse, cannonball.x, cannonball.y ) end
now my problems are as follows:
i cant get cannonball.png to load
i need the cannon to shoot on touch
and i need the cannonbarral.png to rotate when i click to fire, and for cannonball.png to come out of the base point
I’m sorry, they are reallY newby problems
thanks