Flixel Forums

development => help => Topic started by: donto on Wed, Oct 20, 2010

Title: Everything was fine then a black screen loaded.
Post by: donto on Wed, Oct 20, 2010
First day playing with AS3 and flixel and I'm have a blast. Played around with FlxInvaders and managed to make some fun changes (aliens wipe out the shields, etc). Everything was working fine when I changed my backgroundColor back to black from white and then the problem hit.

I had previous changed the color code to #FFFFFF so I could see the canvas better with no problems. After finishing up playing around with the Ship.as file was when I decided to make the backgroundColor change.

I did notice that if I move the mouse and click to lose focus, the game pauses and the screen displays but clicking back to focus "freezes" the screen.

I have no idea where to begin to fix this. Below is my FlxInvaders.as and if the problem is here I think I just need some sleep. 
Code: [Select]
package {

import org.flixel.*; //Allows you to refer to flixel objects in your code
[SWF(width="640", height="480", backgroundColor="#FFFFFF")] //Set the size and color of the Flash file
[Frame(factoryClass="Preloader")]  //Tells flixel to use the default preloader

public class FlxInvaders extends FlxGame
public function FlxInvaders():void
super(320,240,PlayState); //Create a new FlxGame object at 320x240 with 2x pixels, then load PlayState
//showLogo = false;

Thanks in advance.
Title: Re: Everything was fine then a black screen loaded.
Post by: OmegaStorm on Thu, Oct 21, 2010
super(320,240,PlayState, 2)

I notice you don't have your zoom level set here. What other code did you add/change so far?
Title: Re: Everything was fine then a black screen loaded.
Post by: donto on Thu, Oct 21, 2010
The zoom level is the same as the source files. http://github.com/AdamAtomic/Flx-Invaders/blob/master/src/FlxInvaders.as (http://github.com/AdamAtomic/Flx-Invaders/blob/master/src/FlxInvaders.as)

As far as other things I changed.

Additions in the PlayState.as

Aliens destroy shields on contact and aliens kill player on contact.

Code: [Select]
FlxU.overlap(_shields,_aliens,overlapped);//aliens plow through the shields now
FlxU.overlap(_player,_aliens);       //kills the player if he contacts aliens

If all the shields are destroyed the game ends.

Code: [Select]
else if(_shields.getFirstExtant() ==null)
FlxG.scores[0] = "AlL YOUR BASE";
FlxG.state = new PlayState();

Outside of those additions, I played around with most of the code to watch the effects but changed everything back to defaults.

I realize that this is just the FlxInvaders demo, so fixing this is no big deal. I am just curious as to what happened.