Register  |  FAQ  |  Search  |  Memberlist  |  Usergroups  |  Log in 
Reply to topic
 Looping Sounds (Custom Events). 
zeno00


Joined: 06 Apr 2009
Posts: 16
Reply with quote
So If I have single Audio file that I'd like to Hear it looping Only As long as I'm pressing down Up OR Down Arrow Keys
Simulating player's footsteps or Breath.
Thanks,


Last edited by zeno00 on Mon Apr 13, 2009 12:53 pm; edited 1 time in total
View user's profile Send private message
  
Vincent


Joined: 25 Dec 2006
Posts: 296
Reply with quote
Code:
local soundlen=1 -- assume the sound time length is 1 second
local lastsoundtime=0

function FrameMove()
   if GetAppTime()-lastsoundtime > soundlen then
      lastsoundtime=GetAppTime()
      PlaySound('swim')
   end
end


For keys pressing detection, you can see the wnd.IsKeyDown() function.
View user's profile Send private message
  
zeno00


Joined: 06 Apr 2009
Posts: 16
Reply with quote
Alright Thanks Very much Vincent,
And these techniques are applicable to control Some ambient sounds.
View user's profile Send private message
  
zeno00


Joined: 06 Apr 2009
Posts: 16
Reply with quote
Hey,
I've been trying to do wnd.IskeyDown() Function to apply sound loop when the Up key is pressed
So I Wrote at first line :
Code:
function wnd.IsVK_UPDown()

Then I listed the whole function with the lines above it In the Keybord input messages section But It didn't work

So Is this the Right syntax and should I list in the App flow section.
also Can this function be used IF the FrameMove() function was already devoted for different sound.
Thanks,
View user's profile Send private message
  
Vincent


Joined: 25 Dec 2006
Posts: 296
Reply with quote
you should use the function like this:

Code:
function FrameMove()
   if wnd.IsKeyDown(VK_UP) then
      if GetAppTime()-lastsoundtime > soundlen then
         lastsoundtime=GetAppTime()
         PlaySound('swim')
      end
   end
end
View user's profile Send private message
  
zeno00


Joined: 06 Apr 2009
Posts: 16
Reply with quote
Ok, Thanks Vincent It Works, But What if I wanted to trigger Another sound loop in the same scene Throw
An overlay usually when we Trigger it By an overlay it doesn't loop what can I do then to make it loop.
Thank You,
View user's profile Send private message
  
nigec


Joined: 04 Jul 2007
Posts: 212
Reply with quote
You can do timeline looped sound, use wav, create a shot that cycles and doesn't effect the camera..
thats the way I'd do it, but I don't need it hard wired into scripts
View user's profile Send private message
  
zeno00


Joined: 06 Apr 2009
Posts: 16
Reply with quote
Well thanks nigec but I really need know this Code ,
Also I'd like to know how can I assign the wnd.IsKeyDown() function to more keys
SO That it can triggered by More Than one key
how do we make that?
Thanks,
View user's profile Send private message
  
Vincent


Joined: 25 Dec 2006
Posts: 296
Reply with quote
You had better spend some time to learn LUA language first, then scripting. Smile
View user's profile Send private message
  
zeno00


Joined: 06 Apr 2009
Posts: 16
Reply with quote
Yes Vincent I'll Consider this Starting of today Thank you very much.
View user's profile Send private message
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT  
Page 1 of 1  

  
  
 Reply to topic