Tell me more ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I am having an issue getting my Flash game (made using the Flixel library) to display when I use Zoom = 1 in the call to Super() in the game's constructor.

I have made a map using Dame which is 640x1280 pixels. In the constructor for the game's main class, I set the stage for the SWF to and the size of the screen that Flixel draws onto to both be 640X480:

package
{
  import flash.display.Sprite;
  import org.flixel.*;

  [SWF(width="640",height="480",backgroundColor="#000000")]
  public class Ascent extends FlxGame
  {
    public function Ascent()
    {
        /*set the size of the screen on which flixel will draw*/
        super(640,480,PlayState,50,50);
        forceDebugger = true;
    }
  }
}

Then, in the constructor for PlayState.as, I set the camera bounds to the size of the map, and set the camera to follow the player:

        /*Set data for player*/
        TheClimber = new BalloonHero()
        TheClimber.x = FlxG.width/2-5,
        TheClimber.y = 1210;

        /*add player to the game*/
        add(TheClimber);

        /*Add camera and set it to follow The Climber*/
        //This will automatically set the boundaries of the world.

        FlxG.camera.setBounds(0,0,640,1280,true);
        FlxG.camera.follow(TheClimber,FlxCamera.STYLE_PLATFORMER);

However, this only results in a black screen. Yet, when I change the Zoom to 2 using either:

super(640,480,PlayState, 2 ,50,50);

or

super(320,240,PlayState,2, 50,50);

Then the map and player appear, drawn on screen, and function how I would like. I understand why the two alternatives shown above work, but I do not understand why the first attempt, in which Zoom = 1 only results in a black screen. Thank you for your help,

share|improve this question

closed as too localized by Tetrad Mar 18 at 23:02

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, see the FAQ.

1 Answer

Specifying the argument as 1 resolved the issue:

/*set the size of the screen on which flixel will draw*/ super(640,480,PlayState,1,50,50);

See the post here for details.

share|improve this answer
1  
Yeah, because before you were setting the zoom to 50! You can't just skip arguments. The computer has no way of knowing that you are, so it sets the zoom to 50 and the next argument, the framerate, to 50, instead of setting both framerates to 50. – dizzydj7 Feb 17 at 23:31
I believe that actionscript 3 supports default arguments? Which, if I understand correctly, allow you to call a function without explicitly stating each parameter. For example: ntt.cc/2009/04/22/… In Flixel, the super function signature shows zoom=1 as a default value, however it seems that may be inaccurate. – Christian Feb 18 at 19:59
1  
Yes, but you can't skip parameters. If you put super(640,480,PlayState), then the parameters after that will be the default. But if you want to set the framerates, you have to set all the parameters before it, including zoom. – dizzydj7 Feb 18 at 20:23
Ah! Ok, I was not aware of that. Thank you for the insight. I was assuming it would determine the signature based on the number and type of arguments. A misconception on my part. – Christian Feb 18 at 21:40
1  
Also note that the AS3 compiler couldn't really deduce if 50 is a Number or a uint in this case. Positional arguments generally aren't repositionable in a language, but a pattern you'll see in other languages (like Python) is that keyword arguments or arguments you specify by name at the call site don't have to keep the same position. Example: If Flixel were written in Python or if AS3 supported keyword args, you could write something like init(640, 480, PlayState, GameFramerate=50, FlashFramerate=50); and get the behavior you were expecting. – michael.bartnett Mar 18 at 19:53

Not the answer you're looking for? Browse other questions tagged or ask your own question.