Hi guys, me annoying again ;)
My problem is that this code does not increase the int value of a given index, its in a button class that should get covered green if its clicked, the more often it is clicked, the more green the button should get!
The code of Clicked just simply:
Thanks for help again!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | if (index!= 0 ) { getImage().setColor(Color.green); getImage().fillRect( 0 , 0 ,(getImage().getWidth()/ 10 )*UserInfo.getMyInfo().getInt(index),height); getImage().setColor( new Color( 155 , 0 , 0 )); getImage().drawString( "Cost: " +UserInfo.getMyInfo().getInt(index)* 10 ,getImage().getWidth()/ 2 -fm.stringWidth( "Cost: " +UserInfo.getMyInfo().getInt(index)* 10 )/ 2 ,height/ 2 +fm.getHeight()/ 4 ); if (Clicked()) { UserInfo.getMyInfo().setInt(index,UserInfo.getMyInfo().getInt(index)+ 1 ); UserInfo.getMyInfo().store(); } } |
1 2 3 4 5 | public boolean Clicked() { if (Greenfoot.mouseClicked( this )) return true ; else return false ; } |