SpikedPlattforms2
This commit is contained in:
+17
-1
@@ -21,10 +21,26 @@ public class Spike extends Actor
|
||||
public void act()
|
||||
{
|
||||
// Add your action code here.
|
||||
this.setLocation(this.getX(), this.getY()+speed);
|
||||
if(this.isTouching(Player.class))
|
||||
{
|
||||
Greenfoot.setWorld(new GameOverWorld());
|
||||
}
|
||||
this.bewege();
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
this.loescheMich();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user