I'm trying to a simple scrolling engine, but I'm having difficulty. I'm trying to go through an array of classes, find all of them in a List, and set the location for each one in the list. However, I have to use this in order to use methods of the classes:
I tried making an array, but the Object's name is a symbol, and I don't have a way of storing a symbol. Does anyone know how to do this?
Here's my code:
(([Object's Name Here])[defined actor]).setLocation([Stuff Here]);
Class[] all = {Wall.class,Key.class,Block.class,Lava.class,Water.class}; public void scroll(String direction){ int v; int h; if (direction.equals("left"))h=getWidth(); if (direction.equals("right"))h=-getWidth(); if (direction.equals("up"))v=getHeight(); if (direction.equals("down"))v=-getHeight(); int a; while (a<all.length){ List object = getObjects(all[a]); if (! object.isEmpty()){ for (int i=0; i<object.size(); i++){ Actor Object = (Actor) object.get(i); if (Object!=null)Object.setLocation(getX()+h,getY()+v); //It won't let me do this; I have to replace "Object.setLocation();" with "(([Name Here])Object).setLocation();" } } a++; } }