NotePlayer in an if statement

I was wondering if there was an easy way to add a sound to an if statement. I want xojo to make a ding sound whenever my character touches the platform. Is there an easy way to do this?

thanks in advance

if player_touched_platform then 
Dim f As FolderItem = GetFolderItem("sounds").child("ding")
  Dim s As Sound = f.OpenAsSound
  If s <> Nil Then s.Play
End if

crude… but should give an idea

i tried that out just now but i cant hear any noise. this is the exact code i have with the stuff you told me to add.

    if + oval1.height < rectangle1(j).top + rectangle1(j).height and + oval1.height > rectangle1(j).top  and oval1.left >rectangle1(j).left  and oval1.left  < rectangle1(j).left + rectangle1(j).width and VelY > 0  then
      VelY = -25 =
      isJumping = false
Dim f As FolderItem = GetFolderItem("ding.wav")
      Dim s As Sound = f.OpenAsSound
      If s <> Nil Then s.Play

    end if

// is where the code you told me to add is, i was wondering if you could pinpoint what the problem is.
i have the soundfile in the folder i am using by the way

are you sure it is actually reaching the code?
and if so, if the folderitem legit (ie… not null, and exists)?
and that “S” is being loaded?

put breakpoints in to validate all that… and remember I said it was crude… not the best solution, just a direction to head…

also remember… GetFolderItem returns the app folder… which MAY NOT be what you think it is for running in the IDE

Add ding.wav to your project and in your code :

how do i add ding to my code, and it is also definitely seeing it

Drag the file and drop it over the CONTENTS left hand side of the IDE. It will then show as an item in the list.