Class enchant.Entity
A class with objects displayed as DOM elements. Not to be used directly.
- Defined in: enchant.js
- Extends enchant.Node
Constructor Attributes | Constructor Name and Description |
---|---|
Field Attributes | Field Name and Description |
---|---|
The Entity background color.
|
|
Defines this Entity as a button.
|
|
Indicates if this Entity is being clicked.
|
|
The Entity debug color.
|
|
The height of the Entity.
|
|
The transparency of this entity.
|
|
The point of origin used for rotation and scaling.
|
|
The point of origin used for rotation and scaling.
|
|
Entity rotation angle (degree).
|
|
Scaling factor on the x axis of this Entity.
|
|
Scaling factor on the y axis of this Entity.
|
|
Indicates whether or not this Entity can be touched.
|
|
Indicates whether or not to display this Entity.
|
|
The width of the Entity.
|
- Fields borrowed from class enchant.Node:
- age, parentNode, scene, x, y
Method Summary
Method Attributes | Method Name and Description |
---|---|
intersect(other)
Performs a collision detection based on whether or not the bounding rectangles are intersecting.
|
|
rotate(deg)
Rotate this Entity.
|
|
scale(x, y)
Enlarges or shrinks this Entity.
|
|
within(other, distance)
Performs a collision detection based on distance from the Entity's central point.
|
- Methods borrowed from class enchant.Node:
- moveBy
- moveTo
- Methods borrowed from class enchant.EventTarget:
- addEventListener
- clearEventListener
- dispatchEvent
- on
- removeEventListener
Class Detail
enchant.Entity()
Field Detail
{String}
backgroundColor
The Entity background color.
Must be provided in the same format as the CSS 'color' property.
{String}
buttonMode
Defines this Entity as a button.
When touched or clicked the corresponding button event is dispatched.
Valid buttonModes are: left, right, up, down, a, b.
{Boolean}
buttonPressed
Indicates if this Entity is being clicked.
Only works when enchant.Entity.buttonMode is set.
{String}
compositeOperation
{String}
debugColor
The Entity debug color.
Must be provided in the same format as the CSS 'color' property.
{Number}
height
The height of the Entity.
{Number}
opacity
The transparency of this entity.
Defines the transparency level from 0 to 1
(0 is completely transparent, 1 is completely opaque).
{Number}
originX
The point of origin used for rotation and scaling.
{Number}
originY
The point of origin used for rotation and scaling.
{Number}
rotation
Entity rotation angle (degree).
{Number}
scaleX
Scaling factor on the x axis of this Entity.
{Number}
scaleY
Scaling factor on the y axis of this Entity.
{Boolean}
touchEnabled
Indicates whether or not this Entity can be touched.
{Boolean}
visible
Indicates whether or not to display this Entity.
{Number}
width
The width of the Entity.
Method Detail
-
disableCollection()
-
enableCollection()
-
{Boolean} intersect(other)Performs a collision detection based on whether or not the bounding rectangles are intersecting.
- Parameters:
- {*} other
- An object like Entity, with the properties x, y, width, height, which are used for the collision detection.
- Returns:
- {Boolean} True, if a collision was detected.
-
rotate(deg)Rotate this Entity.
- Parameters:
- {Number} deg
- Rotation angle (degree).
-
scale(x, y)Enlarges or shrinks this Entity.
- Parameters:
- {Number} x
- Scaling factor on the x axis.
- {Number} y Optional
- Scaling factor on the y axis.
-
{Boolean} within(other, distance)Performs a collision detection based on distance from the Entity's central point.
- Parameters:
- {*} other
- An object like Entity, with properties x, y, width, height, which are used for the collision detection.
- {Number} distance Optional
- The greatest distance to be considered for a collision. The default distance is the average of both objects width and height.
- Returns:
- {Boolean} True, if a collision was detected.