Permalink
Browse files

can hold down space to shoot

  • Loading branch information...
1 parent d1e9dc4 commit ba41a2fa3d96f99f3897750520d27d36172dfb1c @severest severest committed Nov 20, 2012
Showing with 9 additions and 4 deletions.
  1. +7 −2 components.js
  2. +2 −2 game.js
View
@@ -165,14 +165,19 @@ Crafty.c("RandomMover", {
Crafty.c("ForkyBase", {
bulletSpeed: 3,
init: function () {
+ this.canFire = true;
+ this.fireTimeout = 200;
+
this.requires("2D").requires("DOM").requires("forkysprite").requires("SpriteAnimation").requires("OnJetpack").requires("Keyboard").requires("RealDelay")
.attr({ x: 580, y: 100, z: 2})
.animate("idle", 0, 0, 4)
.animate("lean", 4, 0, 7)
.animate("idle", 20, -1)
.configMovement(0.1,10)
- .bind('KeyDown', function () {
- if (this.isDown("SPACE")) {
+ .bind('EnterFrame', function () {
+ if (this.isDown("SPACE") && this.canFire) {
+ this.canFire = false;
+ this.realDelay(function(){this.canFire = true;},this.fireTimeout); // fire weapon timeout
this.fireBaseWeapon();
}
});
View
@@ -136,13 +136,13 @@ function spawnSimpleEnemy() {
Crafty.e("Enemy, 2D, DOM, onion, SpriteAnimation, EnemyBase, SimpleEnemy")
.attr({ x: Crafty.math.randomInt(20, STAGE_WIDTH), y: -50, z: 2})
.animate("idle", 0, 0, 4)
- .animate("idle", 60, -1)
+ .animate("idle", 30, -1)
.setSpeed(1.5);
Crafty.e("Enemy, 2D, DOM, egg, SpriteAnimation, EnemyBase, SimpleEnemy")
.attr({ x: Crafty.math.randomInt(20, STAGE_WIDTH), y: -50, z: 2})
.animate("idle", 0, 0, 3)
- .animate("idle", 60, -1)
+ .animate("idle", 20, -1)
.setSpeed(1.5);

0 comments on commit ba41a2f

Please sign in to comment.