Unlimited wrote...
are there other ways to work around the problem with the plattforms? As you could probably asume im trying to create a game like megaman x or gunvolt.
/**
* This will return an object at offset (x,y) if its image is colored at the offset
*/
public Actor getAnObjectAtOffset(int x, int y, Class clss){
GreenfootImage img=getImage();
Actor actor = getOneObjectAtOffset(x,y,clss);
if(actor!=null) {
int imgx=getX()+x-(actor.getX()-actor.getImage().getWidth()/2);
int imgy=getY()+y-(actor.getY()-actor.getImage().getHeight()/2);
if (actor.getImage().getColorAt(imgx,imgy).getAlpha()<=0)actor=null;
}
return actor;
}public void horizontalMovement()
{
int dir = 0;
if (Greenfoot.isKeyDown("left")) dir--;
if (Greenfoot.isKeyDown("right")) dir++;
setLocation(getX()+xSpeed*dir);
// collision
Actor.actor = getOneIntersectingObject(Actor.class);
if (actor != null) setLocation(actor.getX()-dir*(actor.getImage().getWidth()+getImage().getWidth())/2);
// image
if (dir == -1 && animSet != leftAnim) setAnim(leftAnim, 6);
else if (dir == 0 && animSet != standAnim) setAnim(standAnim, 2);
else if (dir == 1 && animSet != rightAnim) setAnim(rightAnim, 6);
}