mitrolex wrote...
How do i change the location of those images(strings or whatever they are..) within a loop?image1.drawImage(image2, offfsetX, offsetY);
for (int i=0; i<data.length; i++)
image1.drawImage(image2, offfsetX, offsetY);
for (int i=0; i<data.length; i++)
import greenfoot.*;
import java.io.*;
public class rank extends Actor
{
boolean p = false;
rankSlika rs = new rankSlika();
rankListaIme rli = new rankListaIme();//This is for all the names from the file.
rankListaPoeni rlp = new rankListaPoeni();//And this is for all the scores from the file.
Color c = new Color(0,0,0,0);
int g = 0;
public void act()
{
if(Greenfoot.mouseClicked(this))
{
g++;
bg b = (bg)getWorld();
p = true;
getWorld().addObject(rs,b.getWidth()/2,b.getHeight()/2);
getWorld().addObject(rli,b.getWidth()/2-112,b.getHeight()/2-112);//Names
getWorld().addObject(rlp,b.getWidth()/2+180,b.getHeight()/2-112);//Scores
while(p==true)
{
b.citanje();
b.rank();
p=false;
}
for (int n=0; n<b.data.length; n++)
{
rli.setImage(new GreenfootImage(b.ime, 35, Color.BLACK, c));//Names
rlp.setImage(new GreenfootImage(""+b.poeni, 35, Color.BLACK, c));//Scores
}
}
if (Greenfoot.mouseClicked(this)&&g>=2)
{
getWorld().removeObject(rs);
getWorld().removeObject(rli);
getWorld().removeObject(rlp);
g=0;
}
}
}
GreenfootImage image = new GreenfootImage(200, 30*b.data.length); //30 should be the height of one image (you could check the size of the current image)
for (int n=0; n<b.data.length; n++)
{
image.drawImage(new GreenfootImage(b.ime, 35, Color.BLACK, c), 0, 30*n);
image.drawImage(new GreenfootImage(""+b.poeni, 35, Color.BLACK, c), 50, 30*n);
}import greenfoot.*;
import java.io.*;
public class rank extends Actor
{
boolean p = false;
rankSlika rs = new rankSlika();
rankListaPoeni rlp = new rankListaPoeni();
Color c = new Color(0,0,0,0);
public void act()
{
int g=0;
if(Greenfoot.mouseClicked(this))
{
g++;
bg b = (bg)getWorld();
p = true;
getWorld().addObject(rs,b.getWidth()/2,b.getHeight()/2);
getWorld().addObject(rlp,b.getWidth()/2+180,b.getHeight()/2-112);
while(p==true)
{
b.citanje();
b.rank();
p=false;
}
int nMax=b.data.length;
if(b.data.length>=10)
{
nMax=10;
}
int h = nMax*24;
GreenfootImage image = new GreenfootImage(900, h+28*nMax);
for (int n=0; n<nMax; n++)
{
image.drawImage(new GreenfootImage(n+1+"."+(String)b.data[n][0]+":"+(Integer)b.data[n][1], 35, Color.BLACK, c), 105, h+28*n);
rlp.setImage(image);
}
}
if(Greenfoot.mouseClicked(rlp))
{
getWorld().removeObjects(getWorld().getObjects(rankSlika.class));
getWorld().removeObjects(getWorld().getObjects(rankListaPoeni.class));
}
}
} import greenfoot.*;
import java.io.*;
public class rank extends Actor
{
rankSlika rs = new rankSlika();
rankListaPoeni rlp = new rankListaPoeni();
Color c = new Color(0,0,0,0);
public void act()
{
if(Greenfoot.mouseClicked(this))
{
bg b = (bg)getWorld();
getWorld().addObject(rs,b.getWidth()/2,b.getHeight()/2);
getWorld().addObject(rlp,b.getWidth()/2+180,b.getHeight()/2-112);
b.citanje();
b.rank();
int nMax=b.data.length;
if(b.data.length>=10)
{
nMax=10;
}
int h = 250;
GreenfootImage image = new GreenfootImage(900, h+28*nMax);
for (int n=0; n<nMax; n++)
{
image.drawImage(new GreenfootImage(n+1+"."+(String)b.data[n][0]+":"+(Integer)b.data[n][1], 35, Color.BLACK, c), 105, h+28*n);
}
rlp.setImage(image);
}
if(Greenfoot.mouseClicked(rlp))
{
getWorld().removeObjects(getWorld().getObjects(rankSlika.class));
getWorld().removeObjects(getWorld().getObjects(rankListaPoeni.class));
}
}
} setLocation(getX()-getWorld().getHeight()/2+50+image.getWidth()/2, getY());
setLocation(getX(), getY()-getWorld().getHeight()/2+50+image.getHeight()/2);