display.newSprite / sound

Hi, 

you can insert a sound into a sprite?

function fnc1(sceneGroup) sheetData = {width=638, height=93, numFrames=7, sheetContentWidth=638, sheetContentHeight=651}; myImageSheet = graphics.newImageSheet("image/ima1.png", sheetData); sequenceData= { {name = "normalRun", start=2, count=6, time=3750, frames={2,3,4,5,6,7}, loopCount = 1}, } myNewSprite = display.newSprite(myImageSheet , sequenceData); myNewSprite.x, myNewSprite.y = 240, 225; myNewSprite:scale( 0.38, 0.35) sceneGroup:insert(myNewSprite); myNewSprite:play(); return fncR1 end

I have this function , and I need that for each frame heard a sound.

Thanks.

solved 

but that is not the solution it is looking good. 

snd1 = audio.loadSound("media/beep1.wav"); function fnc1(sceneGroup) sheetData = {width=638, height=93, numFrames=7, sheetContentWidth=638, sheetContentHeight=651}; myImageSheet = graphics.newImageSheet("image/ima1.png", sheetData); sequenceData= { {name = "normalRun", start=2, count=6, time=3750, frames={2,3,4,5,6,7}, loopCount = 1}, } myNewSprite = display.newSprite(myImageSheet , sequenceData); myNewSprite.x, myNewSprite.y = 240, 225; myNewSprite:scale( 0.38, 0.35) sceneGroup:insert(myNewSprite); myNewSprite:play();

audio.play(snd2)

timer.performWithDelay(715, function () audio.play(snd1); end, 5);
return fncR1 end

If you can do something else so I would appreciate it should say 

Use a sprite listener and use the events provided by it to play the sound.

Look in the corona docs regarding sprites and you will see the event listener guide.

Hi @catal.lluis,

Here is the doc hub page that Gremlin suggests. See the example code on the “event.phase” page for how to set up a sprite listener on a certain event in the animation.

http://docs.coronalabs.com/api/event/sprite/index.html

Take care,

Brent

solved 

but that is not the solution it is looking good. 

snd1 = audio.loadSound("media/beep1.wav"); function fnc1(sceneGroup) sheetData = {width=638, height=93, numFrames=7, sheetContentWidth=638, sheetContentHeight=651}; myImageSheet = graphics.newImageSheet("image/ima1.png", sheetData); sequenceData= { {name = "normalRun", start=2, count=6, time=3750, frames={2,3,4,5,6,7}, loopCount = 1}, } myNewSprite = display.newSprite(myImageSheet , sequenceData); myNewSprite.x, myNewSprite.y = 240, 225; myNewSprite:scale( 0.38, 0.35) sceneGroup:insert(myNewSprite); myNewSprite:play();

audio.play(snd2)

timer.performWithDelay(715, function () audio.play(snd1); end, 5);
return fncR1 end

If you can do something else so I would appreciate it should say 

Use a sprite listener and use the events provided by it to play the sound.

Look in the corona docs regarding sprites and you will see the event listener guide.

Hi @catal.lluis,

Here is the doc hub page that Gremlin suggests. See the example code on the “event.phase” page for how to set up a sprite listener on a certain event in the animation.

http://docs.coronalabs.com/api/event/sprite/index.html

Take care,

Brent