Skip to content

Commit

Permalink
Improve docs
Browse files Browse the repository at this point in the history
Improve docs of Supportable and Twoway with examples of realistic,
custom land and jump behavior.
  • Loading branch information
mkucko committed Apr 7, 2015
1 parent 54cc31d commit 5793f07
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
12 changes: 8 additions & 4 deletions src/controls/controls.js
Expand Up @@ -1300,11 +1300,15 @@ Crafty.c("Twoway", {
* @example
* ~~~
* var player = Crafty.e("2D, Twoway");
* player.hasDoubleJumpPowerUp = true; // allow player to double jump by granting him a powerup
* player.bind("CheckJumping", function(ground) {
* if (!ground && player.hasDoubleJumpPowerUp) { // custom behaviour
* player.hasDoubleJumpPowerUp = false;
* player.canJump = true;
* }
* if (!ground && player.hasDoubleJumpPowerUp) { // allow player to double jump by using up his double jump powerup
* player.canJump = true;
* player.hasDoubleJumpPowerUp = false;
* }
* });
* player.bind("LandedOnGround", function(ground) {
* player.hasDoubleJumpPowerUp = true; // give player new double jump powerup upon landing
* });
* ~~~
*/
Expand Down
3 changes: 2 additions & 1 deletion src/spatial/2d.js
Expand Up @@ -951,8 +951,9 @@ Crafty.c("Supportable", {
* ~~~
* var player = Crafty.e("2D, Gravity");
* player.bind("CheckLanding", function(ground) {
* if (player.isAirplane) // custom behaviour
* if (player.y + player.h > ground.y + player.vy) { // forbid landing, if player's feet are not above ground
* player.canLand = false;
* }
* });
* ~~~
*/
Expand Down

0 comments on commit 5793f07

Please sign in to comment.