In there is not find error but when run, the object can't move like we hope ..
Can help me .. Please ..
import greenfoot.*;
/**
* Write a description of class Pindah here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Pindah extends Actor
{
public int jmlKey;
World ourWorld = getWorld();
public void act()
{
if(Greenfoot.isKeyDown("space"))
{
Actor sA = getOneIntersectingObject(A.class);
Actor sB = getOneIntersectingObject(B.class);
Actor sC = getOneIntersectingObject(C.class);
Actor sD = getOneIntersectingObject(D.class);
jmlKey++;
if(jmlKey == 0)
{
sA.setLocation (125, 300);
sA.setImage("SegMerAtas.png");
sB.setLocation (95, 330);
sB.setImage("SegBirKiri.png");
sC.setLocation (125, 360);
sC.setImage("SegKunBawah.png");
sD.setLocation (155, 330);
sD.setImage("SegHijKanan.png");
}
if(jmlKey == 1)
{
sD.setLocation (125, 300);
sD.setImage("SegHijAtas.png");
sA.setLocation (95, 330);
sA.setImage("SegMerKiri.png");
sB.setLocation (125, 360);
sB.setImage("SegBirBawah.png");
sC.setLocation (155, 330);
sC.setImage("SegKunKanan.png");
/*setImage("SegHijAtas.png", 125, 300);
setImage("SegMerKiri.png", 95, 330);
setImage("SegBirBawah.png", 125, 360);
setImage("SegKunKanan.png",155, 330 );
//break;
*/
}
if(jmlKey == 2)
{
sC.setLocation (125, 300);
sC.setImage("SegKunAtas.png");
sD.setLocation (95, 330);
sD.setImage("SegHijKiri.png");
sA.setLocation (125, 360);
sA.setImage("SegMerBawah.png");
sB.setLocation (155, 330);
sB.setImage("SegBirKanan.png");
}
if(jmlKey == 3)
{
sB.setLocation (125, 300);
sB.setImage("SegBirAtas.png");
sC.setLocation (95, 330);
sC.setImage("SegKunKiri.png");
sD.setLocation (125, 360);
sD.setImage("SegHijBawah.png");
sA.setLocation (155, 330);
sA.setImage("SegMerKanan.png");
}
if(jmlKey>3)
sA.setLocation (125, 300);
sA.setImage("SegMerAtas.png");
sB.setLocation (95, 330);
sB.setImage("SegBirKiri.png");
sC.setLocation (125, 360);
sC.setImage("SegKunBawah.png");
sD.setLocation (155, 330);
sD.setImage("SegHijKanan.png");
jmlKey = 0;
}
}
}
/*
if(Greenfoot.isKeyDown("space")==true)
{
getWorld();
A.class.setLocation(90, 230);
}*/
