Skip to content

Commit

Permalink
rebuilt preloader, worked on group collisions
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamAtomic committed Feb 14, 2010
1 parent 06d3b13 commit c934035
Show file tree
Hide file tree
Showing 16 changed files with 389 additions and 377 deletions.
4 changes: 2 additions & 2 deletions flx.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@
lines = []
lines.append('package\r\n')
lines.append('{\r\n')
lines.append('\timport org.flixel.data.FlxFactory;\r\n')
lines.append('\timport org.flixel.*;\r\n')
lines.append('\r\n')
lines.append('\tpublic class '+preloader+' extends FlxFactory\r\n')
lines.append('\tpublic class '+preloader+' extends FlxPreloader\r\n')
lines.append('\t{\r\n')
lines.append('\t\tpublic function '+preloader+'()\r\n')
lines.append('\t\t{\r\n')
Expand Down
32 changes: 14 additions & 18 deletions org/flixel/FlxEmitter.as
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ package org.flixel
* Sets the <code>acceleration.y</code> member of each particle to this value on launch.
*/
public var gravity:Number;
/**
* Determines whether the emitter is currently emitting particles.
*/
public var on:Boolean;
/**
* This variable has different effects depending on what kind of emission it is.
* During an explosion, delay controls the lifespan of the particles.
Expand All @@ -53,10 +57,6 @@ package org.flixel
* The number of particles to launch at a time.
*/
public var quantity:uint;
/**
* Whether the emitter is currently "on", or emitting particles.
*/
public var on:Boolean;
/**
* The style of particle emission (all at once, or one at a time).
*/
Expand Down Expand Up @@ -100,8 +100,8 @@ package org.flixel
quantity = 0;
_counter = 0;
_explode = true;

kill();
exists = false;
on = false;
}

/**
Expand Down Expand Up @@ -165,7 +165,6 @@ package org.flixel
s.scrollFactor = scrollFactor;
add(s);
}
kill();
return this;
}

Expand Down Expand Up @@ -229,14 +228,7 @@ package org.flixel
_timer += FlxG.elapsed;
if((delay > 0) && (_timer > delay))
{
var o:FlxObject;
l = members.length;
for(i = 0; i < l; i++)
{
o = members[i] as FlxObject;
if(o != null)
o.exists = false;
}
kill();
return;
}
if(on)
Expand Down Expand Up @@ -290,10 +282,10 @@ package org.flixel
* Call this function to start emitting particles.
*
* @param Explode Whether the particles should all burst out at once.
* @param Quantity How many particles to launch. Default value is 0, or "all the particles".
* @param Delay You can set the delay (or lifespan) here if you want.
* @param Quantity How many particles to launch. Default value is 0, or "all the particles".
*/
public function start(Explode:Boolean=true,Quantity:uint=0,Delay:Number=0):void
public function start(Explode:Boolean=true,Delay:Number=0,Quantity:uint=0):void
{
if(members.length <= 0)
{
Expand All @@ -306,6 +298,9 @@ package org.flixel
if(!exists)
_particle = 0;
exists = true;
visible = true;
active = true;
dead = false;
on = true;
_timer = 0;
if(quantity == 0)
Expand Down Expand Up @@ -375,7 +370,8 @@ package org.flixel
*/
override public function kill():void
{
exists = false;
super.kill();
on = false;
}
}
}
2 changes: 1 addition & 1 deletion org/flixel/FlxG.as
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ package org.flixel
* Assign a minor version to your library.
* Appears after the decimal in the console.
*/
static public var LIBRARY_MINOR_VERSION:uint = 11;
static public var LIBRARY_MINOR_VERSION:uint = 12;

/**
* Internal tracker for game object (so we can pause & unpause)
Expand Down
116 changes: 7 additions & 109 deletions org/flixel/FlxGame.as
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package org.flixel
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.*;
import flash.geom.ColorTransform;
import flash.geom.Point;
import flash.geom.Rectangle;
import flash.text.AntiAliasType;
Expand All @@ -17,7 +16,6 @@ package org.flixel
import flash.utils.getTimer;

import org.flixel.data.FlxConsole;
import org.flixel.data.FlxLogoPixel;
import org.flixel.data.FlxPause;

/**
Expand All @@ -29,20 +27,14 @@ package org.flixel
public class FlxGame extends Sprite
{
[Embed(source="data/nokiafc22.ttf",fontFamily="system")] protected var junk:String;
[Embed(source="data/poweredby.png")] protected var ImgPoweredBy:Class;
[Embed(source="data/beep.mp3")] protected var SndBeep:Class;
[Embed(source="data/flixel.mp3")] protected var SndFlixel:Class;

/**
* Essentially locks the framerate to 30 FPS minimum
*/
internal const MAX_ELAPSED:Number = 0.0333;

/**
* Whether or not to display the flixel logo on startup.
* @default true
*/
public var showLogo:Boolean;

/**
* Sets 0, -, and + to control the global volume and P to pause.
* @default true
Expand Down Expand Up @@ -82,15 +74,6 @@ package org.flixel
internal var _soundTrayBars:Array;
internal var _console:FlxConsole;

//logo stuff
internal var _f:Array;
internal var _fc:uint;
internal var _logoComplete:Boolean;
internal var _logoTimer:Number;
internal var _poweredBy:Bitmap;
internal var _logoFade:Bitmap;
internal var _fSound:Class;

/**
* Game object constructor - sets up the basic properties of your game.
*
Expand All @@ -111,40 +94,18 @@ package org.flixel
pause = new FlxPause();
_state = null;
_iState = InitialState;

useDefaultHotKeys = true;

showLogo = true;
_f = null;
_fc = 0xffffffff;
_fSound = SndFlixel;

_frame = null;
_gameXOffset = 0;
_gameYOffset = 0;

_paused = false;
_created = false;
_logoComplete = false;
addEventListener(Event.ENTER_FRAME, onEnterFrame);
}

/**
* Allows you to customize the sound and appearance of the flixel 'f'.
*
* @param FlixelColor The color of the great big 'f' in the flixel logo.
* @param FlixelSound The sound that is played over the flixel 'f' logo.
*
* @return This <code>FlxGame</code> instance.
*/
protected function setLogoFX(FlixelColor:Number,FlixelSound:Class=null):FlxGame
{
_fc = FlixelColor;
if(FlixelSound != null)
_fSound = FlixelSound;
return this;
}

/**
* Adds a frame around your game for presentation purposes (see Canabalt, Gravity Hook).
*
Expand Down Expand Up @@ -269,8 +230,7 @@ package org.flixel
*/
protected function onFocusLost(event:Event=null):void
{
if(_logoComplete)
FlxG.pause = true;
FlxG.pause = true;
}

/**
Expand Down Expand Up @@ -314,7 +274,7 @@ package org.flixel
//Frame timing
var t:uint = getTimer();
_elapsed = (t-_total)/1000;
if(_logoComplete)
if(_created)
_console.lastElapsed = _elapsed;
_total = t;
FlxG.elapsed = _elapsed;
Expand Down Expand Up @@ -347,7 +307,7 @@ package org.flixel
}
}

if(_logoComplete)
if(_created)
{
//Animate flixel HUD elements
FlxG.panel.update();
Expand Down Expand Up @@ -412,68 +372,6 @@ package org.flixel
_flipped = !_flipped;
}
}
else if(_created)
{
if(!showLogo)
{
_logoComplete = true;
switchState(new _iState());
}
else
{
if(_f == null)
{
var tmp:Bitmap;
_f = new Array();
var scale:uint = 1;
if(FlxG.height > 200)
scale = 2;
var pixelSize:uint = 32*scale;
var top:int = FlxG.height*_zoom/2-pixelSize*2;
var left:int = FlxG.width*_zoom/2-pixelSize;

_f.push(addChild(new FlxLogoPixel(left+pixelSize,top,pixelSize,0,_fc)) as FlxLogoPixel);
_f.push(addChild(new FlxLogoPixel(left,top+pixelSize,pixelSize,1,_fc)) as FlxLogoPixel);
_f.push(addChild(new FlxLogoPixel(left,top+pixelSize*2,pixelSize,2,_fc)) as FlxLogoPixel);
_f.push(addChild(new FlxLogoPixel(left+pixelSize,top+pixelSize*2,pixelSize,3,_fc)) as FlxLogoPixel);
_f.push(addChild(new FlxLogoPixel(left,top+pixelSize*3,pixelSize,4,_fc)) as FlxLogoPixel);

_poweredBy = new ImgPoweredBy;
_poweredBy.scaleX = scale;
_poweredBy.scaleY = scale;
_poweredBy.x = FlxG.width*_zoom/2-_poweredBy.width/2;
_poweredBy.y = top+pixelSize*4+16;
var ct:ColorTransform = new ColorTransform();
ct.color = _fc;
_poweredBy.bitmapData.colorTransform(new Rectangle(0,0,_poweredBy.width,_poweredBy.height),ct);
addChild(_poweredBy);

_logoFade = addChild(new Bitmap(new BitmapData(FlxG.width*_zoom,FlxG.height*_zoom,true,0xFF000000))) as Bitmap;
_logoFade.x = _gameXOffset*_zoom;
_logoFade.y = _gameYOffset*_zoom;

if(_fSound != null)
FlxG.play(_fSound,0.35);
}

_logoTimer += _elapsed;
for(i = 0; i < _f.length; i++)
_f[i].update();
if(_logoFade.alpha > 0)
_logoFade.alpha -= _elapsed*0.5;

if(_logoTimer > 2)
{
removeChild(_poweredBy);
for(i = 0; i < _f.length; i++)
removeChild(_f[i]);
_f.length = 0;
removeChild(_logoFade);
switchState(new _iState());
_logoComplete = true;
}
}
}
else if(root != null)
{
//Set up the view window and double buffering
Expand Down Expand Up @@ -526,7 +424,7 @@ package org.flixel
_soundTray.visible = false;
_soundTray.scaleX = 2;
_soundTray.scaleY = 2;
tmp = new Bitmap(new BitmapData(80,30,true,0x7F000000));
var tmp:Bitmap = new Bitmap(new BitmapData(80,30,true,0x7F000000));
_soundTray.x = (_gameXOffset+FlxG.width/2)*_zoom-(tmp.width/2)*_soundTray.scaleX;
_soundTray.addChild(tmp);

Expand Down Expand Up @@ -580,7 +478,7 @@ package org.flixel

//All set!
_created = true;
_logoTimer = 0;
switchState(new _iState());
}
}
}
Expand Down
Loading

0 comments on commit c934035

Please sign in to comment.