Main repository of MikuMikuStudio
修订版 | be629edb491804f55340ee3c22e08a2111c21b0e (tree) |
---|---|
时间 | 2003-10-30 04:07:12 |
作者 | Anakan <Anakan@75d0...> |
Commiter | Anakan |
Sound actions
git-svn-id: http://jmonkeyengine.googlecode.com/svn/trunk@139 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
@@ -0,0 +1,71 @@ | ||
1 | +/* | |
2 | + * Copyright (c) 2003, jMonkeyEngine - Mojo Monkey Coding | |
3 | + * All rights reserved. | |
4 | + * | |
5 | + * Redistribution and use in source and binary forms, with or without | |
6 | + * modification, are permitted provided that the following conditions are met: | |
7 | + * | |
8 | + * Redistributions of source code must retain the above copyright notice, this | |
9 | + * list of conditions and the following disclaimer. | |
10 | + * | |
11 | + * Redistributions in binary form must reproduce the above copyright notice, | |
12 | + * this list of conditions and the following disclaimer in the documentation | |
13 | + * and/or other materials provided with the distribution. | |
14 | + * | |
15 | + * Neither the name of the Mojo Monkey Coding, jME, jMonkey Engine, nor the | |
16 | + * names of its contributors may be used to endorse or promote products derived | |
17 | + * from this software without specific prior written permission. | |
18 | + * | |
19 | + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |
20 | + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
21 | + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
22 | + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | |
23 | + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
24 | + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
25 | + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
26 | + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
27 | + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
28 | + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
29 | + * POSSIBILITY OF SUCH DAMAGE. | |
30 | + * | |
31 | + */ | |
32 | + | |
33 | +/* | |
34 | + * Created on 29 oct. 2003 | |
35 | + * | |
36 | + */ | |
37 | +package com.jme.sound.action; | |
38 | + | |
39 | +import com.jme.input.action.KeyBackwardAction; | |
40 | +import com.jme.renderer.Camera; | |
41 | +import com.jme.sound.SoundSource; | |
42 | + | |
43 | +/** | |
44 | + * @author Arman Ozcelik | |
45 | + * | |
46 | + */ | |
47 | +public class SoundBackwardAction extends KeyBackwardAction { | |
48 | + | |
49 | + private String sound; | |
50 | + private SoundSource player; | |
51 | + | |
52 | + /** | |
53 | + * @param camera | |
54 | + * @param speed | |
55 | + */ | |
56 | + public SoundBackwardAction(Camera camera, float speed, SoundSource soundPlayer, String soundName) { | |
57 | + super(camera, speed); | |
58 | + player = soundPlayer; | |
59 | + sound = soundName; | |
60 | + } | |
61 | + | |
62 | + /** | |
63 | + * @see com.jme.input.action.InputAction#performAction(float) | |
64 | + */ | |
65 | + public void performAction(float time) { | |
66 | + super.performAction(time); | |
67 | + if (player != null && !player.isPlaying()) { | |
68 | + player.play(sound); | |
69 | + } | |
70 | + } | |
71 | +} |
@@ -0,0 +1,72 @@ | ||
1 | +/* | |
2 | + * Copyright (c) 2003, jMonkeyEngine - Mojo Monkey Coding | |
3 | + * All rights reserved. | |
4 | + * | |
5 | + * Redistribution and use in source and binary forms, with or without | |
6 | + * modification, are permitted provided that the following conditions are met: | |
7 | + * | |
8 | + * Redistributions of source code must retain the above copyright notice, this | |
9 | + * list of conditions and the following disclaimer. | |
10 | + * | |
11 | + * Redistributions in binary form must reproduce the above copyright notice, | |
12 | + * this list of conditions and the following disclaimer in the documentation | |
13 | + * and/or other materials provided with the distribution. | |
14 | + * | |
15 | + * Neither the name of the Mojo Monkey Coding, jME, jMonkey Engine, nor the | |
16 | + * names of its contributors may be used to endorse or promote products derived | |
17 | + * from this software without specific prior written permission. | |
18 | + * | |
19 | + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |
20 | + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
21 | + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
22 | + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | |
23 | + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
24 | + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
25 | + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
26 | + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
27 | + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
28 | + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
29 | + * POSSIBILITY OF SUCH DAMAGE. | |
30 | + * | |
31 | + */ | |
32 | + | |
33 | +/* | |
34 | + * Created on 29 oct. 2003 | |
35 | + * | |
36 | + */ | |
37 | +package com.jme.sound.action; | |
38 | + | |
39 | +import com.jme.input.action.KeyForwardAction; | |
40 | +import com.jme.renderer.Camera; | |
41 | +import com.jme.sound.SoundSource; | |
42 | + | |
43 | +/** | |
44 | + * @author Arman Ozcelik | |
45 | + * | |
46 | + */ | |
47 | +public class SoundForwardAction extends KeyForwardAction { | |
48 | + | |
49 | + private SoundSource player; | |
50 | + private String sound; | |
51 | + | |
52 | + /** | |
53 | + * @param camera | |
54 | + * @param speed | |
55 | + */ | |
56 | + public SoundForwardAction(Camera camera, float speed, SoundSource soundPlayer, String soundName) { | |
57 | + super(camera, speed); | |
58 | + player = soundPlayer; | |
59 | + sound = soundName; | |
60 | + } | |
61 | + | |
62 | + /** | |
63 | + * @see com.jme.input.action.InputAction#performAction(float) | |
64 | + */ | |
65 | + public void performAction(float time) { | |
66 | + super.performAction(time); | |
67 | + if (player != null && !player.isPlaying()) { | |
68 | + player.play(sound); | |
69 | + } | |
70 | + } | |
71 | + | |
72 | +} |
@@ -0,0 +1,70 @@ | ||
1 | +/* | |
2 | + * Copyright (c) 2003, jMonkeyEngine - Mojo Monkey Coding | |
3 | + * All rights reserved. | |
4 | + * | |
5 | + * Redistribution and use in source and binary forms, with or without | |
6 | + * modification, are permitted provided that the following conditions are met: | |
7 | + * | |
8 | + * Redistributions of source code must retain the above copyright notice, this | |
9 | + * list of conditions and the following disclaimer. | |
10 | + * | |
11 | + * Redistributions in binary form must reproduce the above copyright notice, | |
12 | + * this list of conditions and the following disclaimer in the documentation | |
13 | + * and/or other materials provided with the distribution. | |
14 | + * | |
15 | + * Neither the name of the Mojo Monkey Coding, jME, jMonkey Engine, nor the | |
16 | + * names of its contributors may be used to endorse or promote products derived | |
17 | + * from this software without specific prior written permission. | |
18 | + * | |
19 | + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |
20 | + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
21 | + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
22 | + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | |
23 | + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
24 | + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
25 | + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
26 | + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
27 | + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
28 | + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
29 | + * POSSIBILITY OF SUCH DAMAGE. | |
30 | + * | |
31 | + */ | |
32 | + | |
33 | +/* | |
34 | + * Created on 29 oct. 2003 | |
35 | + * | |
36 | + */ | |
37 | +package com.jme.sound.action; | |
38 | + | |
39 | +import com.jme.input.action.KeyLookDownAction; | |
40 | +import com.jme.renderer.Camera; | |
41 | +import com.jme.sound.SoundSource; | |
42 | + | |
43 | +/** | |
44 | + * @author Arman Ozcelik | |
45 | + * | |
46 | + */ | |
47 | +public class SoundLookDownAction extends KeyLookDownAction { | |
48 | + | |
49 | + private String sound; | |
50 | + private SoundSource player; | |
51 | + /** | |
52 | + * @param camera | |
53 | + * @param speed | |
54 | + */ | |
55 | + public SoundLookDownAction(Camera camera, float speed, SoundSource soundPlayer, String soundName) { | |
56 | + super(camera, speed); | |
57 | + player = soundPlayer; | |
58 | + sound = soundName; | |
59 | + } | |
60 | + | |
61 | + /** | |
62 | + * @see com.jme.input.action.InputAction#performAction(float) | |
63 | + */ | |
64 | + public void performAction(float time) { | |
65 | + super.performAction(time); | |
66 | + if (player != null && !player.isPlaying()) { | |
67 | + player.play(sound); | |
68 | + } | |
69 | + } | |
70 | +} |
@@ -0,0 +1,70 @@ | ||
1 | +/* | |
2 | + * Copyright (c) 2003, jMonkeyEngine - Mojo Monkey Coding | |
3 | + * All rights reserved. | |
4 | + * | |
5 | + * Redistribution and use in source and binary forms, with or without | |
6 | + * modification, are permitted provided that the following conditions are met: | |
7 | + * | |
8 | + * Redistributions of source code must retain the above copyright notice, this | |
9 | + * list of conditions and the following disclaimer. | |
10 | + * | |
11 | + * Redistributions in binary form must reproduce the above copyright notice, | |
12 | + * this list of conditions and the following disclaimer in the documentation | |
13 | + * and/or other materials provided with the distribution. | |
14 | + * | |
15 | + * Neither the name of the Mojo Monkey Coding, jME, jMonkey Engine, nor the | |
16 | + * names of its contributors may be used to endorse or promote products derived | |
17 | + * from this software without specific prior written permission. | |
18 | + * | |
19 | + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |
20 | + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
21 | + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
22 | + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | |
23 | + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
24 | + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
25 | + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
26 | + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
27 | + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
28 | + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
29 | + * POSSIBILITY OF SUCH DAMAGE. | |
30 | + * | |
31 | + */ | |
32 | + | |
33 | +/* | |
34 | + * Created on 29 oct. 2003 | |
35 | + * | |
36 | + */ | |
37 | +package com.jme.sound.action; | |
38 | + | |
39 | +import com.jme.input.action.KeyLookUpAction; | |
40 | +import com.jme.renderer.Camera; | |
41 | +import com.jme.sound.SoundSource; | |
42 | + | |
43 | +/** | |
44 | + * @author Arman Ozcelik | |
45 | + * | |
46 | + */ | |
47 | +public class SoundLookUpAction extends KeyLookUpAction { | |
48 | + | |
49 | + private String sound; | |
50 | + private SoundSource player; | |
51 | + /** | |
52 | + * @param camera | |
53 | + * @param speed | |
54 | + */ | |
55 | + public SoundLookUpAction(Camera camera, float speed, SoundSource soundPlayer, String soundName) { | |
56 | + super(camera, speed); | |
57 | + player = soundPlayer; | |
58 | + sound = soundName; | |
59 | + } | |
60 | + | |
61 | + /** | |
62 | + * @see com.jme.input.action.InputAction#performAction(float) | |
63 | + */ | |
64 | + public void performAction(float time) { | |
65 | + super.performAction(time); | |
66 | + if (player != null && !player.isPlaying()) { | |
67 | + player.play(sound); | |
68 | + } | |
69 | + } | |
70 | +} |
@@ -0,0 +1,70 @@ | ||
1 | +/* | |
2 | + * Copyright (c) 2003, jMonkeyEngine - Mojo Monkey Coding | |
3 | + * All rights reserved. | |
4 | + * | |
5 | + * Redistribution and use in source and binary forms, with or without | |
6 | + * modification, are permitted provided that the following conditions are met: | |
7 | + * | |
8 | + * Redistributions of source code must retain the above copyright notice, this | |
9 | + * list of conditions and the following disclaimer. | |
10 | + * | |
11 | + * Redistributions in binary form must reproduce the above copyright notice, | |
12 | + * this list of conditions and the following disclaimer in the documentation | |
13 | + * and/or other materials provided with the distribution. | |
14 | + * | |
15 | + * Neither the name of the Mojo Monkey Coding, jME, jMonkey Engine, nor the | |
16 | + * names of its contributors may be used to endorse or promote products derived | |
17 | + * from this software without specific prior written permission. | |
18 | + * | |
19 | + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |
20 | + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
21 | + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
22 | + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | |
23 | + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
24 | + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
25 | + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
26 | + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
27 | + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
28 | + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
29 | + * POSSIBILITY OF SUCH DAMAGE. | |
30 | + * | |
31 | + */ | |
32 | + | |
33 | +/* | |
34 | + * Created on 29 oct. 2003 | |
35 | + * | |
36 | + */ | |
37 | +package com.jme.sound.action; | |
38 | + | |
39 | +import com.jme.input.action.KeyRotateLeftAction; | |
40 | +import com.jme.renderer.Camera; | |
41 | +import com.jme.sound.SoundSource; | |
42 | + | |
43 | +/** | |
44 | + * @author Arman Ozcelik | |
45 | + * | |
46 | + */ | |
47 | +public class SoundRotateLeftAction extends KeyRotateLeftAction { | |
48 | + | |
49 | + private String sound; | |
50 | + private SoundSource player; | |
51 | + /** | |
52 | + * @param camera | |
53 | + * @param speed | |
54 | + */ | |
55 | + public SoundRotateLeftAction(Camera camera, float speed, SoundSource soundPlayer, String soundName) { | |
56 | + super(camera, speed); | |
57 | + player = soundPlayer; | |
58 | + sound = soundName; | |
59 | + } | |
60 | + | |
61 | + /** | |
62 | + * @see com.jme.input.action.InputAction#performAction(float) | |
63 | + */ | |
64 | + public void performAction(float time) { | |
65 | + super.performAction(time); | |
66 | + if (player != null && !player.isPlaying()) { | |
67 | + player.play(sound); | |
68 | + } | |
69 | + } | |
70 | +} |
@@ -0,0 +1,69 @@ | ||
1 | +/* | |
2 | + * Copyright (c) 2003, jMonkeyEngine - Mojo Monkey Coding | |
3 | + * All rights reserved. | |
4 | + * | |
5 | + * Redistribution and use in source and binary forms, with or without | |
6 | + * modification, are permitted provided that the following conditions are met: | |
7 | + * | |
8 | + * Redistributions of source code must retain the above copyright notice, this | |
9 | + * list of conditions and the following disclaimer. | |
10 | + * | |
11 | + * Redistributions in binary form must reproduce the above copyright notice, | |
12 | + * this list of conditions and the following disclaimer in the documentation | |
13 | + * and/or other materials provided with the distribution. | |
14 | + * | |
15 | + * Neither the name of the Mojo Monkey Coding, jME, jMonkey Engine, nor the | |
16 | + * names of its contributors may be used to endorse or promote products derived | |
17 | + * from this software without specific prior written permission. | |
18 | + * | |
19 | + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |
20 | + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
21 | + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
22 | + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | |
23 | + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
24 | + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
25 | + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
26 | + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
27 | + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
28 | + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
29 | + * POSSIBILITY OF SUCH DAMAGE. | |
30 | + * | |
31 | + */ | |
32 | + | |
33 | +/* | |
34 | + * Created on 29 oct. 2003 | |
35 | + * | |
36 | + */ | |
37 | +package com.jme.sound.action; | |
38 | + | |
39 | +import com.jme.input.action.KeyRotateRightAction; | |
40 | +import com.jme.renderer.Camera; | |
41 | +import com.jme.sound.SoundSource; | |
42 | + | |
43 | +/** | |
44 | + * @author Arman Ozcelik | |
45 | + * | |
46 | + */ | |
47 | +public class SoundRotateRightAction extends KeyRotateRightAction { | |
48 | + private String sound; | |
49 | + private SoundSource player; | |
50 | + /** | |
51 | + * @param camera | |
52 | + * @param speed | |
53 | + */ | |
54 | + public SoundRotateRightAction(Camera camera, float speed, SoundSource soundPlayer, String soundName) { | |
55 | + super(camera, speed); | |
56 | + player = soundPlayer; | |
57 | + sound = soundName; | |
58 | + } | |
59 | + | |
60 | + /** | |
61 | + * @see com.jme.input.action.InputAction#performAction(float) | |
62 | + */ | |
63 | + public void performAction(float time) { | |
64 | + super.performAction(time); | |
65 | + if (player != null && !player.isPlaying()) { | |
66 | + player.play(sound); | |
67 | + } | |
68 | + } | |
69 | + } |
@@ -0,0 +1,69 @@ | ||
1 | +/* | |
2 | + * Copyright (c) 2003, jMonkeyEngine - Mojo Monkey Coding | |
3 | + * All rights reserved. | |
4 | + * | |
5 | + * Redistribution and use in source and binary forms, with or without | |
6 | + * modification, are permitted provided that the following conditions are met: | |
7 | + * | |
8 | + * Redistributions of source code must retain the above copyright notice, this | |
9 | + * list of conditions and the following disclaimer. | |
10 | + * | |
11 | + * Redistributions in binary form must reproduce the above copyright notice, | |
12 | + * this list of conditions and the following disclaimer in the documentation | |
13 | + * and/or other materials provided with the distribution. | |
14 | + * | |
15 | + * Neither the name of the Mojo Monkey Coding, jME, jMonkey Engine, nor the | |
16 | + * names of its contributors may be used to endorse or promote products derived | |
17 | + * from this software without specific prior written permission. | |
18 | + * | |
19 | + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |
20 | + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
21 | + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
22 | + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | |
23 | + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
24 | + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
25 | + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
26 | + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
27 | + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
28 | + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
29 | + * POSSIBILITY OF SUCH DAMAGE. | |
30 | + * | |
31 | + */ | |
32 | + | |
33 | +/* | |
34 | + * Created on 29 oct. 2003 | |
35 | + * | |
36 | + */ | |
37 | +package com.jme.sound.action; | |
38 | + | |
39 | +import com.jme.input.action.KeyStrafeLeftAction; | |
40 | +import com.jme.renderer.Camera; | |
41 | +import com.jme.sound.SoundSource; | |
42 | + | |
43 | +/** | |
44 | + * @author Arman Ozcelik | |
45 | + * | |
46 | + */ | |
47 | +public class SoundStrafeLeftAction extends KeyStrafeLeftAction { | |
48 | + private String sound; | |
49 | + private SoundSource player; | |
50 | + /** | |
51 | + * @param camera | |
52 | + * @param speed | |
53 | + */ | |
54 | + public SoundStrafeLeftAction(Camera camera, float speed, SoundSource soundPlayer, String soundName) { | |
55 | + super(camera, speed); | |
56 | + player = soundPlayer; | |
57 | + sound = soundName; | |
58 | + } | |
59 | + | |
60 | + /** | |
61 | + * @see com.jme.input.action.InputAction#performAction(float) | |
62 | + */ | |
63 | + public void performAction(float time) { | |
64 | + super.performAction(time); | |
65 | + if (player != null && !player.isPlaying()) { | |
66 | + player.play(sound); | |
67 | + } | |
68 | + } | |
69 | +} |
@@ -0,0 +1,70 @@ | ||
1 | +/* | |
2 | + * Copyright (c) 2003, jMonkeyEngine - Mojo Monkey Coding | |
3 | + * All rights reserved. | |
4 | + * | |
5 | + * Redistribution and use in source and binary forms, with or without | |
6 | + * modification, are permitted provided that the following conditions are met: | |
7 | + * | |
8 | + * Redistributions of source code must retain the above copyright notice, this | |
9 | + * list of conditions and the following disclaimer. | |
10 | + * | |
11 | + * Redistributions in binary form must reproduce the above copyright notice, | |
12 | + * this list of conditions and the following disclaimer in the documentation | |
13 | + * and/or other materials provided with the distribution. | |
14 | + * | |
15 | + * Neither the name of the Mojo Monkey Coding, jME, jMonkey Engine, nor the | |
16 | + * names of its contributors may be used to endorse or promote products derived | |
17 | + * from this software without specific prior written permission. | |
18 | + * | |
19 | + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |
20 | + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
21 | + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
22 | + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | |
23 | + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
24 | + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
25 | + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
26 | + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
27 | + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
28 | + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
29 | + * POSSIBILITY OF SUCH DAMAGE. | |
30 | + * | |
31 | + */ | |
32 | + | |
33 | +/* | |
34 | + * Created on 29 oct. 2003 | |
35 | + * | |
36 | + */ | |
37 | +package com.jme.sound.action; | |
38 | + | |
39 | +import com.jme.input.action.KeyStrafeRightAction; | |
40 | +import com.jme.renderer.Camera; | |
41 | +import com.jme.sound.SoundSource; | |
42 | + | |
43 | +/** | |
44 | + * @author Arman Ozcelik | |
45 | + * | |
46 | + */ | |
47 | +public class SoundStrafeRightAction extends KeyStrafeRightAction { | |
48 | + | |
49 | + private String sound; | |
50 | + private SoundSource player; | |
51 | + /** | |
52 | + * @param camera | |
53 | + * @param speed | |
54 | + */ | |
55 | + public SoundStrafeRightAction(Camera camera, float speed, SoundSource soundPlayer, String soundName) { | |
56 | + super(camera, speed); | |
57 | + player = soundPlayer; | |
58 | + sound = soundName; | |
59 | + } | |
60 | + | |
61 | + /** | |
62 | + * @see com.jme.input.action.InputAction#performAction(float) | |
63 | + */ | |
64 | + public void performAction(float time) { | |
65 | + super.performAction(time); | |
66 | + if (player != null && !player.isPlaying()) { | |
67 | + player.play(sound); | |
68 | + } | |
69 | + } | |
70 | +} |