Package ch.epfl.cs107.play.engine.actor
Class RPGSprite
java.lang.Object
ch.epfl.cs107.play.math.Node
ch.epfl.cs107.play.engine.actor.ImageGraphics
ch.epfl.cs107.play.engine.actor.Sprite
ch.epfl.cs107.play.engine.actor.RPGSprite
- All Implemented Interfaces:
Graphics,Attachable,Positionable
-
Constructor Summary
ConstructorsConstructorDescriptionRPGSprite(String name, float width, float height, Positionable parent) Creates a new image graphics.RPGSprite(String name, float width, float height, Positionable parent, RegionOfInterest roi) Creates a new image graphics.RPGSprite(String name, float width, float height, Positionable parent, RegionOfInterest roi, Vector anchor) Creates a new image graphics.RPGSprite(String name, float width, float height, Positionable parent, RegionOfInterest roi, Vector anchor, float alpha, float depthCorrection) Creates a new Sprite. -
Method Summary
Modifier and TypeMethodDescriptionvoidRenders itself on specified canvas.static 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
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
-
RPGSprite
public RPGSprite(String name, float width, float height, Positionable parent, RegionOfInterest roi, Vector anchor, float alpha, float depthCorrection) 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)depthCorrection- (float): correction of the deepness defined by the parent position if exists
-
RPGSprite
public RPGSprite(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
-
RPGSprite
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
-
RPGSprite
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
-
draw
Description copied from interface:GraphicsRenders itself on specified canvas.- Specified by:
drawin interfaceGraphics- Overrides:
drawin classImageGraphics- Parameters:
canvas- target, not null
-
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
-