Class: ImageSprite

ImageSprite(img, x, y)

ImageSprite

Constructor

new ImageSprite(img, x, y)

A sprite that is simply an image. The sprite can change between images, visibility, position, and rotation. Also includes basic hitbox detection.
Parameters:
Name Type Description
img Image The starting images that this sprite will render as. Will be in index 0 of the images array.
x Number The starting x-position of this sprite
y Number The starting y-position of this sprite
Properties:
Name Type Description
x Number The current x-position of this sprite
y Number The current y-position of this sprite
rotation Number The number of degrees this sprite is currently rotated. Default: 0
visible Boolean Whether or not this sprite is visible
images Array An Array of Images that this sprite can switch between
img Image The current image the sprite will render as
Source:

Methods

(static) draw(game)

Renders the sprite onto the give game canvas.
Parameters:
Name Type Description
game Game The game this sprite will be rendered onto
Source:

(static) hide()

Makes this sprite not visible
Source:

(static) hide()

Makes this sprite visible
Source:

(static) inHit(cx, cy) → {Boolean}

Checks to see if the given coordinates are within the sprite's "hit box"
Parameters:
Name Type Description
cx Number The x coordinate
cy Number The y coordinate
Source:
Returns:
True is the coordinates are within the "hit box", False otherwise.
Type
Boolean