Permalink
Browse files

Tree Climb Animation

  • Loading branch information...
1 parent 1307155 commit 088a3f8456e89539c3b0aedaf9a5315e2f76832b Brian R McDonald committed Jan 29, 2012
Showing with 71 additions and 7 deletions.
  1. +48 −7 src/Player.as
  2. +23 −0 src/TreeClimbSprite.as
View
55 src/Player.as
@@ -45,6 +45,8 @@ package
public var sacrifices : Array;
public var currentSacrifice : Number;
+ public var treeClimbSprite:TreeClimbSprite;
+
//This is the player object class. Most of the comments I would put in here
//would be near duplicates of the Enemy class, so if you're confused at all
//I'd recommend checking that out for some ideas!
@@ -93,6 +95,8 @@ package
footstep = new FlxSound();
footstep.loadEmbedded(footstepSound, true, true);
+
+
/* if ( FlxG.getPlugin(FlxControl) == null) {
FlxG.addPlugin(new FlxControl);
}
@@ -464,19 +468,56 @@ package
public function climbTree():void
{
keyboardInputEnabled = false;
- play("climbTree");
+
+ treeClimbSprite=new TreeClimbSprite(0,0);
+ treeClimbSprite.x=treeToClimb.x;
+ treeClimbSprite.y=treeToClimb.y;
+
+ FlxG.state.add(treeClimbSprite);
+ treeToClimb.visible=false;
+
+ treeClimbSprite.addAnimationCallback(treeAnimationDone);
+
+ this.visible=false;
+ treeClimbSprite.play("Climb");
+
+
+ //Comment out put back in animation is feckered
+ //play("climbTree");
//when animation finished teleport to top of tree
- solid = false;
- treeToClimb.canopy.solid = false;
- y = treeToClimb.y - this.height - 20 ;
- treeToClimb.canopy.solid = true;
- solid = true;
+ //solid = false;
+ //treeToClimb.canopy.solid = false;
+ //y = treeToClimb.y - this.height - 20 ;
+ //treeToClimb.canopy.solid = true;
+ //solid = true;
// treeToClimb.y;
- keyboardInputEnabled = true;
+ //keyboardInputEnabled = true;
}
+ function treeAnimationDone(name:String,frameNo:uint,frameIndex:uint):void
+ {
+ if (name=="Climb")
+ {
+ if (frameIndex==8)
+ {
+
+ treeToClimb.visible=true;
+ solid = false;
+ treeToClimb.canopy.solid = false;
+ y = treeToClimb.y - this.height - 20 ;
+ treeToClimb.canopy.solid = true;
+ solid = true;
+ // treeToClimb.y;
+ keyboardInputEnabled = true;
+ treeClimbSprite.visible=false;
+ this.visible=true;
+ FlxG.state.remove(treeClimbSprite);
+ }
+ }
+ }
+
override public function kill():void
{
if(!alive)
View
23 src/TreeClimbSprite.as
@@ -0,0 +1,23 @@
+package
+{
+ import org.flixel.FlxSprite;
+
+ public class TreeClimbSprite extends FlxSprite
+ {
+ //[Embed(source = "../assets/treeClimb.png")] protected var ImgTree:Class;
+ [Embed(source="../assets/TreeBurstAnimScaled.png")] protected var ImgTree:Class;
+ function TreeClimbSprite(X:Number=0,Y:Number=0)
+ {
+ super(x,y);
+
+ loadGraphic(ImgTree,true,true,128, 128);
+ //
+ addAnimation("grow", [0, 1, 2, 3,4,5,6,7,8,9,10,10,10,10,10,10,11,12,13,
+ 14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29], 24, false);
+
+ //We should use when we have asset
+ //loadGraphic(ImgTree,true,false,128,128);
+ //addAnimation("Climb",[0,1,2,3,4,5,6,7],15,false);
+ }
+ }
+}

0 comments on commit 088a3f8

Please sign in to comment.