Members
has_click_listeners :boolean
Whether the current Doll or any of its DollSlot objects respond to
click events
Type:
- boolean
has_collision_listeners :boolean
Whether the current Doll or any of its DollSlot objects respond to
collision between DollSlot events
Type:
- boolean
has_update_listeners :boolean
Whether the current Doll or any of its DollSlot objects have an update
listener specified to be called according to the update time function
Type:
- boolean
num_loading :int
Number of images in DollSlot object on this Doll that
have yet to load
Type:
- int
player_index :int|boolean
If the Doll is navigable, then this holds the index of the PlayerSlot
in the array this.slots.items of DollSlot objects
Type:
- int | boolean
render_requests :Array.<Canvas>
An array of canvas objects on which this Doll has been requested to
render, but can't yet (say because relies on images which are still
loading)
Type:
- Array.<Canvas>
rendering :boolean
Is true if the Doll is currently being drawn in some other thread
Type:
- boolean
Methods
checkCollisions(dollhouse)
Checks for any collisions between DollSlot objects on the current Doll
that have collision listeners specified. If there are then the
listeners are called with an event containing info about the two
DollSlots involved and the Dollhouse on which the Doll will be rendered.
Parameters:
| Name | Type | Description |
|---|---|---|
dollhouse |
Dollhouse | on which the current Doll is to be rendered |
getPlayerSlot(dollhousenullable) → {DollSlot}
Returns the DollSlot used to manage the player's coordinates and
icon image within the current Doll (provided the Doll is navigable).
If the player DollSlot doesn't exist an attempt is made to create it.
If a Dollhouse is provided this is used in the attempt to create the
player slot.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
dollhouse |
DollHouse |
<nullable> |
null | that may be used to help create the player DollSlot |
Returns:
the player DollSlot
- Type
- DollSlot
init()
Used to set up the Doll. This involves loading all images related to
doll, and initializing the has_click_listeners, has_collision_listeners,
has_update_listeners booleant
loadImage(URL) → {HTMLImageElement}
Initiates loading of the image at URL into an Image object and returns
this object. Adds one to num_loading property of this Doll,
so know Doll is tracking one more image to be loaded.
Sets up a callback such that if all the images that have been requested
for this Doll have loaded, and there have been requests to render
this doll, then the Doll is rendered to each canvas requested.
Parameters:
| Name | Type | Description |
|---|---|---|
URL |
string | of image to load |
Returns:
image to be loaded
- Type
- HTMLImageElement
push(slot) → {boolean}
If the passed slot is a DollSlot adds it to slots and returns true;
otherwise, does nothing and returns false
Parameters:
| Name | Type | Description |
|---|---|---|
slot |
DollSlot | to insert |
Returns:
whether the item was added or not
- Type
- boolean
render(canvas)
Draws the current Doll to the provided canvas view. Note given the
Doll's coordinate system only some portion of the Doll may be
visible. If not all of the images for this Doll have been downloaded
a render request is made instead.
Parameters:
| Name | Type | Description |
|---|---|---|
canvas |
HTMLCanvasElement | to draw Doll onto |
setPlayerSlot(player_slot)
Sets the DollSlot object that corresponds to the person playing the
game to player_slot. This object holds player info when a Doll is
navigable
Parameters:
| Name | Type | Description |
|---|---|---|
player_slot |
DollSlot | a doll slot with player's rectangle info on the doll, and icon or color to draw for player |