|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JLabel
com.threecoffee.anim.Sprite
public class Sprite
Simple class to represent an image or a simple animation consisting of a group of images.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class javax.swing.JComponent |
---|
javax.swing.JComponent.AccessibleJComponent |
Nested classes/interfaces inherited from class java.awt.Component |
---|
java.awt.Component.BaselineResizeBehavior |
Field Summary |
---|
Fields inherited from class javax.swing.JComponent |
---|
TOOL_TIP_TEXT_KEY, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
Fields inherited from class java.awt.Component |
---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface javax.swing.SwingConstants |
---|
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST |
Fields inherited from interface java.awt.image.ImageObserver |
---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
---|---|
Sprite()
Creates a new animated sprite with no image |
|
Sprite(Animation anim)
Creates a new Sprite from the given Animation |
Method Summary | |
---|---|
void |
addCollider(Sprite s)
Checks for collision with the given Sprite, and calls the collided(Sprite) method of BOTH THE SPRITES if collision is detected. |
void |
addImage(javax.swing.ImageIcon ico)
Adds a new image to the sprite. |
void |
addTo(GameWindow gaw)
Add this Sprite to the given GameWindow. |
void |
checkCollisions()
Used by the system to check if this Sprite has collided with a collider Object. |
void |
collided(Sprite s)
Called whenever this Sprite collides with another Sprite. |
Animation |
getAnimation()
Returns the Animation Object that this Sprite displays |
java.util.Vector<Sprite> |
getColliders()
Returns all the Sprites that this Sprite can collide with. |
javax.swing.ImageIcon |
getCurrentImage()
Returns the ImageIcon being displayed by the Sprite. |
int |
getCurrentSpriteIndex()
Returns the index of the image being displayed currently by this sprite |
long |
getDelay()
Returns the time in milliseconds between two successive frames. |
GameWindow |
getGameWindow()
Returns the GameWindow that this Sprite is attached to. |
Gravity |
getGravity()
Returns the Gravity object acting on the Sprite. |
java.util.Vector<javax.swing.ImageIcon> |
getImages()
Returns all the images that this sprite contains. |
java.lang.String |
getName()
Returns the name of this Sprite. |
java.awt.Point |
getPreviousLocation()
Returns the previous location of the sprite. |
boolean |
hasGravity()
Returns whether the Sprite is affected by Gravity. |
boolean |
hasPoint(int x,
int y)
Returns true if the Sprite contains the given location on the screen. |
boolean |
hasPoint(java.awt.Point p)
Returns true if the Sprite contains the given location on the screen. |
void |
init()
Called by the system when the play() method is called, just before the Sprite starts playing. |
boolean |
inView()
Returns true if the Sprite is being displayed on the screen. |
boolean |
isPaused()
Returns true if the Sprite is paused. |
void |
moveSprite(int x,
int y)
Moves the sprite x pixels to the right, and y pixels down. |
void |
pause(boolean b)
Use this method to pause/resume the Sprite. |
void |
play()
Call this method to start displaying the Sprite on the screen. |
void |
run()
Used by the system internally. |
void |
setCurrentImage(javax.swing.ImageIcon ico)
Sets the image being displayed to the given image. |
void |
setCurrentSpriteIndex(int i)
Sets the image being displayed to the image at the given index. |
void |
setDelay(long l)
Sets the time in milliseconds between two consecutive frames. |
void |
setGravity(boolean b)
Adds/Removes gravity to/from the Sprite. |
void |
setGravity(Gravity g1)
Sets the given Gravity object as this Sprite's default Gravity. |
void |
setImages(java.util.Vector<javax.swing.ImageIcon> i)
Sets the given images as the ones that this Sprite displays. |
void |
setName(java.lang.String n)
Sets the name of this Sprite to the given string. |
void |
stop()
Stops playing the current Sprite. |
void |
undo()
Forces the Sprite to go back to it's previous location. |
void |
update()
This method is called again and again unless the Sprite is paused or stopped. |
Methods inherited from class javax.swing.JLabel |
---|
getAccessibleContext, getDisabledIcon, getDisplayedMnemonic, getDisplayedMnemonicIndex, getHorizontalAlignment, getHorizontalTextPosition, getIcon, getIconTextGap, getLabelFor, getText, getUI, getUIClassID, getVerticalAlignment, getVerticalTextPosition, imageUpdate, setDisabledIcon, setDisplayedMnemonic, setDisplayedMnemonic, setDisplayedMnemonicIndex, setHorizontalAlignment, setHorizontalTextPosition, setIcon, setIconTextGap, setLabelFor, setText, setUI, setVerticalAlignment, setVerticalTextPosition, updateUI |
Methods inherited from class javax.swing.JComponent |
---|
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update |
Methods inherited from class java.awt.Container |
---|
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate |
Methods inherited from class java.awt.Component |
---|
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Sprite()
public Sprite(Animation anim)
Method Detail |
---|
public Animation getAnimation()
public void setName(java.lang.String n)
setName
in class java.awt.Component
public java.lang.String getName()
getName
in class java.awt.Component
public void addImage(javax.swing.ImageIcon ico)
public java.util.Vector<javax.swing.ImageIcon> getImages()
public void setImages(java.util.Vector<javax.swing.ImageIcon> i)
public void addCollider(Sprite s)
public java.util.Vector<Sprite> getColliders()
public void setDelay(long l)
public long getDelay()
public void setCurrentImage(javax.swing.ImageIcon ico)
public javax.swing.ImageIcon getCurrentImage()
public void setCurrentSpriteIndex(int i)
public int getCurrentSpriteIndex()
public void setGravity(boolean b)
public void setGravity(Gravity g1)
public boolean hasGravity()
public Gravity getGravity()
public boolean inView()
public java.awt.Point getPreviousLocation()
public void run()
run
in interface java.lang.Runnable
public void checkCollisions()
public boolean hasPoint(int x, int y)
public boolean hasPoint(java.awt.Point p)
public void undo()
public void play()
public void init()
public void update()
public void pause(boolean b)
public boolean isPaused()
public void moveSprite(int x, int y)
public void collided(Sprite s)
public void stop()
public void addTo(GameWindow gaw)
public GameWindow getGameWindow()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |