ball shadow on the ground

Can anybody explain me how to make ball shadow on the ground so that it makes the plaer feel that the ball is moving up in the ground .The code helps me make the ball move in the desired location but I want also the shadow to be there so that it looks as if the ballis moving in the air and not in the ground.How to make it?Can anybody suggest me any help regarding this?

[code]

function vyf(v, a)
return v * math.cos(a * math.pi / 180)
end

function vxt(v, a, t)
return v * math.sin(a * math.pi / 180) - 9.8 * t
end

function xt(v, a, t)
return v * math.sin(a * math.pi / 180) * t - 0.5 * 9.8 * t * t
end

–[[worker functions]]–

function totalRangeHeightFlightTime(v, ag)
local h = vxt(v, ag, 0) * vxt(v, ag, 0) / (2 * 9.8)
local t = 2 * vxt(v, ag, 0) / 9.8
local r = v * v * math.sin( 2 * ag * math.pi / 180 ) / 9.8
return r, h, t
end

function positionAtTime(v, ag, t)
local vy = vyf(v,ag) – horizontal velocity
local y = vyf(v,ag) * t – horizontal distance
local vx = vxt(v, ag, t) – vertical velocity
local x = xt(v, ag, t) – height at time ‘t’

return x, y, vx, vy
end

–[[environment setup]]–

local offsetX, offsetY = 384, 900
local iteration = .1

local v = 70 – launch velocity v/ms
local ag = 60 – launch angle (theta) degrees
local r, h, f = totalRangeHeightFlightTime(v, ag) – total flight time

print( 'range: ', r )
print( 'height: ', h )
print( 'flight time: ', f )

–[[trajectory plotting]]–
for t = 0, f, iteration do
local x, y, vx, vy = positionAtTime(v, ag, t)
print( math.round(x), math.round(y) )
local cir1=display.newCircle( x + offsetX, y * -1 + offsetY, (vx+vy)*.1 )
end
[/code] [import]uid: 82446 topic_id: 32868 reply_id: 332868[/import]

Create another image that is the shadow of the ball. Keep the Y fixed so the shadow remains on the ground and update the X with the ball. You could even set an angle of light to figure out where the shadow should be (if you don’t want the light source directly above the ball). Then scale the object in relation to the ball height.

This won’t work if you have the lighting source change direction, but you could probably update it to do so if you need. [import]uid: 181948 topic_id: 32868 reply_id: 130622[/import]

Create another image that is the shadow of the ball. Keep the Y fixed so the shadow remains on the ground and update the X with the ball. You could even set an angle of light to figure out where the shadow should be (if you don’t want the light source directly above the ball). Then scale the object in relation to the ball height.

This won’t work if you have the lighting source change direction, but you could probably update it to do so if you need. [import]uid: 181948 topic_id: 32868 reply_id: 130622[/import]

Could you tell he how to add air drag to the above code to make it feel like “Paper Toss” kind of game?What should be done in the above code to make an air drag effect to the motion of the game. [import]uid: 82446 topic_id: 32868 reply_id: 131263[/import]

You can adjust the linear damping of the object to get more of an air drag effect on your physics bodies:

http://developer.coronalabs.com/reference/index/bodylineardamping

You can also play around with the scaling, density, and gravity. It just comes down to a lot of tweaking until it feels/looks right. [import]uid: 181948 topic_id: 32868 reply_id: 131266[/import]

Could you tell he how to add air drag to the above code to make it feel like “Paper Toss” kind of game?What should be done in the above code to make an air drag effect to the motion of the game. [import]uid: 82446 topic_id: 32868 reply_id: 131263[/import]

You can adjust the linear damping of the object to get more of an air drag effect on your physics bodies:

http://developer.coronalabs.com/reference/index/bodylineardamping

You can also play around with the scaling, density, and gravity. It just comes down to a lot of tweaking until it feels/looks right. [import]uid: 181948 topic_id: 32868 reply_id: 131266[/import]