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

2013/3/5

Ground detection issues

Draymothisk Draymothisk

2013/3/5

#
I know how to throw up barriers and hit detection and all, but for some reason whenever my character lands, he sinks 1 pixel lower with each landing. This happens for about an increase of getY()+8, then resets his landing to where it should be, then starts to sink 1 pixel lower with each landing again. He doesn't sink while on the ground, it is when he lands the next time around that he goes 1 pixel lower. Here is my code. (I also used "getOneIntersectingObject", and it had the same problem). My gravity method may be causing it, but I'm not sure. Actor bottom; bottom = getOneObjectAtOffset(0, 26, barriers.class ); if(bottom != null) { speedDown = 0; Gravity = 0; Ground = true; canJump = true; } else { gCount++; Ground = false; canJump = false; speedDown = speedDown; }
danpost danpost

2013/3/6

#
You can add a statement to place to object properly when on the ground:
setLocation(bottom.getY()-bottom.getImage().getHeight()/2-getImage().getHeight()/2);
You need to login to post a reply.