Game Development Community

How do I get the texture?

by Giuseppe De Francesco · in Torque X 2D · 11/19/2009 (9:27 pm) · 2 replies

Hi all,

let's see if anyone has already found this before to start digging :) I need to get the current texture assigned to my animated sprite. In the code I'm in the component's delegate
private void _OnFrameChange(int frame)
I see (in debug) that the base texture is available in the Material property but is private so I cannot access to it: any trick to do that?

About the author

In the software eng. field since 1981, in charge of R&D during last 10 years. IEEE Senior Member (and volunteer).


#1
11/20/2009 (10:58 am)
This will give you a reference to the Texture2D being used on an animated sprite:

(myAnimSprite.AnimationData.Material as SimpleMaterial).Texture.Instance as Texture2D
#2
11/20/2009 (5:17 pm)
Hi Duncan,

thank you very much for the pointer. Actually because my object is light reactive that one won't work, but simply changing it to this:

(_animatedSprite.AnimationData.Material as LightingMaterial).Texture.Instance as Texture2D

gets me the base texture :)

Thanks again ;)
Pino