Package ch.epfl.cs107.play.engine.actor
Class Sprite
java.lang.Object
ch.epfl.cs107.play.math.Node
ch.epfl.cs107.play.engine.actor.ImageGraphics
ch.epfl.cs107.play.engine.actor.Sprite
- All Implemented Interfaces:
Graphics,Attachable,Positionable
- Direct Known Subclasses:
RPGSprite
-
Constructor Summary
ConstructorsConstructorDescriptionSprite(String name, float width, float height, Positionable parent) Creates a new image graphics.Sprite(String name, float width, float height, Positionable parent, RegionOfInterest roi) Creates a new image graphics.Sprite(String name, float width, float height, Positionable parent, RegionOfInterest roi, Vector anchor) Creates a new image graphics.Sprite(String name, float width, float height, Positionable parent, RegionOfInterest roi, Vector anchor, float alpha, float depth) Creates a new Sprite. -
Method Summary
Modifier and TypeMethodDescriptionstatic Sprite[]extractSprites(String name, int nbFrames, float width, float height, Positionable parent, int regionWidth, int regionHeight) Extracts from an image the spritesstatic Sprite[][]extractSprites(String name, int nbFrames, float width, float height, Positionable parent, int regionWidth, int regionHeight, Orientation[] order) Extracts from an image the sprites corresponding to a given orientation the returned array has 4 entry (one per orientation) the content of each entry is an array of sprites corresponding to the given orientation (the entry indexed by Orientation.dir.ordinal() is the array of sprites corresponding to the orientation Orientation.dir).static Sprite[][]extractSprites(String name, int nbFrames, float width, float height, Positionable parent, int regionWidth, int regionHeight, Vector anchor, Orientation[] order) Extracts from an image the sprites corresponding to a given orientation the returned array has 4 entry (one per orientation) the content of each entry is an array of sprites corresponding to the given orientation (the entry indexed by Orientation.dir.ordinal() is the array of sprites corresponding to the orientation Orientation.dir).static Sprite[]extractSprites(String name, int nbFrames, float width, float height, Positionable parent, Vector anchor, int regionWidth, int regionHeight) Extracts from an image the spritesMethods inherited from class ch.epfl.cs107.play.engine.actor.ImageGraphics
draw, getAlpha, getAnchor, getDepth, getHeight, getName, getWidth, setAlpha, setAnchor, setDepth, setHeight, setName, setWidthMethods inherited from class ch.epfl.cs107.play.math.Node
getParent, getPosition, getRelativeTransform, getTransform, getVelocity, setParent, setRelativeTransform
-
Constructor Details
-
Sprite
public Sprite(String name, float width, float height, Positionable parent, RegionOfInterest roi, Vector anchor, float alpha, float depth) Creates a new Sprite.- Parameters:
name- (String): image name, may be nullwidth- (int): actual image width, before transformationheight- (int): actual image height, before transformationparent- (Positionable): parent of this, not nullroi- (RegionOfInterest): region of interest into the image as a rectangle in the image. May be nullanchor- (Vector): image anchor, not nullalpha- (float): transparency, between 0 (invisible) and 1 (opaque)depth- (float): render priority, lower-values drawn first
-
Sprite
public Sprite(String name, float width, float height, Positionable parent, RegionOfInterest roi, Vector anchor) Creates a new image graphics.- Parameters:
name- (String): image name, not nullwidth- (int): actual image width, before transformationheight- (int): actual image height, before transformationparent- (Positionable): parent of this, not nullroi- (RegionOfInterest): region of interest into the image as a rectangle in the image. May be nullanchor- (Vector): image anchor, not null
-
Sprite
Creates a new image graphics.- Parameters:
name- (String): image name, not nullwidth- (int): actual image width, before transformationheight- (int): actual image height, before transformationparent- (Positionable): parent of this, not nullroi- (RegionOfInterest): region of interest into the image as a rectangle in the image. May be null
-
Sprite
Creates a new image graphics.- Parameters:
name- (String): image name, not nullwidth- (int): actual image width, before transformationheight- (int): actual image height, before transformationparent- (Positionable): parent of this, not null
-
-
Method Details
-
extractSprites
public static Sprite[][] extractSprites(String name, int nbFrames, float width, float height, Positionable parent, int regionWidth, int regionHeight, Vector anchor, Orientation[] order) Extracts from an image the sprites corresponding to a given orientation the returned array has 4 entry (one per orientation) the content of each entry is an array of sprites corresponding to the given orientation (the entry indexed by Orientation.dir.ordinal() is the array of sprites corresponding to the orientation Orientation.dir).- Parameters:
name- (String): the name of the imagenbFrames- (int): number of frames in each rowwidth- (int): actual image width, before transformationheight- (int): actual image height, before transformationparent- (Positionable): parent of this, not nullregionWidth- (int): width of frame (number of pixels in the image)regionHeight- (int): height of frame (number of pixels in the image)anchor- (Vector) : image anchor, not nullorder- (Orientation[]): order of the frames in the image- Returns:
- an array of 4 Sprite[] (one Sprite[] per orientation)
-
extractSprites
public static Sprite[][] extractSprites(String name, int nbFrames, float width, float height, Positionable parent, int regionWidth, int regionHeight, Orientation[] order) Extracts from an image the sprites corresponding to a given orientation the returned array has 4 entry (one per orientation) the content of each entry is an array of sprites corresponding to the given orientation (the entry indexed by Orientation.dir.ordinal() is the array of sprites corresponding to the orientation Orientation.dir).- Parameters:
name- (String): the name of the imagenbFrames- (int): number of frames in each rowwidth- (int): actual image width, before transformationheight- (int): actual image height, before transformationparent- (Positionable): parent of this, not nullregionWidth- (int): width of frame (number of pixels in the image)regionHeight- (int): height of frame (number of pixels in the image)order- (Orientation[]): order of the frames in the image- Returns:
- an array of 4 Sprite[] (one Sprite[] per orientation)
-
extractSprites
public static Sprite[] extractSprites(String name, int nbFrames, float width, float height, Positionable parent, Vector anchor, int regionWidth, int regionHeight) Extracts from an image the sprites- Parameters:
name- (String): the name of the imagenbFrames- (int): number of frames in each rowwidth- (int): actual image width, before transformationheight- (int): actual image height, before transformationparent- (Positionable): parent of this, not nullanchor- (Vector) : image anchor, not nullregionWidth- (int): width of frame (number of pixels in the image)regionHeight- (int): height of frame (number of pixels in the image)- Returns:
- an array of Sprite
-
extractSprites
public static Sprite[] extractSprites(String name, int nbFrames, float width, float height, Positionable parent, int regionWidth, int regionHeight) Extracts from an image the sprites- Parameters:
name- (String): the name of the imagenbFrames- (int): number of frames in each rowwidth- (int): actual image width, before transformationheight- (int): actual image height, before transformationparent- (Positionable): parent of this, not nullregionWidth- (int): width of frame (number of pixels in the image)regionHeight- (int): height of frame (number of pixels in the image)- Returns:
- an array of Sprite
-