Difference between revisions of "Pixel:setTexturePosition"

From GiderosMobile
m (Text replacement - "</source>" to "</syntaxhighlight>")
Line 1: Line 1:
 
__NOTOC__
 
__NOTOC__
 
'''Available since:''' Gideros 2011.6<br/>
 
'''Available since:''' Gideros 2011.6<br/>
'''Class:''' [[Special:MyLanguage/Pixel|Pixel]]<br/>
+
'''Class:''' [[Pixel]]<br/>
  
 
=== Description ===
 
=== Description ===
Sets the texture's position.
+
Sets the texture position.
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
 
Pixel:setTexturePosition(x,y)
 
Pixel:setTexturePosition(x,y)
Line 10: Line 10:
  
 
=== Parameters ===
 
=== Parameters ===
'''x''': (number) x-coordinate of texture <br/>
+
'''x''': (number) texture x coordinate<br/>
'''y''': (any) y-coordinate of texture <br/>
+
'''y''': (number) texture y coordinate<br/>
  
 
=== Example ===
 
=== Example ===
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- a pixel holding a repeatable power of 2 texture
+
-- a pixel holding a repeatable texture
 
local tex = Texture.new("gfx/image.jpg", true, {wrap = TextureBase.REPEAT})
 
local tex = Texture.new("gfx/image.jpg", true, {wrap = TextureBase.REPEAT})
 
local img = Pixel.new(tex, tex:getWidth(), tex:getHeight())
 
local img = Pixel.new(tex, tex:getWidth(), tex:getHeight())

Revision as of 21:43, 7 November 2023

Available since: Gideros 2011.6
Class: Pixel

Description

Sets the texture position.

Pixel:setTexturePosition(x,y)

Parameters

x: (number) texture x coordinate
y: (number) texture y coordinate

Example

-- a pixel holding a repeatable 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)