java - How do I change the sprite in the timer when the object is created but is not visible camera? -


i want change sprite after time if object not visible camera. have method creates object

 private void spawnraindrop() {     rectangle raindrop = new rectangle();     raindrop.x = mathutils.random(0, drop.width - 100);     raindrop.y = drop.width;     raindrop.width = 100;     raindrop.height = 100;     raindrops.add(raindrop);     lastdroptime = timeutils.nanotime(); }  have method changes time interval through sprites:  public void timerspritechange() {      timer timer = new timer();     timer.schedule(new timer.task() {                        @override                        public void run() {                                  index = ((int) (math.random() * max_sprites));                           }                    }              , 0, 5);  } 

here check , compare time , call method

  if (timeutils.nanotime() - lastdroptime > 1000000000) {              spawnraindrop();          } 

orthographiccamera camera;

have thought of making boolean 'raindropvisible' when create object , spawn it, sets boolean true, when game disposes of it, sets false. make timer check if boolean false, , if is, change sprite?


Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -