|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectsprite.Sprite
sprite.spritesound.SoundSprite
public class SoundSprite
Created on November 20, 2006, 5:14 PM
Creates a sound sprite which can load and play sound files.
To preserve the line of inheritance, updateSprite may also be used to play the sound file.
Based on ClipInfo.java from "Killer Game Programming in Java."
| Field Summary |
|---|
| Fields inherited from class sprite.Sprite |
|---|
active, visible |
| Constructor Summary | |
|---|---|
SoundSprite()
Creates a new instance of SoundSprite |
|
| Method Summary | |
|---|---|
void |
close()
Closes the sound clip. |
javax.sound.sampled.Clip |
getClip()
Gets the clip. |
java.text.DecimalFormat |
getDf()
Gets the demical format of the clip. |
java.lang.String |
getFileName()
Gets the file name. |
boolean |
isIsLooping()
The looping state. |
boolean |
isIsPlaying()
The current play state of the sound clip. |
void |
loadClip()
Loads the sound clip from the specified fileName. |
void |
paintSprite(java.awt.Graphics2D g)
Paints the sprite. Sound sprite has an empty paintSprite method since there is nothing to paint. |
void |
pause()
Pause the sound slip. |
void |
play()
plays the sound clip. |
void |
resume()
Resumes the sound clip. |
void |
setClip(javax.sound.sampled.Clip clip)
Sets the clip. |
void |
setDf(java.text.DecimalFormat df)
Sets the decimal format. |
void |
setFileName(java.lang.String fileName)
Sets the file name. |
void |
setIsLooping(boolean isLooping)
Sets the loop state. |
void |
setIsPlaying(boolean isPlaying)
Set the current playing state. |
void |
stop()
stops the sound clip. |
void |
update(javax.sound.sampled.LineEvent le)
Handles the update for the line event. |
void |
updateSprite(java.awt.Component c)
Updates the sprite. In the case of soundSprite, this plays the sound. |
| Methods inherited from class sprite.Sprite |
|---|
addPropertyChangeListener, getPropertySupport, isActive, isVisible, removePropertyChangeListener, restore, setActive, setVisible, suspend |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public SoundSprite()
| Method Detail |
|---|
public void updateSprite(java.awt.Component c)
updateSprite in class Spritec - The component that contains this sprite.public void paintSprite(java.awt.Graphics2D g)
paintSprite in class Spriteg - the graphics used for painting.public java.lang.String getFileName()
public void setFileName(java.lang.String fileName)
fileName - The new file name.public javax.sound.sampled.Clip getClip()
public void setClip(javax.sound.sampled.Clip clip)
clip - The new sound clip.public boolean isIsLooping()
public void setIsLooping(boolean isLooping)
isLooping - The new loop state.public java.text.DecimalFormat getDf()
public void setDf(java.text.DecimalFormat df)
df - The new decimal format.public void loadClip()
public void update(javax.sound.sampled.LineEvent le)
update in interface javax.sound.sampled.LineListenerle - The line event that triggered the update.public void close()
public void play()
public void stop()
public void pause()
public void resume()
public boolean isIsPlaying()
public void setIsPlaying(boolean isPlaying)
isPlaying - The new playing state of the sound. True if playing, false if not.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||