Classes
| Global | Description |
|---|---|
| Bitmap | Bitmap |
Functions
| Global | Description |
|---|---|
| initialize(width, height) | Initialize the bitmap. 初始化位图。 |
isReady() ⇒ Boolean | 检查位图是否准备好渲染 Checks whether the bitmap is ready to render. |
isError() ⇒ Boolean | 检查是否发生加载错误 Checks whether a loading error has occurred. |
| touch() | Touch the resource to prevent it from being removed from cache. 触摸资源以防止其从缓存中移除。 |
| resize(width, height) | 调整位图大小 Resizes the bitmap. |
| blt(source, sx, sy, sw, sh, dx, dy, [dw], [dh]) | 执行块传输 Performs a block transfer. |
| bltImage(source, sx, sy, sw, sh, dx, dy, [dw], [dh]) | 执行块传输,假设原始图像未被修改(无色相变化) Performs a block transfer, using assumption that original image was not modified (no hue) |
getPixel(x, y) ⇒ String | 返回指定点的像素颜色 Returns pixel color at the specified point. |
getAlphaPixel(x, y) ⇒ Number | 返回指定点的像素透明度值 Returns alpha pixel value at the specified point. |
| clearRect(x, y, width, height) | 清除指定的矩形区域 Clears the specified rectangle. |
| clear() | 清除整个位图 Clears the entire bitmap. |
| fillRect(x, y, width, height, color) | 填充指定的矩形区域 Fills the specified rectangle. |
| fillAll(color) | 填充整个位图 Fills the entire bitmap. |
| gradientFillRect(x, y, width, height, color1, color2, vertical) | 绘制具有渐变效果的矩形 Draws the rectangle with a gradation. |
| drawCircle(x, y, radius, color) | 绘制圆形位图 Draw a bitmap in the shape of a circle |
| drawText(text, x, y, maxWidth, lineHeight, align) | 向位图绘制轮廓文字 Draws the outline text to the bitmap. |
measureTextWidth(text) ⇒ Number | 返回指定文字的宽度 Returns the width of the specified text. |
| adjustTone(r, g, b) | 改变整个位图的色调 Changes the color tone of the entire bitmap. |
| rotateHue(offset) | 旋转整个位图的色相 Rotates the hue of the entire bitmap. |
| blur() | 对位图应用模糊效果 Applies a blur effect to the bitmap. |
| addLoadListener(listener) | 添加在位图加载完成时调用的回调函数 Add a callback function that will be called when the bitmap is loaded. |
| decode() | 解码位图数据 Decodes the bitmap data. |
| checkDirty() | 如果位图为脏状态则更新纹理 Updates texture if bitmap was dirty. |
isRequestOnly() ⇒ Boolean | 检查是否仅为请求状态 Checks if the bitmap is request-only. |
isRequestReady() ⇒ Boolean | 检查请求是否准备就绪 Checks if the request is ready. |
| startRequest() | 开始请求操作 Starts the request operation. |
Bitmap
Bitmap
Kind: global class
- Bitmap
- new Bitmap(width, height)
- .cacheEntry :
CacheEntry - .fontFace :
String - .fontSize :
Number - .fontItalic :
Boolean - .textColor :
String - .outlineColor :
String - .outlineWidth :
Number
new Bitmap(width, height)
表示图像的基本对象
The basic object that represents an image.
| Param | Type | Description |
|---|---|---|
| width | Number | 位图宽度 / The width of the bitmap |
| height | Number | 位图高度 / The height of the bitmap |
bitmap.cacheEntry : CacheEntry
Cache entry, for images. In all cases _url is the same as cacheEntry.key
缓存条目,用于图像。在所有情况下,_url 与 cacheEntry.key 相同。
Kind: instance property of Bitmap
bitmap.fontFace : String
字体名称
The face name of the font.
Kind: instance property of Bitmap
Properties
| Name |
|---|
| fontFace |
bitmap.fontSize : Number
字体大小(像素)
The size of the font in pixels.
Kind: instance property of Bitmap
Properties
| Name |
|---|
| fontSize |
bitmap.fontItalic : Boolean
字体是否为斜体
Whether the font is italic.
Kind: instance property of Bitmap
Properties
| Name |
|---|
| fontItalic |
bitmap.textColor : String
CSS 格式的文字颜色
The color of the text in CSS format.
Kind: instance property of Bitmap
Properties
| Name |
|---|
| textColor |
bitmap.outlineColor : String
CSS 格式的文字轮廓颜色
The color of the outline of the text in CSS format.
Kind: instance property of Bitmap
Properties
| Name |
|---|
| outlineColor |
bitmap.outlineWidth : Number
文字轮廓的宽度
The width of the outline of the text.
Kind: instance property of Bitmap
Properties
| Name |
|---|
| outlineWidth |
initialize(width, height)
Initialize the bitmap.
初始化位图。
Kind: global function
| Param | Type | Description |
|---|---|---|
| width | Number | The width of the bitmap |
| height | Number | The height of the bitmap |
isReady() ⇒ Boolean
检查位图是否准备好渲染
Checks whether the bitmap is ready to render.
Kind: global function
Returns: Boolean - 如果位图准备好渲染则返回 true / True if the bitmap is ready to render
isError() ⇒ Boolean
检查是否发生加载错误
Checks whether a loading error has occurred.
Kind: global function
Returns: Boolean - 如果发生加载错误则返回 true / True if a loading error has occurred
touch()
Touch the resource to prevent it from being removed from cache.
触摸资源以防止其从缓存中移除。
Kind: global function
resize(width, height)
调整位图大小
Resizes the bitmap.
Kind: global function
| Param | Type | Description |
|---|---|---|
| width | Number | 位图的新宽度 / The new width of the bitmap |
| height | Number | 位图的新高度 / The new height of the bitmap |
blt(source, sx, sy, sw, sh, dx, dy, [dw], [dh])
执行块传输
Performs a block transfer.
Kind: global function
| Param | Type | Default | Description |
|---|---|---|---|
| source | Bitmap | 要绘制的位图 / The bitmap to draw | |
| sx | Number | 源中的 x 坐标 / The x coordinate in the source | |
| sy | Number | 源中的 y 坐标 / The y coordinate in the source | |
| sw | Number | 源图像的宽度 / The width of the source image | |
| sh | Number | 源图像的高度 / The height of the source image | |
| dx | Number | 目标中的 x 坐标 / The x coordinate in the destination | |
| dy | Number | 目标中的 y 坐标 / The y coordinate in the destination | |
| [dw] | Number | sw | 在目标中绘制图像的宽度 / The width to draw the image in the destination |
| [dh] | Number | sh | 在目标中绘制图像的高度 / The height to draw the image in the destination |
bltImage(source, sx, sy, sw, sh, dx, dy, [dw], [dh])
执行块传输,假设原始图像未被修改(无色相变化)
Performs a block transfer, using assumption that original image was not modified (no hue)
Kind: global function
| Param | Type | Default | Description |
|---|---|---|---|
| source | Bitmap | 要绘制的位图 / The bitmap to draw | |
| sx | Number | 源中的 x 坐标 / The x coordinate in the source | |
| sy | Number | 源中的 y 坐标 / The y coordinate in the source | |
| sw | Number | 源图像的宽度 / The width of the source image | |
| sh | Number | 源图像的高度 / The height of the source image | |
| dx | Number | 目标中的 x 坐标 / The x coordinate in the destination | |
| dy | Number | 目标中的 y 坐标 / The y coordinate in the destination | |
| [dw] | Number | sw | 在目标中绘制图像的宽度 / The width to draw the image in the destination |
| [dh] | Number | sh | 在目标中绘制图像的高度 / The height to draw the image in the destination |
getPixel(x, y) ⇒ String
返回指定点的像素颜色
Returns pixel color at the specified point.
Kind: global function
Returns: String - 像素颜色(十六进制格式) / The pixel color (hex format)
| Param | Type | Description |
|---|---|---|
| x | Number | 位图中像素的 x 坐标 / The x coordinate of the pixel in the bitmap |
| y | Number | 位图中像素的 y 坐标 / The y coordinate of the pixel in the bitmap |
getAlphaPixel(x, y) ⇒ Number
返回指定点的像素透明度值
Returns alpha pixel value at the specified point.
Kind: global function
Returns: Number - 透明度值 / The alpha value
| Param | Type | Description |
|---|---|---|
| x | Number | 位图中像素的 x 坐标 / The x coordinate of the pixel in the bitmap |
| y | Number | 位图中像素的 y 坐标 / The y coordinate of the pixel in the bitmap |
clearRect(x, y, width, height)
清除指定的矩形区域
Clears the specified rectangle.
Kind: global function
| Param | Type | Description |
|---|---|---|
| x | Number | 左上角的 x 坐标 / The x coordinate for the upper-left corner |
| y | Number | 左上角的 y 坐标 / The y coordinate for the upper-left corner |
| width | Number | 要清除的矩形宽度 / The width of the rectangle to clear |
| height | Number | 要清除的矩形高度 / The height of the rectangle to clear |
clear()
清除整个位图
Clears the entire bitmap.
Kind: global function
fillRect(x, y, width, height, color)
填充指定的矩形区域
Fills the specified rectangle.
Kind: global function
| Param | Type | Description |
|---|---|---|
| x | Number | 左上角的 x 坐标 / The x coordinate for the upper-left corner |
| y | Number | 左上角的 y 坐标 / The y coordinate for the upper-left corner |
| width | Number | 要填充的矩形宽度 / The width of the rectangle to fill |
| height | Number | 要填充的矩形高度 / The height of the rectangle to fill |
| color | String | CSS 格式的矩形颜色 / The color of the rectangle in CSS format |
fillAll(color)
填充整个位图
Fills the entire bitmap.
Kind: global function
| Param | Type | Description |
|---|---|---|
| color | String | CSS 格式的矩形颜色 / The color of the rectangle in CSS format |
gradientFillRect(x, y, width, height, color1, color2, vertical)
绘制具有渐变效果的矩形
Draws the rectangle with a gradation.
Kind: global function
| Param | Type | Description |
|---|---|---|
| x | Number | 左上角的 x 坐标 / The x coordinate for the upper-left corner |
| y | Number | 左上角的 y 坐标 / The y coordinate for the upper-left corner |
| width | Number | 要填充的矩形宽度 / The width of the rectangle to fill |
| height | Number | 要填充的矩形高度 / The height of the rectangle to fill |
| color1 | String | 渐变起始颜色 / The gradient starting color |
| color2 | String | 渐变结束颜色 / The gradient ending color |
| vertical | Boolean | 渐变是否为垂直方向 / Whether the gradient should be draw as vertical or not |
drawCircle(x, y, radius, color)
绘制圆形位图
Draw a bitmap in the shape of a circle
Kind: global function
| Param | Type | Description |
|---|---|---|
| x | Number | 基于圆心的 x 坐标 / The x coordinate based on the circle center |
| y | Number | 基于圆心的 y 坐标 / The y coordinate based on the circle center |
| radius | Number | 圆的半径 / The radius of the circle |
| color | String | CSS 格式的圆的颜色 / The color of the circle in CSS format |
drawText(text, x, y, maxWidth, lineHeight, align)
向位图绘制轮廓文字
Draws the outline text to the bitmap.
Kind: global function
| Param | Type | Description |
|---|---|---|
| text | String | 将要绘制的文字 / The text that will be drawn |
| x | Number | 文字左侧的 x 坐标 / The x coordinate for the left of the text |
| y | Number | 文字顶部的 y 坐标 / The y coordinate for the top of the text |
| maxWidth | Number | 文字的最大允许宽度 / The maximum allowed width of the text |
| lineHeight | Number | 文字行的高度 / The height of the text line |
| align | String | 文字的对齐方式 / The alignment of the text |
measureTextWidth(text) ⇒ Number
返回指定文字的宽度
Returns the width of the specified text.
Kind: global function
Returns: Number - 文字的宽度(像素) / The width of the text in pixels
| Param | Type | Description |
|---|---|---|
| text | String | 要测量的文字 / The text to be measured |
adjustTone(r, g, b)
改变整个位图的色调
Changes the color tone of the entire bitmap.
Kind: global function
| Param | Type | Description |
|---|---|---|
| r | Number | 红色强度,范围(-255, 255) / The red strength in the range (-255, 255) |
| g | Number | 绿色强度,范围(-255, 255) / The green strength in the range (-255, 255) |
| b | Number | 蓝色强度,范围(-255, 255) / The blue strength in the range (-255, 255) |
rotateHue(offset)
旋转整个位图的色相
Rotates the hue of the entire bitmap.
Kind: global function
| Param | Type | Description |
|---|---|---|
| offset | Number | 色相偏移量,以 360 度为单位 / The hue offset in 360 degrees |
blur()
对位图应用模糊效果
Applies a blur effect to the bitmap.
Kind: global function
addLoadListener(listener)
添加在位图加载完成时调用的回调函数
Add a callback function that will be called when the bitmap is loaded.
Kind: global function
| Param | Type | Description |
|---|---|---|
| listener | function | 回调函数 / The callback function |
decode()
解码位图数据
Decodes the bitmap data.
Kind: global function
checkDirty()
如果位图为脏状态则更新纹理
Updates texture if bitmap was dirty.
Kind: global function
isRequestOnly() ⇒ Boolean
检查是否仅为请求状态
Checks if the bitmap is request-only.
Kind: global function
Returns: Boolean - 是否仅为请求状态 / Whether the bitmap is request-only
isRequestReady() ⇒ Boolean
检查请求是否准备就绪
Checks if the request is ready.
Kind: global function
Returns: Boolean - 请求是否准备就绪 / Whether the request is ready
startRequest()
开始请求操作
Starts the request operation.
Kind: global function
.load(url) ⇒ Bitmap
加载图像文件并返回新的位图对象
Loads a image file and returns a new bitmap object.
Kind: static function
Returns: Bitmap - 新的位图对象 / New bitmap object
| Param | Type | Description |
|---|---|---|
| url | String | 纹理的图像 URL / The image url of the texture |
.snap(stage) ⇒ Bitmap
截取游戏画面快照并返回新的位图对象
Takes a snapshot of the game screen and returns a new bitmap object.
Kind: static function
Returns: Bitmap - 新的位图对象 / New bitmap object
| Param | Type | Description |
|---|---|---|
| stage | Stage | 舞台对象 / The stage object |
.request(url) ⇒ Bitmap
请求位图资源
Requests a bitmap resource.
Kind: static function
Returns: Bitmap - 新的位图对象 / New bitmap object
| Param | Type | Description |
|---|---|---|
| url | String | 要请求的 URL / The URL to request |