I have code in which when you press the spacebar you jump, yet if you hold the spacebar down the actor just floats upwards
then this i called to move the player
1 | if (Greenfoot.isKeyDown( "space" )&&!canSee( 0 ,- 2 )){ if (jump== true ){Y=- 1 ;jump= false ;} else {jump= true ;}} else if (canSee( 0 , 2 )){Y= 0 ;} else {Y= 0.5 ;} |
1 | setLocation(getX()+X,getY()+Y); |