set texture at runtime

Started by angieIe, November 20, 2014, 08:53:46 AM

Previous topic - Next topic

angieIe

hai, i want to change texture in plane when i click button. how to do it? thank you

Wolf17

#1
 It is simple.....Just for the start , the most simple and basic would be like this-
1.Make sure u have all the texture to be switched in the memory .That means , load all your textures when initially creating the world .
2.Apply your first texture on the object while creating world/scene .
3. For switching texture -->
Have your touch/button clicking condition checked (Like in helloworld sample see the  touchturn("if "condition) or something like that in the ondrawframe ).
Inside that ,set the second texture on the desired object in the ondrawframe . But yes ..you have to make sure that you do that only once or  it would throw an  error .
You can do that by having a boolean global variable  set to false ( secondtexapplied=false)..And then inside your  button/touch logic  in  ondrawframe ....
if(secondtexapplied==false)
{
change/apply second tex on object
secondtexapplied==true;
}

angieIe

Thank you Wolf17 for the answer  ;)