I am new to corona and have a little experience with programming. I am currently fiddling around with the asteroid like tutorial game. In this game it creates new asteroid at a random location and sets it on a random path (within specific bounds) using the code below:
if ( whereFrom == 1 ) then -- From the left newAsteroid.x = -60 newAsteroid.y = math.random( 500 ) newAsteroid:setLinearVelocity( math.random( 40,120 ), math.random( 20,60 ) ) elseif ( whereFrom == 2 ) then -- From the top newAsteroid.x = math.random( display.contentWidth ) newAsteroid.y = -60 newAsteroid:setLinearVelocity( math.random( -40,40 ), math.random( 40,120 ) ) elseif ( whereFrom == 3 ) then -- From the right newAsteroid.x = display.contentWidth + 60 newAsteroid.y = math.random( 500 ) newAsteroid:setLinearVelocity( math.random( -120,-40 ), math.random( 20,60 ) ) end
I am trying to use the (newAsteroid.rotation =) and set it to the specific angle of travel so that the images face the direction of travel. I am having trouble figuring out how to change the x/y coordinates of the setLinearVelocity into an angle to use for the newAsteroid.rotation.
Please help! Thanks ahead of time!