import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class Plattform here. * * @author (your name) * @version (a version number or a date) */ public class Plattform extends Actor { boolean geloescht= false; /** * Act - do whatever the Plattform wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public void act() { this.scrollNachUnten(); if(geloescht) { this.loescheMich(); } // Add your action code here. } public void scrollNachUnten() { MyWorld welt= (MyWorld) getWorld(); setLocation(this.getX(),this.getY()+2); // Nach unten turnen if(this.getY()>= welt.getHeight()-5 ||this.getY()<=0) { geloescht= true; } } public void loescheMich() { getWorld().removeObject(this); } public boolean PlayerOnPlattform() { Player Spieler= (Player) this.getWorld().getObjects(Player.class).get(0); if(Spieler.getX()+(Spieler.getImage().getWidth()/2)>=this.getX()-(this.getImage().getWidth()/2) && Spieler.getX()-(Spieler.getImage().getWidth()/2)<=this.getX()+(this.getImage().getWidth()/2)) { if(Spieler.getY()+(Spieler.getImage().getHeight()/2)<=this.getY()-(this.getImage().getHeight()/2) && Spieler.getY()+(Spieler.getImage().getHeight()/2)>=this.getY()-(this.getImage().getHeight()/2)) { return true; } else { return false; } } else { return false; } } }