I'm currently writing a 2d platformer for Android smartphones / tablets and I have a question regarding gravity.
I read up a bit before I applied gravity and from what I could tell, it seemed that gravity should be applied 'constantly' to characters (Like it is in real life).
By this, I mean, if the character is standing on a solid floor/platform, gravity will still be pulling him down.
My collision detection, will predict that his next position will be 'in' the platform and correct it before rendering. This way, when he isn't on a platform, he will just fall without me having to do anything extra.
However, I read an interesting article about how Sonic was made and it states that:
(Of gravity) This value is added to Y speed in every step in which Sonic isn't on the ground.
So I'm guessing they have a boolean value 'gravity' and just switch it true or false depending on when they want the gravity to be applied. (So false when on floor/platform, then switch to true when not).
I'm just wondering which of the two methods do you advocate and why? Which one would be easier to work with and why?