|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.golden.gamedev.object.Sprite
vooga.engine.core.BetterSprite
public class BetterSprite
The vooga.engine.core.Sprite class can represent any renderable object in the game environment. The vooga.engine.core.Sprite class extends the com.golden.gamedev.object.Sprite class but provides two additional useful features: the option to switch between renderable images and the capacity to contain any attributes in the form of a Stat. Like the Golden T Sprite class, the Vooga Sprite class supports update and render behaviors for a Sprite object. In addition, the Sprite class contains all the images and attributes that a Sprite object needs. The functionalities supported by the Sprite class include rendering image animation, setting Sprite location and velocity, switching to a different image, and allows for the updating of Sprite attributes. Code Example:
Constructor Summary | |
---|---|
BetterSprite()
Constructs an entity with null image and 0, 0 position and the default label. |
|
BetterSprite(java.awt.image.BufferedImage image)
Constructs an entity with the image and 0, 0 position |
|
BetterSprite(java.awt.image.BufferedImage[] images)
Construct an animated entity from an array of images |
|
BetterSprite(java.awt.image.BufferedImage image,
double x,
double y)
Constructs an entity with an image located at the specified coordinates and the default label. |
|
BetterSprite(double x,
double y)
Constructs an entity with null image located at the specified coordinates with the default label. |
|
BetterSprite(java.lang.String label,
java.awt.image.BufferedImage image,
double x,
double y)
Constructs an entity with given image located at specified coordinates AND labels the image so that you can switch to this initial sprite if other sprites are added to this entity later. |
|
BetterSprite(java.lang.String label,
com.golden.gamedev.object.Sprite s)
|
Method Summary | |
---|---|
void |
addAnimatedImages(java.lang.String label,
java.awt.image.BufferedImage[] images)
Adds a new Animatedsprite to the image map; |
void |
addHorizontalSpeed(long elapsedTime,
double accel,
double maxSpeed)
Add an acceleration value to the sprite or change the horizontal speed of the sprite |
void |
addImage(java.lang.String label,
java.awt.image.BufferedImage image)
Adds a new Sprite made from the given image. |
void |
addSprite(java.lang.String label,
com.golden.gamedev.object.Sprite sp)
|
void |
addVerticalSpeed(long elapsedTime,
double accel,
double maxSpeed)
Add an acceleration value to the sprite or change the vertical speed of the sprite |
void |
firstRun()
Override this method to do any initializations necessary after the sprite is initialized by the level file. |
void |
forceX(double newx)
Force myCurrentSprite to a specific X location newx on the screen |
void |
forceY(double newy)
Force myCurrentSprite to a specific Y location newy on the screen |
com.golden.gamedev.object.Sprite |
getCurrentSprite()
This method returns my currentSprite. |
double |
getDistance(com.golden.gamedev.object.Sprite other)
Get the distance from mycurrentSprite |
Stat<java.lang.Double> |
getDoubleStat(java.lang.String statname)
|
int |
getHeight()
|
double |
getHorizontalSpeed()
|
java.awt.image.BufferedImage |
getImage()
Get the bitmap representation of myCurrentSprite |
Stat<java.lang.Integer> |
getIntStat(java.lang.String statname)
|
Stat<?> |
getStat(java.lang.String statName)
Returns the Stat associated with the given name. |
long |
getTimeInExistence()
|
double |
getVerticalSpeed()
|
int |
getWidth()
|
double |
getX()
Get the current X position of myCurrentSprite |
double |
getY()
Get the current Y position of myCurrentSprite |
boolean |
isActive()
check if myCurrentSprite is currently displayed |
boolean |
isOnScreen()
Check whether the myCurrentSprite is on the screen |
void |
move(double newx,
double newy)
Move the current Sprite newx and newy |
boolean |
moveTo(long elapsedTime,
double newx,
double newy,
double newspeed)
Move myCurrentSprie to newx and newy and change the velocity to newSpeed |
void |
moveX(double dx)
|
void |
moveY(double dy)
|
void |
render(java.awt.Graphics2D g)
Render the image onto the screen |
void |
setActive(boolean b)
set whether myCurrentSprite will be visible on the screen |
void |
setAsRenderedSprite(java.lang.String spriteName)
Modify GameEntity so that it is represented by the Sprite specified by spriteName. |
void |
setBackground(Background backgr)
Set the background for the Golden T. |
void |
setDoubleStat(java.lang.String statname)
|
void |
setHorizontalSpeed(double vx)
|
void |
setImage(java.awt.image.BufferedImage Image)
This method sets a new image to the current Image. |
void |
setImages(java.awt.image.BufferedImage[] images)
This method sets a new image array to the current image array only if myCurrentSprite is an AnimatedSprite |
void |
setIntStat(java.lang.String statname,
int stat)
|
void |
setLayer(int i)
Set all the sprites to the same |
void |
setLocation(double xs,
double ys)
|
void |
setMovement(double speed,
double angleDir)
set the magnitude of myCurrenttSprite with an initial angle |
void |
setSpeed(double vs,
double vy)
|
void |
setStat(java.lang.String name,
Stat<?> t)
Sets |
void |
setVerticalSpeed(double vy)
|
void |
setX(double xs)
|
void |
setY(double ys)
|
void |
update(long elapsedTime)
Specify how the GameEntity Object should be updated. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public BetterSprite()
public BetterSprite(java.awt.image.BufferedImage image)
image
- public BetterSprite(java.lang.String label, com.golden.gamedev.object.Sprite s)
name
- is any name you'd like to give to the object.state
- State name is the name you'd like to map to the following
Sprite object. e.g."alive" to represent a sprite that's a
live, or "dead" if the sprite represents the entity in a dead
state, etcthis
- is the default Sprite that will represent this Entity on the
Screen.public BetterSprite(java.awt.image.BufferedImage[] images)
image
- public BetterSprite(java.awt.image.BufferedImage image, double x, double y)
image
- x
- is the x position.y
- is the y position.public BetterSprite(double x, double y)
x
- is the x position.y
- is the y position.public BetterSprite(java.lang.String label, java.awt.image.BufferedImage image, double x, double y)
label
- is the label for this sprite representation.image
- x
- is the x position.y
- is the y position.Method Detail |
---|
public void addSprite(java.lang.String label, com.golden.gamedev.object.Sprite sp)
label
- is the name you'd like to use to represent the Sprite
parameter. e.g. "alive" or "dead" or "shooting"sp
- is the Sprite you are mapping to the first parameter.public void addImage(java.lang.String label, java.awt.image.BufferedImage image)
label
- is the name you'd like to use to represent the Sprite
parameter. e.g. "alive" or "dead" or "shooting"image
- is the image from which the new Sprite will be constructed.public void addAnimatedImages(java.lang.String label, java.awt.image.BufferedImage[] images)
label
- images
- public com.golden.gamedev.object.Sprite getCurrentSprite()
public long getTimeInExistence()
public void setAsRenderedSprite(java.lang.String spriteName)
spriteName
- the "name" of the sprite that GameEntity will now be
represented by.public Stat<?> getStat(java.lang.String statName)
statName
- is the name used
public void setStat(java.lang.String name, Stat<?> t)
public Stat<java.lang.Integer> getIntStat(java.lang.String statname)
public void setIntStat(java.lang.String statname, int stat)
public Stat<java.lang.Double> getDoubleStat(java.lang.String statname)
public void setDoubleStat(java.lang.String statname)
public void update(long elapsedTime)
public void firstRun()
public void render(java.awt.Graphics2D g)
com.golden.gamedev.object.Sprite#render(java.awt.Graphics2D)
public java.awt.image.BufferedImage getImage()
public void setImage(java.awt.image.BufferedImage Image)
Image
- public void setImages(java.awt.image.BufferedImage[] images)
images
- the images to set on myCurrentSpritepublic boolean isOnScreen()
public void setActive(boolean b)
public boolean isActive()
public void setBackground(Background backgr)
public void setLayer(int i)
public void addHorizontalSpeed(long elapsedTime, double accel, double maxSpeed)
com.golden.gamedev.object.Sprite#addHorizontalSpeed(long, double,
double)
public void addVerticalSpeed(long elapsedTime, double accel, double maxSpeed)
com.golden.gamedev.object.Sprite#addVerticalSpeed(long, double,
double)
public void forceX(double newx)
public void forceY(double newy)
public double getX()
public double getY()
com.golden.gamedev.object.Sprite#getY()
public double getDistance(com.golden.gamedev.object.Sprite other)
public int getHeight()
public int getWidth()
public double getHorizontalSpeed()
public double getVerticalSpeed()
public void setHorizontalSpeed(double vx)
public void setVerticalSpeed(double vy)
public void setLocation(double xs, double ys)
public void setMovement(double speed, double angleDir)
public void setSpeed(double vs, double vy)
public void setX(double xs)
public void setY(double ys)
public void move(double newx, double newy)
com.golden.gamedev.object.Sprite#move(double, double)
public boolean moveTo(long elapsedTime, double newx, double newy, double newspeed)
public void moveX(double dx)
public void moveY(double dy)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |