texture:draw()

类型 函数
对象 TextureResourceCanvas
graphics.*
修订版本 版本 2024.3703
另请参阅 TextureResource
TextureResourceCanvas
texture:invalidate()

概述

此方法将一个 显示对象 添加/渲染到 TextureResourceCanvas 对象的内部渲染队列中。所有排队对象的渲染都在调用 texture:invalidate() 之后发生。

陷阱

将显示对象插入渲染队列也会将该对象从其当前的 舞台 中移除,因为对象不能存在于多个组中。

语法

texture:draw( object )
对象 (必填)

DisplayObject. 要插入到渲染队列中的对象。

示例

local tex = graphics.newTexture( { type="canvas", width=128, height=128 } )

-- Create a circle and draw/render it to the texture
local circ = display.newCircle( 0, 0, 64 )
circ:setFillColor( { type="gradient", color1={0,0.2,1}, color2={0.8,0.8,0.8}, direction="down" } )
tex:draw( circ )

-- Schedule texture objects to be rendered to texture before next frame
tex:invalidate()