Timon wrote...
No. Now when I press no bottom and a box came he is going underthe box and after the box he Comes up.
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class Boxes here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Boxes extends Objects
{
/**
* Act - do whatever the Boxes wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
this.move();
this.despawning();
}
}
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class Objects here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Objects extends Actor
{
/**
* Act - do whatever the Objects wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
}
public void move()
{
move(-6);
}
public int score=0;
public void despawning()
{
if(this.isAtEdge())
{
getWorld().removeObject(this);
}
}
public void countScore()
{
score++;
setImage(new GreenfootImage("Score: " + score, 48, Color.WHITE, Color.BLACK));
}
}
Actor player = getOneIntersectingObject(Player.class); // adjust class name as needed if (player != null) player.move(-6);