Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: Sounds!!!!!!!!!!!!!

                  
   
  1. #1
    DCEmu Coder PSPKOR's Avatar
    Join Date
    Apr 2006
    Location
    England
    Age
    36
    Posts
    184
    Rep Power
    70

    Default Sounds!!!!!!!!!!!!!

    OK I've been stuck with this all weekend with no luck, can some one tell me whats wrong with this bit of code:
    if playerMove == "no" and loopCount == 0 then
    tankidle:play()
    loopCount = loopCount + 1
    loopCount2 = 0
    tankdrive:stop()
    end
    if playerMove == "yes" and loopCount2 == 0 then
    tankdrive:play()
    loopCount2 = loopCount2 + 1
    loopCount = 0
    tankidle:stop()
    end

    Its playing .wav sounds and they are looped.

    I did also try doing another way of playing it using the
    local sound = filename
    voice = sound:play()

    but that didn't work very well, beacause every time I tried to stop one sound it was ok but if i tried stoping the other it just wouldn't work.

    So if someone could help me out here please.
    LEARN, MASTER and ACHIEVE!!
    'Bruce Lee'

  2. #2
    GP2X Coder/Moderator
    Join Date
    Jan 2006
    Posts
    1,678
    Rep Power
    87

    Default

    Wouldn't this be better in terms of logic flow?
    if playerMove == "no" and not tankidle:playing() then
    tankdrive:stop()
    tankidle:play()
    end

    if playerMove == "yes" and not tankdrive:playing() then
    tankidle:stop()
    tankdrive:play()
    end

  3. #3
    DCEmu Coder PSPKOR's Avatar
    Join Date
    Apr 2006
    Location
    England
    Age
    36
    Posts
    184
    Rep Power
    70

    Default

    Cheers i'll just try it.

    ---Edit---
    No, it just goes off like it did before. Any other ideas?
    LEARN, MASTER and ACHIEVE!!
    'Bruce Lee'

  4. #4
    GP2X Coder/Moderator
    Join Date
    Jan 2006
    Posts
    1,678
    Rep Power
    87

    Default

    Okay.. In that case, I need to know what it actually does and what you want it to do in as much detail as possible. How are you trying to stop both sounds?

  5. #5
    DCEmu Coder PSPKOR's Avatar
    Join Date
    Apr 2006
    Location
    England
    Age
    36
    Posts
    184
    Rep Power
    70

    Default

    Well its for a tank game that I'm making and I want it so that when the tanks moving it plays one sound and when its not moving it plays the other. But i also need it so it stops the other sound, or it sounds quite nasty. The sounds are also looped.

    At the moment I have this:

    if playerMove == "no" and loopCount == 0 then
    local sound = tankidle
    voice = sound:play()
    loopCount2 = 0
    loopCount = loopCount + 1
    end

    if voice:playing() and playerMove == "yes" then
    voice:stop()
    loopCount = 0
    end

    if playerMove == "yes" and loopCount2 == 0 then
    local sound = tankdrive
    noise = sound:play()
    loopCount2 = loopCount2 + 1
    end


    This plays the stoped sound fine eg starts and stops at the right time, but the driving sound just keeps playing. If I try to add the STOP() command it crashes.
    LEARN, MASTER and ACHIEVE!!
    'Bruce Lee'

  6. #6
    DCEmu Coder PSPKOR's Avatar
    Join Date
    Apr 2006
    Location
    England
    Age
    36
    Posts
    184
    Rep Power
    70

    Default

    That didn't work either.
    But yeah thats what I want i want it to do.
    "plays either the tankidle or tankdrive sound at one time"
    LEARN, MASTER and ACHIEVE!!
    'Bruce Lee'

  7. #7
    GP2X Coder/Moderator
    Join Date
    Jan 2006
    Posts
    1,678
    Rep Power
    87

    Default

    tankdriveVoice = tankdrive:play()
    tankdriveVoice:stop()
    tankidleVoice = tankidle:play()
    tankidleVoice:stop()

    while true do

    if playerMove == "no" and not tankidle:playing() then
    tankdriveVoice:stop()
    tankidleVoice = tankidle:play()
    end

    if playerMove == "yes" and not tankdrive:playing() then
    tankidleVoice :stop()
    tankdriveVoice = tankdrive:play()
    end
    end
    Completely untested.

  8. #8
    DCEmu Coder PSPKOR's Avatar
    Join Date
    Apr 2006
    Location
    England
    Age
    36
    Posts
    184
    Rep Power
    70

    Default

    Dont look like thats working, I'll try and fiddle about with it a minute.

    Do you have a PSP or Lua player on your PC?

    Nevermind here you go have a look at the code attached, this is the whole code for it so far.

    The sound stuff is under ------------drivin sounds------------.
    LEARN, MASTER and ACHIEVE!!
    'Bruce Lee'

  9. #9
    GP2X Coder/Moderator
    Join Date
    Jan 2006
    Posts
    1,678
    Rep Power
    87

    Default

    tankdriveVoice = tankdrive:play()
    tankdriveVoice:stop()
    tankidleVoice = tankidle:play()
    tankidleVoice:stop()

    while true do

    if playerMove == "no" and not tankidleVoice:playing() then
    tankdriveVoice:stop()
    tankidleVoice = tankidle:play()
    end

    if playerMove == "yes" and not tankdriveVoice:playing() then
    tankidleVoice :stop()
    tankdriveVoice = tankdrive:play()
    end
    end
    .

  10. #10
    DCEmu Coder PSPKOR's Avatar
    Join Date
    Apr 2006
    Location
    England
    Age
    36
    Posts
    184
    Rep Power
    70

    Default

    Well it runs this time but it only plays the idle sound.

    PS - look at my post above.
    LEARN, MASTER and ACHIEVE!!
    'Bruce Lee'

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •