[messages] [Module Design] Custom Java class blinking effect

Mu0n micjuneau at gmail.com
Tue Apr 25 20:58:24 CEST 2017


I solved it, I used a Timer():

final Timer timer = new Timer();
            timer.schedule(new TimerTask() {
                int count = 1;
                @Override
                public void run() {
                    try{
//do stuff
//control how many times using the count variable
                        }
                    } catch (Exception e) {

                    }
                }
            }, 0,DELAYBETWEENFLASHES);
        }

to achieve the blink, I used an an anonymous class that implements
Drawable,
in the draw function, I use a boolean toggle which alternates between:

1) drawing the shape
2) repainting the map

there are probably some optimisations to do, but I'm working on other
more urgent things for my module and it's good enough.
Sometimes, the last "flash" of my blink (which uses a transparent alpha
colored shape) will stay drawn at the end of the cycle but will
disappear if you move the mouse or click somewhere in the background of
the Map.

_______________________________________________
Read this topic online here:
http://www.vassalengine.org/forum/viewtopic.php?p=53494#p53494


More information about the messages mailing list