Pixel:setTexturePosition

From GiderosMobile
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

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)