java - Scale an image with Graphics2D -


in game making want power ups airdrops. have image of crate want draw bigger have drawn it. want image become progressively smaller times looks it's dropped air. have crafted code think should work reason doesn't.

if(power.getpowerup()){    double cratex = (int) power.getx();    double cratey = (int) power.gety();    image crate = power.getcrate();    int cratew = crate.getwidth(null) + 100;    int crateh = crate.getheight(null) + 100;    if(cratew > 64){       g2d.drawimage(          power.getcrate(), (int) cratex, (int) cratey, cratew, crateh, );       cratex += .5;       cratex += .5;       cratew -= 1;       crateh -= 1;    }    else {       g2d.drawimage(          power.getcrate(), (int) cratex, (int) cratey, cratew, crateh, );    } } 

i have method inside paintcomponent(graphics g) , use thread repaint graphics. why doesn't work? have use values class? how make progressively smaller?

you recreating cratew , crateh variables everytime method called. method goes either if or else block, never goes else (what want) after having gone if block. in other words, width , heights same next time method called.


Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -