Creating a shooting game i run into an what seemed simple at first but unsolvable problem for me.
I want (on keypress) lightning to shoot up out of the world // working
Lightning to find enemy and setLocation on that enemy // working
Want lightning to stay at that exact location while running rest of code // not working, keeps following enemy as enemy moves.
following code is the working part to setLocation of that enemy. (and i dont want it to move cause it needs to strike, needs to be there, expand and dissapear.
Hope some1 understands my question and can help me. Like i said. All i want is for it to just stay on location its given. Tried lotta different options for almost 2 days now... cant figure it iout.
Please advise. Thanks
public void seaker2() { if (counter > 100) { int enm =0; int range= getWorld().getWidth()*getWorld().getHeight(); List<Enemy> l = (List<Enemy>) getObjectsInRange(range,Enemy.class); if (l.size() >= 1) { int e = l.get(enm).getX(); int f = l.get(enm).getY()-(getImage().getHeight()/2); setImage(l6); setLocation(e,f); } } else if (l.size() <= 0) { getWorld().removeObject(this); } }