fill.frame

Type Number
Object ImageSheetPaint
Library display.*
Revision Release 2024.3703
See also BitmapPaint
ImageSheetPaint

Overview

Defines the image sheet frame index used for the ImageSheetPaint.

Example

-- 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 )

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

-- Fill the rectangle
rect.fill = paint

-- Sometime later, change the fill to frame #2 from the image sheet
rect.fill.frame = 2