Difference between revisions of "Pixel:setTextureMatrix"

From GiderosMobile
(added example)
m (Text replacement - "<source" to "<syntaxhighlight")
Line 5: Line 5:
 
=== Description ===
 
=== Description ===
 
Sets the matrix of the Pixel's texture.
 
Sets the matrix of the Pixel's texture.
<source lang="lua">
+
<syntaxhighlight lang="lua">
 
Pixel:setTextureMatrix(matrix)
 
Pixel:setTextureMatrix(matrix)
 
</source>
 
</source>
Line 13: Line 13:
  
 
=== Example ===
 
=== Example ===
<source lang="lua">
+
<syntaxhighlight lang="lua">
 
-- a pixel holding a repeatable power of 2 texture
 
-- a pixel holding a repeatable power of 2 texture
 
local tex = Texture.new("gfx/myimg.jpg", false, {wrap = TextureBase.REPEAT})
 
local tex = Texture.new("gfx/myimg.jpg", false, {wrap = TextureBase.REPEAT})

Revision as of 14:30, 13 July 2023

Available since: in development
Class: Pixel

Description

Sets the matrix of the Pixel's texture. <syntaxhighlight lang="lua"> Pixel:setTextureMatrix(matrix) </source>

Parameters

matrix: (Matrix) the matrix

Example

<syntaxhighlight lang="lua"> -- a pixel holding a repeatable power of 2 texture local tex = Texture.new("gfx/myimg.jpg", false, {wrap = TextureBase.REPEAT}) local img = Pixel.new(tex, tex:getWidth(), tex:getHeight()) stage:addChild(img) -- the matrix local m = Matrix.new() -- some vars local flow = 0 local flowspeed = 0.09

function onEnterFrame(e) flow += flowspeed m:setRotationZ(math.sin(flow)) -- rotate matrix on Z axis img:setTextureMatrix(m) -- apply modified matrix end

stage:addEventListener(Event.ENTER_FRAME, onEnterFrame) </source>