ImageSheetPaint

父级 Paint
display.*
修订 版本 2024.3703
关键词 imageSheetPaint
另请参阅 object.fill
object.stroke

概述

图像表单画笔是一种特殊的 BitmapPaint,用于使用 图像表单 帧填充/描边对象。

注意事项

无法将**纹理环绕**模式(参考)与图像表单帧结合使用。这是因为 OpenGL 仅支持整个纹理的环绕模式,而不支持纹理的子部分。

语法

local paint = {
    type = "image",
    sheet = ,
    frame =
}
类型 (必填)

字符串 字符串值 "image"

sheet (必填)

ImageSheetgraphics.newImageSheet() 返回的图像表单对象。

frame (必填)

数字 图像表单中的帧索引。

属性

(继承自 Paint 的属性)

fill.frame

fill.rotation

fill.scaleX

fill.scaleY

fill.x

fill.y

示例

-- Set up the image sheet
local options =
{
    width = 40,
    height = 100,
    numFrames = 8,
    sheetContentWidth = 160,  -- width of original 1x size of entire sheet
    sheetContentHeight = 200  -- height of original 1x size of entire sheet
}
local imageSheet = graphics.newImageSheet( "textures.png", options )

-- Create a vector rectangle
local rect = display.newRect( 200, 200, 300, 300 )

-- Set the fill (paint) to use frame #2 from the image sheet
local paint = {
    type = "image",
    sheet = imageSheet,
    frame = 2
}

-- Fill the rectangle
rect.fill = paint