Jump to content


Member Since 14 May 2013
Offline Last Active Nov 18 2014 01:15 PM

#5064006 Stange animation artifact

Posted by Zippery on 22 May 2013 - 08:32 PM

Got it sorted after looking at my code for the last 3 hours, my collision detection routine was flagging my sprite as being on a platform (which strictly speaking it was) for a split second while it was touching the side of the platform and moving towards it while also jumping - as soon as it reached a certain point it kicked off the animation briefly before stopping it again as the sprite flew above the platform. It was this that I was seeing - I hadn't put a check in to disable animation at that point if the sprite was in an upward jump motion.

Cheers! biggrin.png

#5061784 2d Platformer Gravity - constant or conditional!?

Posted by Zippery on 14 May 2013 - 08:17 AM

Hi Guys


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?