Permalink
Browse files

Power UI

  • Loading branch information...
1 parent d67feb9 commit 245efe03a310ff7626963055f670737f20070e4e Brian R McDonald committed Jan 29, 2012
Showing with 51 additions and 5 deletions.
  1. +42 −4 src/PlayState.as
  2. +4 −0 src/Player.as
  3. +5 −1 src/PowerUISprite.as
View
@@ -41,7 +41,10 @@ package
[Embed(source="../assets/fg_mistFX.png")] private static var FgMistClass:Class;
-
+ //Power UI Assets
+ [Embed(source="../assets/ui_explodeIcon.png")] private static var explodeIconClass:Class;
+ [Embed(source="../assets/ui_platformIcon.png")] private static var platformIconClass:Class;
+ [Embed(source="../assets/ui_treeIcon.png")] private static var treeIcon:Class;
// graphics classes
private var fgInverseVignette : FlxSprite;
@@ -86,12 +89,14 @@ package
protected var explosions:FlxGroup;
protected var pickups:FlxGroup;
protected var pickupScoreDisplay:FlxGroup;
+ protected var iconDisplay:FlxGroup;
// Some interface buttons and text
private var autoAltBtn:FlxButton;
private var resetBtn:FlxButton;
private var quitBtn:FlxButton;
private var helperTxt:FlxText;
+ private var lastSacrifice:Number=0;
private var sacrificeText:FlxText;
@@ -456,7 +461,31 @@ package
//create button
resetBtn=new FlxButton(FlxG.width-100,FlxG.height- 50,"Restart",OnRestartButtonClick);
add(resetBtn);
+
+
+ iconDisplay=new FlxGroup();
+ var pUISprite:PowerUISprite=new PowerUISprite(32,FlxG.height- 260);
+ pUISprite.loadGraphic(treeIcon,true,false,128,128,false);
+ pUISprite.play("Idle");
+ iconDisplay.add(pUISprite);
+
+ pUISprite=new PowerUISprite(32,FlxG.height- 260);
+ pUISprite.loadGraphic(platformIconClass,true,false,128,128,false);
+ pUISprite.play("Idle");
+ pUISprite.visible=false;
+ iconDisplay.add(pUISprite);
+
+ pUISprite=new PowerUISprite(32,FlxG.height- 260);
+ pUISprite.loadGraphic(explodeIconClass,true,false,128,128,false);
+ pUISprite.play("Idle");
+ pUISprite.visible=false;
+
+ iconDisplay.add(pUISprite);
+ add(iconDisplay);
+
FlxG.mouse.show();
+
+
}
// Jon's function!
@@ -505,14 +534,23 @@ package
fgLetterbox = new FlxSprite(0, 0, FgLetterboxClass);
add(fgLetterbox);
- sacrificeText = new FlxText(25,FlxG.height- 25,800,"Current Sacrifice: " + player.getSacrifice());
+ sacrificeText = new FlxText(170,FlxG.height- 204,800,"0");
sacrificeText.size = 16;
sacrificeText.alignment = "left";
- sacrificeText.color=0xFFffffff;
+ sacrificeText.color=0xFF000000;
add(sacrificeText);
}
+ public function switchPowerUI(current:Number):void
+ {
+ var uiElement:PowerUISprite=iconDisplay.members[lastSacrifice];
+ uiElement.visible=false;
+ lastSacrifice=current;
+ uiElement=iconDisplay.members[current];
+ uiElement.Play();
+ }
+
override public function update():void
{
// Tilemaps can be collided just like any other FlxObject, and flixel
@@ -622,7 +660,7 @@ package
sacrificeLeft = ""+player.platformsLeft;
}
- sacrificeText.text = "Current Sacrifice: " + player.getSacrifice() + " ( "+ sacrificeLeft +" remaining)";
+ sacrificeText.text = "Sacrifices: " + sacrificeLeft;
super.draw();
View
@@ -277,7 +277,11 @@ package
currentSacrifice ++;
if ( currentSacrifice > (sacrifices.length-1)) {
currentSacrifice = 0;
+ //tell play state to shift icon
+
}
+ var playState=FlxG.state as PlayState;
+ playState.switchPowerUI(currentSacrifice);
}
if ( FlxG.keys.justPressed("SPACE")) {
@@ -4,15 +4,19 @@ package
public class PowerUISprite extends FlxSprite
{
- function PowerUISprite(X:Number=0,Y:Number)
+ function PowerUISprite(X:Number=0,Y:Number=0)
{
super(X,Y);
+ addAnimation("Play",[0,1,2,3],15,false);
+ addAnimation("Idle",[3],15,false);
}
function Play():void
{
//15 FPS
+ visible=true;
+ play("Play");
}
function Stop():void

0 comments on commit 245efe0

Please sign in to comment.