Permalink
Browse files

Tree Animation for climbing

  • Loading branch information...
Brian R McDonald
Brian R McDonald committed Jan 29, 2012
1 parent f6103ba commit 33da4c330898e3571f8f99883004b67c8a4c2302
Showing with 20 additions and 25 deletions.
  1. +3 −0 src/PlayState.as
  2. +13 −15 src/Player.as
  3. +4 −10 src/TreeClimbSprite.as
View
@@ -616,6 +616,7 @@ package
public function climbTree(p:Player, treeToClimb:Tree):void
{
+ FlxG.log("Climb Tree in play state"+treeToClimb);
player.play("climbTree");
if (player.y > treeToClimb.y -5)
{
@@ -624,6 +625,8 @@ package
}
//player.canClimb = true;
//player.treeToClimb = treeToClimb;
+ FlxG.log("Climb Tree in play state, climbing tree"+treeToClimb);
+ player.climbTree(treeToClimb);
}
public function plantTreeFirmly(tree:Tree, m:FlxTilemap):void
View
@@ -212,7 +212,7 @@ package
if(FlxG.keys.justPressed("UP") && canClimb)
{
//climb tree
- climbTree();
+ //climbTree();
}
else if(FlxG.keys.justPressed("UP") && velocity.y == 0)
@@ -496,16 +496,17 @@ package
tree.play("grow");
}
- public function climbTree():void
+ public function climbTree(tree:Tree):void
{
keyboardInputEnabled = false;
-
+ FlxG.log("Climbing Tree "+tree);
+ treeToClimb=tree;
treeClimbSprite=new TreeClimbSprite(0,0);
treeClimbSprite.x=treeToClimb.x;
- treeClimbSprite.y=treeToClimb.y;
+ treeClimbSprite.y=treeToClimb.y-64;
FlxG.state.add(treeClimbSprite);
- treeToClimb.visible=false;
+ //treeToClimb.visible=false;
treeClimbSprite.addAnimationCallback(treeAnimationDone);
@@ -529,24 +530,21 @@ package
function treeAnimationDone(name:String,frameNo:uint,frameIndex:uint):void
{
- if (name=="Climb")
- {
- if (frameIndex==8)
+ if (frameIndex==7)
{
- treeToClimb.visible=true;
- solid = false;
- treeToClimb.canopy.solid = false;
+ //treeToClimb.visible=true;
+
+
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
View
@@ -4,20 +4,14 @@ package
public class TreeClimbSprite extends FlxSprite
{
- //[Embed(source = "../assets/treeClimb.png")] protected var ImgTree:Class;
- [Embed(source="../assets/TreeBurstAnimScaled.png")] protected var ImgTree:Class;
+ [Embed(source = "../assets/char_climb.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);
+ loadGraphic(ImgTree,true,true,64, 190);
+ addAnimation("Climb",[0,1,2,3,4,5,6,7],24,false);
}
}
}

0 comments on commit 33da4c3

Please sign in to comment.