1 decade ago by LazerFriends
I am developing a platformer game where the player entity is able to pick up and put down crates. I have 2 issues:
1. I was able to program the player entity to pick up the crate, but only if I am pressing the forward key AND the pickup key. How can I code it so the player can pick up the crate by just standing next to it (touching) and not running against it (colliding)?
2. Simply put: how can the player put the crate back down again?
Here is the code for the pickup:
And a link to the game (Arrow keys for movement, X to pick up crates)
http://bsmallbeck.com/impact/
1. I was able to program the player entity to pick up the crate, but only if I am pressing the forward key AND the pickup key. How can I code it so the player can pick up the crate by just standing next to it (touching) and not running against it (colliding)?
2. Simply put: how can the player put the crate back down again?
Here is the code for the pickup:
check: function(other){
if( ig.input.state('pickup')) {
other.kill();
this.kill();
ig.game.spawnEntity(EntityPlayerBox,other.pos.x, other.pos.y);
};
this.parent();
},
And a link to the game (Arrow keys for movement, X to pick up crates)
http://bsmallbeck.com/impact/
