Java game: temporarily draw image based on int field
<p>I'm new to <code>Java</code> and am making a game for <code>Android</code>.</p>

<p>I have a score counter in my game, and when the counter reaches a certain number I want a message to flash on the screen letting the player know they've reached level 2, etc. </p>

<p>All the other elements of <code>nextLevel</code> I have been able to implement easily, because these updated elements are supposed to retain their changes while in any given level. However, I'm confused about how to draw this "Level 2" image for only a few seconds once the player crosses the appropriate score threshold.</p>

<p>I tried using a boolean (nextlevel) like this:</p>

<pre><code>if (nextLevel){
            if (levelStart &lt; 70){
                paint5.setAlpha(255-(levelStart*4));
                paint7.setAlpha(255-(levelStart*4));
                g.drawString(String.valueOf(scoremult), g.getWidth()/2, g.getHeight()/2-100, paint5);
                g.drawString("x", (g.getWidth()/2)-40, g.getHeight()/2-100, paint7);
                levelStart++;
            }
            else {
                levelStart = 0;
            }
        }
</code></pre>

<p>But because <code>nextLevel</code> stays true the whole time the player is in the level, the message is drawn and fades over and over. What I want is something like an event trigger, where once the threshold is crossed, the draw loop runs until complete regardless of what else is happening in the program.</p>

<p>Here is how the 2nd level is implemented:</p>

<pre><code>if ((score&gt;=50)&amp;&amp;(score &lt; 125)){
        level = 1.2;
        scoremult = 2;
        recentinterval = 27;
        nextlevel = true;
</code></pre>

<p>Any suggestions?</p>
