Constructor
new Texture(bitmapopt, uvopt)
Create a
Texture
Example。
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
bitmap |
Bitmap
|
<optional> |
null | bitmap Bitmap resources. |
uv |
Array
|
<optional> |
null | uv UV data information. |
Extends
Member
(static) DEF_UV :Array
Default UV information.
(static) INV_UV :Array
Reverse UV information.
bitmap :Bitmap
Picture or canvas.
height :Number
Actual height.
isLinearSampling :Boolean
Gets the linear sampling of the current texture.
loaded :Boolean
Indicates whether successful loading can only indicate successful initial loading (usually including downloading and loading) and does not fully indicate whether the resource can be used immediately (resource management, mechanism release, impact, etc.).
offsetX :Number
Offset along the X axis.
- Default Value:
- 0
offsetY :Number
Offset along the Y axis.
- Default Value:
- 0
released :Boolean
Indicates whether the resource has been released.
repeat :Boolean
Gets if the current texture is enabled by tiling the texture
source :Object
Activate and access resources.
sourceHeight :Number
The original height (including the trimmed transparent area).
- Default Value:
- 0
sourceWidth :Number
The original width (including the transparent area being trimmed).
- Default Value:
- 0
url :String
Picture address
uv :Array
UV information.
width :Number
Actual width.
Methods
create(source, x, y, width, height, offsetXopt, offsetYopt, sourceWidthopt, sourceHeightopt) → {Texture}
Create by specifying resources and coordinates, width, height, offset, etc.
Texture
Object.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
source |
Object
|
Drawing resource img or Texture Object. | ||
x |
Number
|
Initial absolute coordinate X. | ||
y |
Number
|
Initial absolute coordinate y. | ||
width |
Number
|
Wide absolute value. | ||
height |
Number
|
High absolute value. | ||
offsetX |
Number
|
<optional> |
0 | offsetX X axis offset (optional). |
offsetY |
Number
|
<optional> |
0 | offsetY Y axis offset (optional). |
sourceWidth |
Number
|
<optional> |
0 | sourceWidth The original width, including the transparent area to be cut (optional). |
sourceHeight |
Number
|
<optional> |
0 | sourceHeight The original height, including the trimmed transparent area (optional). |
createFromTexture(texture, x, y, width, height) → {Texture}
A part of the Texture is intercepted to generate a new Texture, and null is returned if two regions do not intersect.
Parameters:
Name | Type | Description |
---|---|---|
texture |
Texture
|
Target Texture. |
x |
Number
|
The x position relative to the target Texture. |
y |
Number
|
The Y position relative to the target Texture. |
width |
Number
|
Width of intercept. |
height |
Number
|
Interception height. |
destroy(forceDispose)
Destroy textures (divided into two parts: direct destruction, followed by counting, and destroyed).
Parameters:
Name | Type | Description |
---|---|---|
forceDispose |
Boolean
|
(default = false) true forces the main texture to be destroyed, and false destroys the texture by counting. |
event(type, dataopt) → {Boolean}
Dispatch events.
- Inherited From:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
type |
String
|
Event type. | ||
data |
Object
|
<optional> |
null | data (optional) callback data. Be careful: If you need to pass multiple parameters, P1, P2, P3, you can use the array structure, such as: [p1,p2,p3,...] If you need to call a single parameter P, and P is an array, you need to use a structure such as: [p] Other single parameters, P, can be passed directly to the parameter P. |
Returns:
- Type:
-
Boolean
Is there a listener for this event type? If there is a listener, the value is true, otherwise the value is false.
getEnabled()
getPixels(x, y, width, height) → {Array}
Gets the pixels of an area on the Texture
Parameters:
Name | Type | Description |
---|---|---|
x |
Number
|
|
y |
Number
|
|
width |
Number
|
|
height |
Number
|
Returns:
- Type:
-
Array
Returns a collection of pixels
hasListener(type) → {Boolean}
inspect EventDispatcher Object registers any listeners for a particular event type.
- Inherited From:
Parameters:
Name | Type | Description |
---|---|---|
type |
String
|
Event type. |
Returns:
- Type:
-
Boolean
If the specified type of listener has been registered, the value is true; otherwise, the value is false.
isMouseEvent(type) → {Boolean}
Detects whether the specified event type is a mouse event.
- Inherited From:
Parameters:
Name | Type | Description |
---|---|---|
type |
String
|
Event type. |
Returns:
- Type:
-
Boolean
If it is a mouse event, the value is true; otherwise, the value is false.
load(url)
Load the picture of the specified address.
Parameters:
Name | Type | Description |
---|---|---|
url |
String
|
Picture address. |
moveUV(offsetX, offsetY, uv) → {Array}
Translation UV.
Parameters:
Name | Type | Description |
---|---|---|
offsetX |
Number
|
Offset along the X axis. |
offsetY |
Number
|
Offset along the Y axis. |
uv |
Array
|
UV that requires translation operations. |
Returns:
- Type:
-
Array
UV after translation.
off(type, caller, listener, onceOnly) → {EventDispatcher}
from EventDispatcher Delete listeners in object.
- Inherited From:
Parameters:
Name | Type | Description |
---|---|---|
type |
String
|
Event type. |
caller |
Object
|
The domain of the event listener function. |
listener |
function
|
Event listener function. |
onceOnly |
Boolean
|
(optional) if the value is true, only the listeners added by the once method are removed. |
offAll(typeopt) → {EventDispatcher}
from EventDispatcher Removes all listeners that specify the type of event in the object.
- Inherited From:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
type |
String
|
<optional> |
null | type (optional) event type. If the value is null, all types of listeners for this object are removed. |
on(type, caller, listener, argsopt) → {EventDispatcher}
Use EventDispatcher Object registers the event listener object of the specified type so that listeners can receive event notifications.
- Inherited From:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
type |
String
|
Event type. | ||
caller |
Object
|
The domain of the event listener function. | ||
listener |
function
|
Event listener function. | ||
args |
Array
|
<optional> |
null | args Optional callback parameters for the event listener function. |
once(type, caller, listener, argsopt) → {EventDispatcher}
Use EventDispatcher Object registers the event listener object of the specified type so that the listener can receive the event notification, which is automatically removed after a response event.
- Inherited From:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
type |
String
|
Event type. | ||
caller |
Object
|
The domain of the event listener function. | ||
listener |
function
|
Event listener function. | ||
args |
Array
|
<optional> |
null | args Optional callback parameters for the event listener function. |
setTo(bitmapopt, uvopt)
Sets the bitmap resources and UV data information for this object.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
bitmap |
Bitmap
|
<optional> |
null | bitmap Bitmap resources |
uv |
Array
|
<optional> |
null | uv UV data information |
Event
loaded
- See:
-
- events.Event