Add collision bits to player
This commit is contained in:
parent
dc4af9b023
commit
40ddea42d6
@ -30,22 +30,36 @@ Crafty.c('Actor', {
|
||||
|
||||
Crafty.c('Tree', {
|
||||
init: function() {
|
||||
this.requires('Actor, Color')
|
||||
this.requires('Actor, Color, Solid')
|
||||
.color('rgb(20, 125, 40)');
|
||||
}
|
||||
});
|
||||
|
||||
Crafty.c('Bush', {
|
||||
init: function() {
|
||||
this.requires('Actor, Color')
|
||||
this.requires('Actor, Color, Solid')
|
||||
.color('rgb(20, 185, 40)');
|
||||
}
|
||||
});
|
||||
|
||||
Crafty.c('PlayerCharacter', {
|
||||
init: function() {
|
||||
this.requires('Actor, Fourway, Color')
|
||||
this.requires('Actor, Fourway, Color, Collision')
|
||||
.fourway(4)
|
||||
.color('rgb(20, 75, 40)');
|
||||
.color('rgb(20, 75, 40)')
|
||||
.stopOnSolids();
|
||||
},
|
||||
|
||||
stopOnSolids: function() {
|
||||
this.onHit('Solid', this.stopMovement);
|
||||
return this;
|
||||
},
|
||||
|
||||
stopMovement: function() {
|
||||
this._speed = 0;
|
||||
if (this._movement) {
|
||||
this.x -= this._movement.x;
|
||||
this.y -= this._movement.y;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user