Difference between revisions of "Pixel:setTexturePosition"

From GiderosMobile
(added example)
m (Text replacement - "<source" to "<syntaxhighlight")
Line 5: Line 5:
 
=== Description ===
 
=== Description ===
 
Sets the texture's position.
 
Sets the texture's position.
<source lang="lua">
+
<syntaxhighlight lang="lua">
 
Pixel:setTexturePosition(x,y)
 
Pixel:setTexturePosition(x,y)
 
</source>
 
</source>
Line 14: Line 14:
  
 
=== 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/image.jpg", true, {wrap = TextureBase.REPEAT})
 
local tex = Texture.new("gfx/image.jpg", true, {wrap = TextureBase.REPEAT})

Revision as of 15:30, 13 July 2023

Available since: Gideros 2011.6
Class: Pixel

Description

Sets the texture's position. <syntaxhighlight lang="lua"> Pixel:setTexturePosition(x,y) </source>

Parameters

x: (number) x-coordinate of texture
y: (any) y-coordinate of texture

Example

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

function onEnterFrame(e) flow += flowspeed img:setTexturePosition(0, flow) -- move the texture pixel on y axis end

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