object.imageHandle

类型 数字
修订版本 版本 2024.3703
关键词 steam, steamworks, 图像, 纹理, 头像, ImageInfo, imageHandle
另请参阅 ImageInfo
steamworks.*

概述

Steam 分配给图像的唯一临时整数标识符。用于通过 steamworks.newImageRect()steamworks.newTexture() 函数加载图像。

注意事项

不应将图像句柄保存到文件。Steam 分配给图像的唯一句柄可能会在应用程序后续启动后发生更改。

示例

local steamworks = require( "plugin.steamworks" )

-- Fetch information about the logged in user's avatar image
local imageInfo = steamworks.getUserImageInfo( "mediumAvatar" )
if ( imageInfo == nil ) then
    return
end

-- Use "steamworks.newImageRect()" to display avatar on left side of the screen
local imageAvatar = steamworks.newImageRect( imageInfo.imageHandle, 64, 64 )
if ( imageAvatar ) then
    imageAvatar.x = display.contentWidth * 0.25
    imageAvatar.y = display.contentCenterY
end

-- Use "steamworks.newTexture()" to display avatar on right side of the screen
local texture = steamworks.newTexture( imageInfo.imageHandle )
if ( texture ) then
    local textureAvatar = display.newRect( display.contentWidth*0.75, display.contentCenterY, 64, 64 )
    rectangle.fill =
    {
        type = "image",
        filename = texture.filename,
        baseDir = texture.baseDir
    }
    texture:releaseSelf()
end