Hi, Everyone!
When I use following code it works ok:
local mesh_texture = Texture.new("some-name.png", true, {wrap = Texture.REPEAT})
local mesh = Mesh.new()
mesh:setTexture(mesh_texture) |
But when I'd tried to replace Texture with TextureRegion:
local textures = TexturePack.new('tex.txt', 'tex.png')
local mesh_texture = textures:getTextureRegion('some-name.png')
local mesh = Mesh.new()
mesh:setTexture(mesh_texture) |
I got error message "bad argument #1 to 'setTexture' (TextureBase expected, got table)" (tex.txt contains line with item some-name.png). How should I pass TextureRegion object to the setTexture() method? I tried to do something like this:
local mesh_texture = Texture.new(textures:getTextureRegion('some-name.png')) |
but this code doesn't work also.
Comments
http://giderosmobile.com/forum/discussion/comment/21594#Comment_21594
Fragmenter - animated loop machine and IKONOMIKON - the memory game
local texture = TexturePack.new("cards.txt", "cards.png", true)
local region = texture:getTextureRegion("card3.png")
local x, y, w, h = region:getRegion()
local mesh = Mesh.new()
mesh:setVertexArray(0, 0, 90, 0, 90, 128, 0, 128)
mesh:setIndexArray(1, 2, 3, 1, 3, 4)
mesh:setTextureCoordinateArray(x, y, x + w, y, x + w, y + h, x, y + h)
mesh:setTexture(texture)
stage:addChild(mesh)
Fragmenter - animated loop machine and IKONOMIKON - the memory game
I don't remember now if it was a technical limitation (probably it was), but you can fill the Shape/Mesh with texture region
what you can do is to use TexturePack, which also inherits from TextureBase