Class anim.Sprite
All Packages Class Hierarchy This Package Previous Next Index
Class anim.Sprite
java.lang.Object
|
+----anim.Sprite
- public class Sprite
- extends Object
An abstract class to define a sprite object.
Copyright (c) 1996-1997 Intel Corporation
- See Also:
- DynamicDataSprite, StaticDataSprite
-
Sprite()
-
-
adjustCurrentImageNumber(int)
- Adjust a sprite object's current image number.
-
adjustPosition(Point3D)
- Adjust a sprite object's position on its destination surface.
-
applyEffect(Effect)
- Applies an effect to a sprite object.
-
effectCount()
- Returns the number of effects currently applied to a Sprite.
-
effectElements()
- Returns an enumeration of the effects currently applied to a sprite object.
-
getCurrentImageNumber()
- Returns a sprite object's current image number.
-
getDestination()
- Returns a Sprite's surface.
-
getInputView()
- Gets a sprite object's view port on it's input data.
-
getOutputView()
- Gets a sprite object's output view.
-
getPosition()
- Returns a sprite object's position.
-
isVisible()
- Checks if a sprite object is visible.
-
prepare()
- Prepares a sprite object and its effects for drawing.
-
removeEffect(Effect)
- Removes an effect from a sprite object.
-
setCurrentImageNumber(int)
- Sets a sprite object's current image number.
-
setDestination(Surface)
- Maps a Sprite to a surface.
-
setPosition(Point3D)
- Sets a sprite object's position on its destination surface.
-
setVisibility(boolean)
- Sets the visibility of the sprite to true (visible) or false (invisible)
-
toggleVisibility()
- Toggles the visibility of a sprite object.
-
toString()
- Returns the String representation of this Sprite's internal state.
Sprite
public Sprite()
setVisibility
public void setVisibility(boolean cond)
- Sets the visibility of the sprite to true (visible) or false (invisible)
- Parameters:
- cond - If true, show the sprite object, else hide the sprite object.
- See Also:
- isVisible, toggleVisibility
toggleVisibility
public void toggleVisibility()
- Toggles the visibility of a sprite object.
- See Also:
- isVisible, setVisibility
isVisible
public boolean isVisible()
- Checks if a sprite object is visible.
When a sprite object is created, it is initially visible.
- Returns:
- true if the object is visible; false otherwise.
- See Also:
- setVisibility, toggleVisibility
getOutputView
public Rectangle getOutputView()
- Gets a sprite object's output view.
The output view is a rectangular area projected by the object
onto its output. It is in the coordinate system of the parent
surface.
- Returns:
- OutputView for the Sprite
- See Also:
- getInputView
getInputView
public Rectangle getInputView()
- Gets a sprite object's view port on it's input data.
The view port is the rectangular sub-area of the input to display.
InputView is on the coordinate system of the AnimImage
setDestination
public void setDestination(Surface s)
- Maps a Sprite to a surface.
- Parameters:
- s - The surface on which to map the Sprite.
- See Also:
- getDestination, setPosition
getDestination
public Surface getDestination()
- Returns a Sprite's surface.
- Returns:
- The surface that the Sprite is mapped to, null if none.
- See Also:
- setDestination
setPosition
public boolean setPosition(Point3D p)
- Sets a sprite object's position on its destination surface.
This defines the location of the object on its surface. Where the
location is a (2D) point on the (2D) surface and a depth.
Valid ranges for the position are -2^31 to 2^31 for x and y and
0 to 2^16-1 for depth. Negative depth is not allowed. Depth
of 0 is at the glass of the screen.
- Parameters:
- p - The new position of the object on the surface.
- Returns:
- false if Depth is negative.
true otherwise
- See Also:
- adjustPosition, getPosition, setDestination, Surface
getPosition
public Point3D getPosition()
- Returns a sprite object's position. Position is on the coordinate
system of the surface.
- See Also:
- setPosition, adjustPosition, setDestination, Surface
adjustPosition
public boolean adjustPosition(Point3D deltaPoint)
- Adjust a sprite object's position on its destination surface.
This adjusts the (2D) location of the object on its surface and its
depth.
The current position is changed by adding the specified point
values (which may be positive or negative).
Valid ranges for the position are -2^31 to 2^31 for x and y and
0 to 2^16-1 for depth. Negative depth is not allowed. Depth
of 0 is at the glass of the screen.
- Parameters:
- deltaPoint - contains the increment/decrement values for the position
- Returns:
- false if the adjustment makes the depth negative
true otherwise
- See Also:
- setPosition, getPosition
setCurrentImageNumber
public boolean setCurrentImageNumber(int index)
- Sets a sprite object's current image number.
Noteable cases include:
-
When the Sprite is based on an ImageSequence, the index
argument specifies which SingleImage within the sequence to use.
Note that specifying an index before the first image or beyond the last image
results in using the first or last image, respectively. Additionally, an exception
is thrown as described below.
- Parameters:
- index - the sequence position (zero is first) for the new current image
- Returns:
- false if the index was invalid (e.g., out of bounds) and
the object doesn't automatically adjust (e.g., clip or wrap the index). This could happen
because the source for this object is a SingleImage and an
image number greater than zero was requested or its an ImageSequence
and an out of range image number was requested. a false value is
also returned if the sprite does not currently have any data associated with it
true otherwise
- See Also:
- getCurrentImageNumber, adjustCurrentImageNumber, SingleImage, ImageSequence, DynamicDataSprite, StaticDataSprite
getCurrentImageNumber
public int getCurrentImageNumber()
- Returns a sprite object's current image number.
The default current image, defined when the object is created, is zero.
- Returns:
- s the sequence position (zero is first) of the current image
- See Also:
- setCurrentImageNumber, adjustCurrentImageNumber
adjustCurrentImageNumber
public boolean adjustCurrentImageNumber(int deltaIndex)
- Adjust a sprite object's current image number.
The current image number is changed by adding the specified delta modulo the size
of the set of images. That is, if the new image number overflows or underflows the
image set, it wraps around to the other end of the set.
- Parameters:
- deltaIndex - specifies the increment/decrement value for the image number
- Returns:
- false if this adjustment causes the image number to be out
of range as determined by the range in the source data object. a false value is
also returned if the sprite does not currently have any data associated with it
true otherwise
- See Also:
- setCurrentImageNumber, getCurrentImageNumber
applyEffect
public boolean applyEffect(Effect e)
- Applies an effect to a sprite object.
You can apply multiple effects to a sprite object.
Usage Model
-
Apply all the effects you want to use on an object.
-
Call each effect's activate method to turn effects on and off as needed.
-
When you no longer need an effect, remove it by calling removeEffect.
- Parameters:
- e - the effect to apply
- Returns:
- false if parameters for this effect are out of range or if the
specified effect is already applied to a sprite. a false value is
also returned if the sprite does not currently have any data associated with it
true otherwise
- See Also:
- prepare, removeEffect, activate
prepare
public boolean prepare()
- Prepares a sprite object and its effects for drawing.
This is a performance optimization call.
calling this method causes all the effects applied to this sprite
to be executed and a temporary off screen image that can be
directly blitted at draw time is prepared.
- Returns:
- true if successful, false if failed.
removeEffect
public boolean removeEffect(Effect e)
- Removes an effect from a sprite object.
- Parameters:
- e - the effect to remove
- Returns:
- false if the supplied effect is not currently applied
to this sprite object. a false value is
also returned if the sprite does not currently have any data associated with it
- See Also:
- applyEffect
effectCount
public int effectCount()
- Returns the number of effects currently applied to a Sprite.
- Returns:
- number of effects applied to Sprite
effectElements
public Enumeration effectElements()
- Returns an enumeration of the effects currently applied to a sprite object.
Use the Enumeration methods on the returned object to fetch the elements sequentially.
- Returns:
- enumeration of effects applied to Sprite
toString
public String toString()
- Returns the String representation of this Sprite's internal state.
- Overrides:
- toString in class Object
All Packages Class Hierarchy This Package Previous Next Index