Permalink
Browse files

integeration of creation sprite animation

  • Loading branch information...
1 parent 088a3f8 commit 3568f925b4bc608f209ae27512946343f0b26bd7 Colin Farrell committed Jan 29, 2012
Showing with 67 additions and 17 deletions.
  1. +19 −0 src/CreationSprite.as
  2. +48 −17 src/Player.as
View
@@ -0,0 +1,19 @@
+package
+{
+ import org.flixel.*;
+
+ public class CreationSprite extends FlxSprite
+ {
+
+ [Embed(source="../assets/Char_CreatePlatform.png")] protected var ImgCreate:Class;
+
+
+ public function CreationSprite(X:Number=0, Y:Number=0, SimpleGraphic:Class=null)
+ {
+ super(X, Y);
+ loadGraphic(ImgCreate,true,true,160, 128);
+ addAnimation("create", [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14], 12, false);
+
+ }
+ }
+}
View
@@ -27,6 +27,9 @@ package
protected var spawnSprite:PlayerSpawn;
protected var spawning:Boolean;
protected var spawnTimer: Number;
+ protected var creation:CreationSprite;
+ protected var createX: Number;
+ protected var createY:Number;
private var jumpSpeed : Number;
private var runSpeed : Number;
@@ -410,44 +413,72 @@ package
(FlxG.state as PlayState).killTrees(x,y);
}
- public function createTiles():void
+ public function tilesCreated(name:String, frameNo:uint, frameInd:uint):void
+ {
+ if (frameNo == 14)
+ {
+ actualCreateTiles();
+ FlxG.state.remove(creation);
+ }
+
+ }
+
+ public function actualCreateTiles():void
{
- var platformHeight:int = (y / tileSize) + 1;
+
+
+
+ FlxG.log("actual create tiles" );
+ var platformHeight:int = (createY / tileSize) + 1;
/*
if (facing == FlxObject.RIGHT)
{
- _map.setTile(x / tileSize, platformHeight, FLAT_TILE);
- _map.setTile((x + width + 1) / tileSize, platformHeight, FLAT_TILE);
- _map.setTile((x + width * 2) / tileSize, platformHeight, FLAT_TILE);
- _map.setTile((x + width * 3) / tileSize, platformHeight, FLAT_TILE);
+ _map.setTile(x / tileSize, platformHeight, FLAT_TILE);
+ _map.setTile((x + width + 1) / tileSize, platformHeight, FLAT_TILE);
+ _map.setTile((x + width * 2) / tileSize, platformHeight, FLAT_TILE);
+ _map.setTile((x + width * 3) / tileSize, platformHeight, FLAT_TILE);
}
else
{
- _map.setTile(x / tileSize, platformHeight, FLAT_TILE);
- _map.setTile((x - width) / tileSize, platformHeight, FLAT_TILE);
- _map.setTile((x - (width * 2)) / tileSize, platformHeight, FLAT_TILE);
- _map.setTile((x - (width * 3)) / tileSize, platformHeight, FLAT_TILE);
+ _map.setTile(x / tileSize, platformHeight, FLAT_TILE);
+ _map.setTile((x - width) / tileSize, platformHeight, FLAT_TILE);
+ _map.setTile((x - (width * 2)) / tileSize, platformHeight, FLAT_TILE);
+ _map.setTile((x - (width * 3)) / tileSize, platformHeight, FLAT_TILE);
}*/
// O
// XXXXX
// block of 5 tiles, centred on player
- _map.setTile(x / tileSize, platformHeight, FLAT_TILE);
+ _map.setTile(createX / tileSize, platformHeight, FLAT_TILE);
//one to each side
- _map.setTile((x+tileSize+1) / tileSize, platformHeight, FLAT_TILE);
- _map.setTile((x-tileSize) / tileSize, platformHeight, FLAT_TILE);
+ _map.setTile((createX+tileSize+1) / tileSize, platformHeight, FLAT_TILE);
+ _map.setTile((createX-tileSize) / tileSize, platformHeight, FLAT_TILE);
//second on each side
- _map.setTile((x+(tileSize *2)) / tileSize, platformHeight, FLAT_TILE);
- _map.setTile((x-(tileSize *2)) / tileSize, platformHeight, FLAT_TILE);
-
+ _map.setTile((createX+(tileSize *2)) / tileSize, platformHeight, FLAT_TILE);
+ _map.setTile((createX-(tileSize *2)) / tileSize, platformHeight, FLAT_TILE);
+
+
- kill();
FlxG.camera.shake(0.001,0.35);
FlxG.camera.flash(0xff0000a2,0.35);
}
+ public function createTiles():void
+ {
+ createX = x;
+ createY = y;
+ creation = new CreationSprite((closestTilePos(x)-64), (closestTilePos(y)-32));
+ FlxG.state.add(creation);
+
+ creation.addAnimationCallback(tilesCreated);
+ creation.play("create");
+ kill();
+
+
+ }
+
public function createSpawn():void
{
spawnX = x;

0 comments on commit 3568f92

Please sign in to comment.