Russell Posted March 4, 2020 Share Posted March 4, 2020 Hi there team!! I'm working in ZOOM system for my game. When i press down the Right button of the mouse, we make ZOOM and the game plays a sound with this code: Load sounds: --Aquí cargamos los sonidos que necesitaremos: self.sound.zoomin=Sound:Load("Sound/MisSonidos/ZOOMCamara/ZoomIN.wav") self.sound.zoomout=Sound:Load("Sound/MisSonidos/ZOOMCamara/ZoomOUT.wav") Use loaded sounds: --Hacemos ZOOM al pulsar el boton derecho if window:MouseHit(Key.RButton) then if self.sound.zoomin~=nil then self.sound.zoomin:Play() end end if window:MouseDown(Key.RButton) then self.camera:SetFOV(20) self.camera:SetRange(0.05,1000) else self.camera:SetFOV(70) self.camera:SetRange(0.05,1000) end This works ok, but I don't know how play a sound ONCE when we release the Right button of the mouse. Any tip that can help me? Thank you very much!! Quote Link to comment Share on other sites More sharing options...
Russell Posted March 5, 2020 Author Share Posted March 5, 2020 Finally!!! Nevermind team... Finally I got it!! I have used a simple variable to achieve this. This is my code that finally works with SOUND playing ONCE on ZOOM IN and SOUND playing ONCE on ZOOM OUT: local ZoomActivo=false if window:MouseDown(Key.RButton) then self.camera:SetFOV(20) self.camera:SetRange(0.05,1000) else if self.sound.zoomout~=nil and ZoomActivo==true then self.sound.zoomout:Play() ZoomActivo=false end self.camera:SetFOV(70) self.camera:SetRange(0.05,1000) end if window:MouseHit(Key.RButton) then if self.sound.zoomin~=nil then self.sound.zoomin:Play() end ZoomActivo=true end ???? 1 Quote Link to comment Share on other sites More sharing options...
DooMAGE Posted March 6, 2020 Share Posted March 6, 2020 Would be nice to have a native function like OnMouseKeyUp and OnKeyUp on the engine. Maybe in LE5? Quote My Leadwerks games! https://ragingmages.itch.io/ Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.