Commits

Jake Albano committed 50f1f4c

Added function stopBolt() to handle removal procedure of boltAttack;
Bolt spell cast aborted if player starts moving while casting;
Bolt spell cast cannot be initiated if player is moving;

  • Participants
  • Parent commits 2abdc97

Comments (0)

Files changed (2)

 		{
 			if (Input.isKeyDown(Input.LEFT))
 			{
+				stopBolt();
 				if (man.graphic.playing != "attack") man.graphic.play("walk");
 				man.x -= 7;
 				man.rotationY = 180;
 			}
 			else if (Input.isKeyDown(Input.RIGHT))
 			{
+				stopBolt();
 				if (man.graphic.playing != "attack") man.graphic.play("walk");
 				man.x += 7;
 				man.rotationY = 0;
 			//////////////////Magic Targeting System///////////////////
 			//FIXME: Stop player from moving when shooting target spell
 			if (Input.isKeyDown(Input.S))
-			{				
-				man.graphic.play("attack"); //TODO: Stop animation on last frame
-				if (!boltAttack)
+			{
+				if ( !(Input.isKeyDown(Input.LEFT) || Input.isKeyDown(Input.RIGHT) ) )
 				{
-					if (man.rotationY == 0)
+					man.graphic.play("attack"); //TODO: Stop animation on last frame
+					if (!boltAttack)
 					{
-						boltAttack = new LightningBolt(true, man.x, man.y);
-						stage.addChild(boltAttack);
-					}
-					else if (man.rotationY == 180)
-					{
-						boltAttack = new LightningBolt(false, man.x, man.y);
-						stage.addChild(boltAttack);
+						if (man.rotationY == 0)
+						{
+							boltAttack = new LightningBolt(true, man.x, man.y);
+							stage.addChild(boltAttack);
+						}
+						else if (man.rotationY == 180)
+						{
+							boltAttack = new LightningBolt(false, man.x, man.y);
+							stage.addChild(boltAttack);
+						}
 					}
 				}
 			}
 					boltAttack.sendBolt();
 				}
 			}
+			
 			if (boltTime.currentCount >= 12)
 			{
-				boltTime.stop();
-				bolting = false;
-				boltTime.reset();
-				stage.removeChild(boltAttack);
-				boltAttack = null;
+				stopBolt();
 			}
 			///////////////////////////////////////////////////////////
 			
 									//stage.removeChild(Mobs[l]);
 									//Mobs.splice(l, 1);
 									Mobs[l].hitpoints -= 5;
-									trace("shuriken hit");
 									
 									removed = true;
 									
 							{
 								if (!Mobs[l].friendly)
 								{
-									trace("bolt hit")
 									Mobs[l].hitpoints -= 10;
 								}
 							}
 			}
 		}
 		
+		private function stopBolt():void
+		{
+			if (!boltAttack) return;
+			
+			boltTime.stop();
+			bolting = false;
+			boltTime.reset();
+			stage.removeChild(boltAttack);
+			boltAttack = null;
+		}
+		
 		private function addWall(x:Number, y:Number, vertical:Boolean):void
 		{
 			Platforms.push(	addChild(new Platform(x, y, vertical) ) );

File src/ifrit/LightningBolt.as

 			wisp.x += vx;
 		}
 		
-		//FIXME: Bolt child does not get removed
-		/*
-		 * Have not been able to figure out to make it work right,
-		 * so the last chunk of the animation remains on the stage.
-		 * You can see this by the small yellow specks that remain
-		 * afterwards.
-		 */
 		public function sendBolt():void
 		{
 			vx = 0;