类型 目录常量 对象 TextureResource 库 graphics.* 修订版本 版本 2024.3703 另请参阅 texture.filename texture.type TextureResource
使用此属性代替实际的目录常量来创建显示对象、填充,并在其他需要实际目录常量的地方使用。在这些情况下,您还必须将 texture.filename 作为参数传递 — 请参阅下面的示例以供参考。
此
-- Standard image
local image1 = display.newImageRect( "background.png", 100, 100 )
image1.x = 100
image1.y = 100
-- TextureResource-based image
local texture = graphics.newTexture( { type="image", filename="background.png" } )
local image2 = display.newImageRect(
texture.filename, -- "filename" property required
texture.baseDir, -- "baseDir" property required
100,
100
)
image2.x = 200
image2.y = 100
-- Standard fill
local circle1 = display.newCircle( 100, 100, 50 )
circle1.fill = {
type = "image",
filename = "background.png"
}
-- TextureResource-based fill
local texture = graphics.newTexture( { type="image", filename="background.png" } )
local circle2 = display.newCircle( 200, 100, 50 )
circle2.fill = {
type = "image",
filename = texture.filename, -- "filename" property required
baseDir = texture.baseDir -- "baseDir" property required
}