ja ich möchte gerne das mein charackter den ball kicken kann
es so Funktionieren
http://www.spielaffe.de/Spiel/Kickende_Koepfe
möchte genau das spiel programmieren
public class ball extends Actor
{
/**
* Act - do whatever the ball wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
{
boy1HitIt();
}
public void boy1HitIt()
{
Actor boy1;
player=getOneObjectAtOffset(0,0,boy1.class);
if (boy1 !=null)
{
setLocation(getX()-4, getY());
}
}
}
und das ist der spieler
was fehlt mir???????
public class boy1 extends Actor
{
/**
* Act - do whatever the boy1 wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
private int speed = 2; //movement speed
private int vSpeed = 2; //vertical speed
private int acceleration = 2; //gravity effect while falling
private int jumpStrength = -8;
public void act()
{
checkKeys();
checkFall();
jump();
}
public void checkKeys()
{
if( Greenfoot.isKeyDown("a"))
{
move(-5);
}
if(Greenfoot.isKeyDown("d"))
{
move(5);
}
if(Greenfoot.isKeyDown("w"))
{
jump();
}
}
public void jump()
{
if (Greenfoot.isKeyDown("w"))
{
vSpeed = jumpStrength;
checkFall();
}
}
public void checkFall()
{
setLocation(getX(), getY()+vSpeed);
vSpeed = vSpeed + acceleration;
}
}