craftyjs/Crafty — pull request #592 by pawurb (2013-11-01 15:47:20+00:00)
Title: Gravity collision detected only on top.

I am working on a runner inspired by http://www.mylostgames.com/play/nyan_cat_lost_in_space . I need a mechanism for main character to jump on platforms from below (like in Icy Tower). I am using Twoway and Gravity components.

Current implementation of gravity against 'anti' objects make character go immediately up at any contact: http://www.youtube.com/watch?v=kdhKF39-IKc .

This pull request changes make character being stopped by platforms only when he is on top on them: http://www.youtube.com/watch?v=j6vOzTU3kaY. Treshold of 10 pixels was choosen as it avoids jumpy animation and ensures good collision detection.

I would be grateful for a tip on how to detect if character is moving up or down, so that I can stop his movement only if he gets on platform from above.