import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class UnactiveSpike here. * * @author (your name) * @version (a version number or a date) */ public class UnactiveSpike extends Actor { int countdown; int speed; boolean geloescht=false; public UnactiveSpike(int pSpeed, int pCoundown, SpikedPlattform pPlattform) { speed=pSpeed; countdown=pCoundown; } /** * Act - do whatever the UnactiveSpike wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public void act() { this.bewege(); countdown--; if(countdown==0) { MyWorld theWorld= (MyWorld) this.getWorld(); Spike BeispielSpike=new Spike(1); GreenfootImage SpikeImage= BeispielSpike.getImage(); theWorld.addObject(new Spike(speed), this.getX(), (this.getY()- this.getImage().getHeight()/2)-10); //die Zahl Minus damit ist endlich passt geloescht=true; } if(geloescht) { this.loescheMich(); } } public void loescheMich() { MyWorld theWorld= (MyWorld) this.getWorld(); theWorld.removeObject(this); } public void bewege() { this.setLocation(this.getX(), this.getY()+speed); MyWorld theWorld= (MyWorld) this.getWorld(); if(this.getY()>=theWorld.getHeight()-5) { geloescht=true; } } }