Hello everyone,
i am again here…with my silly question but yeah you are so amazing that i always comes to your for help after google…
But this time i want to know that how do i make my sound played when ever my ball collides with bridge…The ball will not explode it just fall down colliding from bridge and i want that
-
When ever ball touches the bridge and the bottom(named as button) it playes a sound named as “wave.wav”
-
I touch the ball and it produces the same sound
i want two codes both in easy language…and for better understanding here is my code…
display.setStatusBar (display.HiddenStatusBar) local centerX = display.contentCenterX local centerY = display.contentCenterY local popsound = audio.loadSound("wave.wav") local background = display.newImageRect("background.jpg" , 320 , 570) background.x= centerX background.y= centerY local bridge = display.newImageRect("bridge.png" , 120,50) bridge.x = 240 bridge.y = 20 bridge.rotation=-10 local bridge2 = display.newImageRect("bridge.png" , 120 , 50) bridge2.x = 80 bridge2.y = 120 bridge2.rotation = 30 local bridge3 = display.newImageRect("bridge.png" , 120 , 50) bridge3.x = 240 bridge3.y = 210 bridge3.rotation = -30 local bridge4 = display.newImageRect("bridge.png" , 120 , 50) bridge4.x = 70 bridge4.y = 310 bridge4.rotation = 30 local bridge5 = display.newImageRect("bridge.png" , 120 , 50) bridge5.x = 240 bridge5.y = 380 bridge5.rotation = -30 local button = display.newImageRect("button.png" ,325 , 40 ) button.x = centerX button. y = 500 local redball = display.newImageRect("redball.gif" , 50 , 50) redball.x=280 redball.y= - 100 local physics = require "physics" physics.start() physics.addBody(redball , "dynamic") physics.addBody(button , "static") physics.addBody(bridge , "static") physics.addBody(bridge2 , "static") physics.addBody(bridge3 , "static") physics.addBody(bridge4 , "static") physics.addBody(bridge5 , "static") local function redball (event) if (event.phase == "ended") then local popsound = audio.loadSound("wave.wav") audio.play(popsound) end end Runtime:addEventListener("touch" , redball)
THANK YOU IN ADVANCE
YOU ARE AWESOME