|
Genuts ME API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.genuts.gameui.Sprite
com.genuts.gameui.SpriteWrapper
This Sprite is a special sprite, its goal is only to wrap another Sprite
Object.
In that way, you can have multiple behavior without any high developpement
procedure, and the same wrapper can be used by diffenrent type of sprites.
A sprite on which a sprite wrapper interact is called an action sprite.
A SpriteWrapper is an abstract super class, because there are no sense to instanciate this class directly.
The only thing to know is that when you add a Sprite to its playfield, don't forget to pass the reference of the wrapper and not of the sprite.
| Constructor Summary | |
SpriteWrapper()
Initializes a default wrapper sprite. |
|
SpriteWrapper(Sprite sprite)
Initializes the wrapper sprite. |
|
| Method Summary | |
boolean |
checkCollision(Sprite sprite)
Checks collision of the action sprite with another action sprite or with the edges of the playfield. |
protected void |
collisionWith(Sprite s)
Propagations of the collision event to the action event. |
Sprite |
getActionSprite()
Returns the action sprite. |
int |
getBackground()
Gets the background color of the action sprite. |
int |
getBottomCollisionOffset()
Gets the offset on the bottom side for which the collision must not be considered. |
Sprite |
getFinalActionSprite()
Returns the first action sprite contained in this sprite that is not a SpriteWrapper. |
int |
getHeight()
Gets the height of the action sprite. |
int |
getId()
Gets the id of the action sprite. |
Image |
getImage()
Gets the image of the action sprite. |
int |
getLeftCollisionOffset()
Gets the offset on the left side for which the collision must not be considered. |
PlayField |
getParent()
Gets the parent playfield of the action sprite. |
int |
getRightCollisionOffset()
Gets the offset on the right side for which the collision must not be considered. |
int |
getTopCollisionOffset()
Gets the offset on the top side for which the collision must not be considered. |
int |
getWidth()
Gets the width of the action sprite. |
int |
getX()
Gets the X coordinate of the action sprite. |
int |
getY()
Gets the Y coordinate of the action sprite. |
void |
invalidate()
Invalidates the action sprite. |
boolean |
isBackgroundSprite()
Is the action sprite a part of the background? |
boolean |
isPremode()
Returns the pre-collision mode state for the action sprite. |
boolean |
isSpriteAt(int x,
int y)
Indicates if the action sprite is under (x,y) coordinates. |
boolean |
isValidate()
Indicates if the action sprite as been valideted by its parent. |
boolean |
isVisible()
Is the action sprite visible? |
void |
paint(Graphics g)
Paints the action sprite. |
protected boolean |
preCollisionWith(Sprite s)
Propagations of the pre-collision event to the action event. |
void |
repaint()
Repaints the action component. |
void |
setActionSprite(Sprite sprite)
Sets the action sprite. |
void |
setBackground(int color)
Sets the background color for the action sprite. |
void |
setBackgroundSprite(boolean v)
Sets if the action sprite a part of the background. |
void |
setBottomCollisionOffset(int offset)
Sets the offset on the bottom side for which the collision must not be considered. |
boolean |
setBounds(int x,
int y,
int width,
int height)
Moves and resizes this action sprite to conform to the new bounding rectangle. |
void |
setId(int id)
Sets the action sprite's id. |
void |
setImage(Image img)
Sets the image for the action sprite. |
void |
setLeftCollisionOffset(int offset)
Sets the offset on the left side for which the collision must not be considered. |
protected void |
setParent(PlayField parent)
Sets the parent playfield of the action sprite. |
boolean |
setPosition(int x,
int y)
Sets the position of the action sprite in the playfield. |
void |
setPremode(boolean state)
Sets the pre-collision mode for the action sprite. |
void |
setRightCollisionOffset(int offset)
Sets the offset on the right side for which the collision must not be considered. |
boolean |
setSize(int w,
int h)
Sets the size of the action sprite. |
void |
setTopCollisionOffset(int offset)
Sets the offset on the top side for which the collision must not be considered. |
void |
setVisible(boolean v)
Sets if the action sprite is visible. |
void |
tick(int ticks)
Propagations of the tick event to the action event if it is an instance of Tickable. |
void |
validate()
Validates the action sprite by its parent. |
| Methods inherited from class com.genuts.gameui.Sprite |
getFinalWrapper, getWrapper, setWrapper, toString |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
public SpriteWrapper()
public SpriteWrapper(Sprite sprite)
sprite - Sprite which really acts.| Method Detail |
public Sprite getFinalActionSprite()
SpriteSpriteWrapper. SpriteWrapper.
getFinalActionSprite in class SpriteSpriteWrapper.public Sprite getActionSprite()
getActionSprite in class Spritepublic void setActionSprite(Sprite sprite)
null.
sprite - Action sprite.public void setId(int id)
setId in class Spriteid - ID of this spritepublic int getId()
getId in class Sprite
public boolean setSize(int w,
int h)
setSize in class Spritetrue if the modification was done, false
otherwise.
public boolean setPosition(int x,
int y)
setPosition in class Spritex - X position of the sprite.y - Y position of the sprite.
true if the modification was done, false
otherwise.public int getX()
getX in class Spritepublic int getY()
getY in class Spritepublic int getWidth()
getWidth in class Spritepublic int getHeight()
getHeight in class Sprite
public boolean setBounds(int x,
int y,
int width,
int height)
setBounds in class Spritex - X position of the sprite.y - Y position of the sprite.width - width of the sprite.height - height of the sprite.
true if the modification was done, false
otherwise.
public boolean isSpriteAt(int x,
int y)
isSpriteAt in class Spritex - X coordinate in the sprite to check.y - Y coordinate in the sprite to check.
true if this sprite is under
(x,y) coordinates, false otherwise.public void setPremode(boolean state)
setPremode in class Spritestate - true to set the pre-collision mode to true,
false otherwise.Sprite.setPremode(boolean)public boolean isPremode()
isPremode in class Spritetrue if the pre-collision mode is true,
false otherwise.public boolean checkCollision(Sprite sprite)
checkCollision in class Spritesprite - Sprite to check the collision with.
true if this sprite and the other
sprite are in collision, false otherwise.public int getRightCollisionOffset()
getRightCollisionOffset in class Spritepublic void setRightCollisionOffset(int offset)
setRightCollisionOffset in class Spritepublic int getLeftCollisionOffset()
getLeftCollisionOffset in class Spritepublic void setLeftCollisionOffset(int offset)
setLeftCollisionOffset in class Spritepublic int getTopCollisionOffset()
getTopCollisionOffset in class Spritepublic void setTopCollisionOffset(int offset)
setTopCollisionOffset in class Spritepublic int getBottomCollisionOffset()
getBottomCollisionOffset in class Spritepublic void setBottomCollisionOffset(int offset)
setBottomCollisionOffset in class Spritepublic boolean isValidate()
isValidate in class Spritetrue if this parent as valid
it, false otherwise.public void validate()
validate in class Spritepublic void invalidate()
invalidate in class Spritepublic boolean isBackgroundSprite()
isBackgroundSprite in class Spritetrue if this sprite is a
part of the background, false
otherwise.public void setBackgroundSprite(boolean v)
setBackgroundSprite in class Spritev - true if this sprite is a
part of the background, false
otherwise.protected void setParent(PlayField parent)
setParent in class Spriteparent - Parent playfield of this sprite.public PlayField getParent()
getParent in class Spritepublic Image getImage()
getImage in class Spritepublic void setImage(Image img)
setImage in class Spriteimg - Image to set.public int getBackground()
getBackground in class Spritepublic void setBackground(int color)
setBackground in class Spritecolor - Color to set.public boolean isVisible()
isVisible in class Spritetrue if the sprite is visible,
false otherwise.public void setVisible(boolean v)
setVisible in class Spritev - true if the sprite is visible,
false otherwise.protected boolean preCollisionWith(Sprite s)
preCollisionWith in class Sprites - Sprite with which the collision is
true to accept the new position and the size of the
sprite, false otherwise.Sprite.preCollisionWith(Sprite)protected void collisionWith(Sprite s)
collisionWith in class Sprites - Sprite with which the collision isSprite.collisionWith(Sprite)public void repaint()
repaint in class SpriteSprite.repaint()public void paint(Graphics g)
paint in class Spriteg - The graphics context to use for painting.public void tick(int ticks)
Tickable.
tick in interface Tickableticks - Number of ticks from the playfield.
|
Genuts ME API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||