Having some problems with my Collision routine. It all works, but I need to know when my sprite is 'falling' and after 2 days of trying to figure out how I do that, I thought I should post my code to see if see if anyone here has any suggestions!
Basically if I am on a platform, my CD routine is constantly correcting the sprites position as gravity pulls him down which is how I want it (constant gravity) But because it moves him out of collision (not colliding) and then into (colliding) and then out (not colliding) and then in (you get the idea), I can never really know when he isn't 'really' on a platform as it will report him as not being on a platform when he's basically 1 pixel above (and will be colliding in the next frame) - as well as when he is really falling.
Hope this is clear! I need to know as when he is truly falling, as I want to apply a different graphic.
You could keep track of the last time the character was on the platform, and if the time difference is more than a second or so, then change the animation. This also looks more natural, since a person doesn't immediately "notice" he's falling.
The mind is a strange and wonderful thing. I'm not sure that it will ever be able to figure itself out, everything else, maybe. From the atom to the universe, everything, except itself.
Joined: May 11, 2013
Hi Stephan, thanks for this. I managed to get around the problem.
I re-wrote my entire collision detection system so that gravity is switched off when my character is on a platform so it doesn't constantly 'fall' into the platform. Cheers.