If you choose to go with the 2nd option, the following should work (please tell me if it doesn't).
var player = Crafty.e("2D, Gravity");
player.bind("CheckLanding", function(ground) {
if (player._y + player._h > ground._y) // disallow landing of player, if the player's position is below ground
player.canLand = false;
});
--
You received this message because you are subscribed to a topic in the Google Groups "Crafty" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/craftyjs/L_1KzbynGOM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to craftyjs+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
.bind("CheckLanding", function(ground) {
if (this._y + this._h > ground._y + ground._h) // disallow landing of player, if player's feet are not above ground
this.canLand = false;
})
Is it also possible to prevent the monkey from snapping to the platform when you jump from the left or right side and in theory wouldn't make it?
Or when you are already on the platform and go a little to the left (or right) off the edge and then quickly go back, then it also snaps
.bind("CheckLanding", function(ground) {
if (this._y + this._h > ground._y + this._vy) // disallow landing of player, if player's feet are not above ground
this.canLand = false;
})
...
...
...