类型 函数 返回值 TextureResourceExternal 版本 发行版 2024.3703 关键字 steam、steamworks、newTexture 另请参阅 steamworks.getAchievementImageInfo() steamworks.getUserImageInfo() steamworks.newImageRect() steamworks.*
通过其由 steamworks.getAchievementImageInfo() 或 steamworks.getUserImageInfo() 函数检索到的唯一 imageHandle,加载 Steam 图片到 纹理。
返回的 纹理 可以通过 display.newImage() 和 display.newImageRect() 函数显示。该 纹理 还可以通过其 填充 属性应用到现有 ShapeObject。
在下列情况下,此函数将返回 nil
false
,表示应用程序当前未连接到 Steam 客户端。steamworks.newTexture( imageHandle )
数字. 作为纹理加载的 Steam 图片的唯一标识符。此标识符由 ImageInfo 对象的 imageHandle 属性提供。
local steamworks = require( "plugin.steamworks" ) -- Create a rectangle which we'll later fill with the avatar image local defaultAvatarWidth = 184 * display.contentScaleX local defaultAvatarHeight = 184 * display.contentScaleY local avatarImage = display.newRect( display.contentCenterX, display.contentCenterY, defaultAvatarWidth, defaultAvatarHeight ) -- Updates the above display object's "fill" to show the newest large avatar image local function updateAvatar() -- Attempt to fetch info about the user's large avatar image local imageInfo = steamworks.getUserImageInfo( "largeAvatar" ) if ( imageInfo == nil ) then return end -- Load the avatar image into a new texture resource object local newTexture = steamworks.newTexture( imageInfo.imageHandle ) if ( newTexture == nil ) then return end -- Update the display object to show the avatar image avatarImage.fill = { type = "image", filename = newTexture.filename, baseDir = newTexture.baseDir } -- Release the texture reference newTexture:releaseSelf() end -- Attempt to update the display object with Steam's current image, if available -- If not currently available, this function call will trigger Steam to download it -- In this case, it dispatches a "userInfoUpdate" event to be received below updateAvatar() -- Set up a listener to be called when a user's info has changed local function onUserInfoUpdated( event ) -- Update display object only when the current user's avatar changes if ( steamworks.userSteamId == event.userSteamId ) then if ( event.largeAvatarChanged ) then updateAvatar() end end end steamworks.addEventListener( "userInfoUpdate", onUserInfoUpdated )