Class: Background

Background(type, value)

Background

Constructor

new Background(type, value)

This Background class is used as a simple way to set backgrounds for games. Background Objects can have three different types: "color", "image" or "img", "clear" If the background type is "color", then the background will render as the solid color as specified by the value parameter you pass in. If the background type is "img" or "image" (there is no difference), then the background will render as the image that you pass in via the value parameter. If the background type is "clear", then the background will not render at all.
Parameters:
Name Type Description
type String The type of background that this Background object will be. Acceptable values: "color", "image" or "img", "clear"
value Object This parameter is either a HTML color ("#00F" or "#0000FF") or an image object. Depends upon the type you specified. If the type is "clear", then this parameter is ignored
Properties:
Name Type Description
color String The current color of this Background object if it is the "color" type
img Object The current background image if this object is the "image" or "img" type.
type String The type of background this Background object currently is. Acceptable values: "color", "image" or "img", "clear"
Source:

Methods

(static) draw(game)

- Renders the background onto the game canvas according to the type of background this is.
Parameters:
Name Type Description
game Game The Game that we are rendering this background onto
Source: