1

I am a beginner at Raylib and I was wondering how to hide an image or sprite in Raylib?

code example:

DrawCircle(400,400,100,RED);//circle 1
DrawCircle(200,200,50,RED); //circle 2
//here is where i want a funtion just to delete/hide circle 2
josephi
  • 81
  • 1
  • 1
  • 5
  • 2
    I don't know Raylib. Can't you just not draw it? – user253751 Sep 08 '20 at 12:06
  • 1
    When asking questions it helps us help you immensely if you can show a minimal amount of code that works, so that we can point at parts of it or rewrite parts in an answer. – Botje Sep 08 '20 at 12:33

3 Answers3

1

I believe there's no real way of undrawing something but you could easily control whether you draw it or not in the first place like so:

int condition = 1;

DrawCircle(400,400,100,RED);//circle 1

if(condition == 0)
{   
    // Circle is only drawn when condition is true
    DrawCircle(200,200,50,RED); //circle 2
}
0

Maybe you can change the radius to 0 when you want to hide it:

float radius{ 50 };   
while(!WindowShouldClose()){
   DrawCircle(400,400,radius,RED);
   if(condition)
       radius = 0; //hide circle
   else{
     radius  = 50;
     }
   }
0

If you want to "draw" an invisible circle for, say, collision. Then you should implement your own, see https://github.com/raysan5/raylib/blob/master/src/rshapes.c for the example, look at the functions with "DrawCircle" in it.

Qognitive
  • 1
  • 3
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - [From Review](/review/late-answers/32286005) – Nol4635 Jul 25 '22 at 22:11