Difference between revisions of "Pixel:setTexturePosition"

From GiderosMobile
 
(8 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
__NOTOC__
 
__NOTOC__
'''<translate>Available since</translate>:''' Gideros 2011.6<br/>
+
'''Available since:''' Gideros 2016.12<br/>
=== <translate>Description</translate> ===
+
'''Class:''' [[Pixel]]<br/>
<translate>Sets the texture's position</translate>
+
 
<source lang="lua">
+
=== Description ===
Pixel:setTexturePosition(x,y)
+
Sets the texture position inside the Pixel.
</source>
+
<syntaxhighlight lang="lua">
=== <translate>Parameters</translate> ===
+
Pixel:setTexturePosition(x,y)
'''x''': (number) <translate>x-coordinate of texture</translate> <br/>
+
</syntaxhighlight>
'''y''': (any) <translate>y-coordinate of texture</translate> <br/>
+
 
 +
=== Parameters ===
 +
'''x''': (number) Pixel texture x coordinate<br/>
 +
'''y''': (number) Pixel texture y coordinate<br/>
 +
 
 +
=== Example ===
 +
<syntaxhighlight lang="lua">
 +
-- a pixel holding a power of 2 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)
 +
</syntaxhighlight>
 +
 
 +
{{Pixel}}

Latest revision as of 01:47, 8 November 2023

Available since: Gideros 2016.12
Class: Pixel

Description

Sets the texture position inside the Pixel.

Pixel:setTexturePosition(x,y)

Parameters

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

Example

-- a pixel holding a power of 2 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)