This site requires JavaScript, please enable it in your browser!
Greenfoot back
hikkikomori008
hikkikomori008 wrote ...

2015/10/14

What's wrong from this script :( Help Me Pleas ..

hikkikomori008 hikkikomori008

2015/10/14

#
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); }*/
danpost danpost

2015/10/14

#
From what I can tell, the images should be changing when the 'space' is pressed; however, hyperactively. As far as movement -- you are rotating the locations of the four actors among the same locations. So, there would be no apparent movement -- just the apparent changing of the images.
You need to login to post a reply.