For some reason the top row of my enemies always gets offset by 10 pixels when it hits the right edge howerver its fine whilst hitting the left? World code to add enemies:
Enemy code for movement:
public void addEnemies()
{
int x1 = 170;
for(int i=0;i<11;i++) {
addObject(new Enemy(), x1, 20);
x1+=60;
}
int x2 = 170;
for(int i=0;i<11;i++) {
addObject(new Enemy(), x2, 60);
x2+=60;
}
int x3 = 170;
for(int i=0;i<11;i++) {
addObject(new Enemy(), x3, 100);
x3+=60;
}
int x4 = 170;
for(int i=0;i<11;i++) {
addObject(new Enemy(), x4, 140);
x4+=60;
}
int x5 = 170;
for(int i=0;i<11;i++) {
addObject(new Enemy(), x5, 180);
x5+=60;
}
}public void move()
{
MyWorld world = (MyWorld)getWorld();
steps++;
if(steps==60)
{
setLocation(getX()+world.d, getY());
steps=0;
}
if(getX()==960)
{
world.d = -10;
setLocation(940, getY());
}
if(getX()==40)
{
world.d = 10;
setLocation(60, getY());
}
}
