Author Topic: set texture at runtime  (Read 2106 times)

Offline angieIe

  • byte
  • *
  • Posts: 29
    • View Profile
set texture at runtime
« on: November 20, 2014, 08:53:46 am »
hai, i want to change texture in plane when i click button. how to do it? thank you

Offline Wolf17

  • int
  • **
  • Posts: 77
    • View Profile
Re: set texture at runtime
« Reply #1 on: November 21, 2014, 06:22:57 am »
 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;
}
« Last Edit: November 21, 2014, 06:24:47 am by Wolf17 »

Offline angieIe

  • byte
  • *
  • Posts: 29
    • View Profile
Re: set texture at runtime
« Reply #2 on: November 24, 2014, 02:10:23 am »
Thank you Wolf17 for the answer  ;)