You're using the move(int b) function. Essentially, it moves you some pixels (assuming that the cell size is 1 pixel) towards the direction you are facing. If you want gravity, move function just won't cut it: You will need to use the setLocation(int x, int y) function, and with gravity, you will need to store some integer value (if you are not going to use the smooth mover, although using that is highly recommended if you want good smooth jumps, but then you will need to use doubles or floats, but neither one don't work with the setLocation function by itself something that can be somewhat mitigated by typecasting) to store your y-speed value.
It'd look something like this
private int gravpull = 0;
public void act()
{
if(notTouchingGround())
{
gravpull ++;
setLocation(getX(), getY()+gravpull);
}
}
public boolean notTouchingGround()
{
blah blah blah, although in this case you can settle for return getY() < (some height);
}
Hope that helps.
and remember to reset and perhaps cap the gravity variable, because not resetting the variable will lead it to plummet unnaturally down when not on the ground. (a constant for the acceleration, and a variable for the actual movement.)
2011/10/26
2011/10/26
2011/10/29