This works:
niceShape = Shape.new()
niceMatrix = Matrix.new(1, 0, 0, 1, -640, -960)
niceTexture = Texture.new("image1.png")
niceShape:setFillStyle(Shape.TEXTURE, niceTexture, niceMatrix)
niceShape:beginPath()
niceShape:moveTo(0,0)
niceShape:lineTo(-640,0)
niceShape:lineTo(-640,-960)
niceShape:lineTo(0,-960)
niceShape:closePath()
niceShape:endPath()
niceShape:setX(500)
niceShape:setY(700)
niceShape:setScale(0.5)
stage:addChild(niceShape) |
but when I subsequently try this:
niceTexture:setTexture("image2.png") |
or this:
niceTexture:setTexture(Texture.new("image2.png")) |
I get the following error:
"attempt to call method 'setTexture' (a nil value)" |
Any help would be appreciated.
Kate's Catalogue of Travelling Theatre Centres :Meet Kate. Grey is her favourite colour. Maths is her favourite subject. Decency is her favourite type of behaviour.
She definitely does not like jewellery or modelling, but loves aeroplanes and other machines made of aluminium.
Comments
What, as I understood, you want to achieve, is to change the fill texture of the Shape.
There are 2 ways to do it:
1) call niceShape:clear() and do all the same thing again you did in first snippet but with other texture
2) use RenderTarget to fill the Shape, and simply change what you render in RenderTarget by calling draw method
Hope that helps
Since "setTexture" works perfectly well on the texture-filled "Bitmap" class, I assumed it would work in exactly the same way on the texture-filled "Shape" class.
Oh well.
Meet Kate. Grey is her favourite colour. Maths is her favourite subject. Decency is her favourite type of behaviour.
She definitely does not like jewellery or modelling, but loves aeroplanes and other machines made of aluminium.