Discord
Login
Community
DARK THEME

Sound of effects

Hi, im new to coding here. im trying to make a sound effect ever type a player collides with a object. please review my code. my audio clip is named clip btw.

collision = function() h_dis = abs(player.x - diamond.x) v_dis = abs(player.y - diamond.y) if h_dis <= 23 and v_dis <= 23 then player.speed = player.speed + speedIncrement return true else return false end if h_dis <= 23 and v_dis <= 23 then return audio.play("clip",1,1) end

mp3 or wav?

collision = function() 
   h_dis = abs(player.x - diamond.x) 
   v_dis = abs(player.y - diamond.y) 
   if h_dis <= 23 and v_dis <= 23 then 
      player.speed = player.speed + speedIncrement 
      audio.play("clip",1,1)
      return true 
   else 
      return false 
   end 
end

return = exit the function immediately

Post a reply

Progress

Status

Preview
Cancel
Post
Validate your e-mail address to participate in the community