Good day,
For the past half a day, I've fixed, changed and reopened greenfoot in order to get to the point I am at with still the same problem(though probably fixed some other ones in the process). The game reports an error/crash when I place the 'Player' in the world and run the scenario due to (what I am sure is te problem) the following lines of code:
My assumption is that, since the scenario immediately stops only when I have just started with a 'Player object' in the world, the error has to be either in the instantiation of the 'Player' (though the error would be when you add the object to the world in that case) or in the first thing that runs, which is the act method.
In case I am wrong, I will provide part of the 'movePlayer()' method below:
Hope some clear conclusion can be made so that this error does not happen again! (also, are there any similar threads on the same mistake?)
Thank you!
public void act()
{
while(Greenfoot.isKeyDown(null))//prevents the player moving more than once per button press
{
movePlayer(); //see method below, moves the player
}
if(!Greenfoot.isKeyDown(null)) //this line permits the player to move again
{
move = false;
}
} public void movePlayer()
{
if(Greenfoot.isKeyDown("w") && move==true) //Moves player up
{
x = getX();
y = getY();
setLocation(x, (y-speedSet()) );
if(isTouching(Wall.class))
{
setLocation (x,y+speedSet());
}
}

