This site requires JavaScript, please enable it in your browser!
Greenfoot back
Black0utHD
Black0utHD wrote ...

2013/6/20

Project. Space Invaders

Black0utHD Black0utHD

2013/6/20

#
Hey there i have a question about programming this Game. I just tried to create a Game with Greenfoot to increase my programming ablitys but something gone wrong so i hope someone can help me to find the mistake :/
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class wombat here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class wombat extends Actor
{
    /**
     * Act - do whatever the wombat wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    public void act() 
    {
        move();
    }
    
    private void move();{
        int x = getX();
        int y = getY();
        if(Greenfoot.isKeyDown("right"))
        {
            setLocation(x + 2, y);
        }
        else if(Greenfoot.isKeyDown("left"))
        {
            setLocation(x - 2, y);
        }
    
    

-Black0utHD
Line 20, you have a ";" right after a method name, causing the error.
Black0utHD Black0utHD

2013/6/24

#
okay thank you
You need to login to post a reply.