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

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -