Exemple #1
0
        /// <summary>
        /// Instantiate a new game object.
        /// </summary>
        /// <param name="gameSizeX">The width of your game in game pixels, not necessarily final display pixels (see Zoom).</param>
        /// <param name="gameSizeY">The height of your game in game pixels, not necessarily final display pixels (see Zoom).</param>
        /// <param name="initialState">The class name of the state you want to create and switch to first (e.g. MenuState).</param>
        /// <param name="zoom">The default level of zoom for the game's cameras (e.g. 2 = all pixels are now drawn at 2x). Default = 1.</param>
        /// <param name="gameFramerate">How frequently the game should update (default is 60 times per second).</param>
        /// <param name="flashFramerate">Sets the actual display framerate for Flash player (default is 30 times per second).</param>
        /// <param name="useSystemCursor">Whether to use the default OS mouse pointer, or to use custom flixel ones.</param>
        public FlxGame(int gameSizeX,
                       int gameSizeY,
                       FlxState initialState,
                       float zoom           = 1.0f,
                       int gameFramerate    = 60,
                       int flashFramerate   = 0,
                       bool useSystemCursor = false) : base()
        {
            if (flashFramerate != 0)
            {
                throw new NotSupportedException();
            }

            // super high priority init stuff (focus, mouse, etc)
            LostFocus = false;

            /*
             *          _focus = new Sprite();
             *          _focus.visible = false;
             *          _soundTray = new Sprite();
             *          _mouse = new Sprite()
             */

            // flx# - the tight stuff is done in Initialize

            // basic display and update setup stuff
            FlxG.init(this, gameSizeX, gameSizeY, zoom);
            FlxG.Framerate = gameFramerate;
            //FlxG.FlashFramerate = flashFramerate;
            Accumulator     = StepMS;
            Total           = 0;
            State           = null;
            UseSoundHotKeys = true;
            UseSystemCursor = useSystemCursor;

            if (!useSystemCursor)
            {
                //flash.ui.mouse.hide();
            }

            ForceDebugger = false;
            //_debuggerUp = false;

            // replay data

            /*
             * _replay = new FlxReplay();
             * _replayRequested = false;
             * _recordingRequested = false;
             * _replaying = false;
             * _recording = false;
             */

            // then get ready to create the game object for real
            InitialState   = initialState;
            RequestedState = null;
            RequestedReset = true;
            Created        = false;
            //addEventListener(Event.ENTER_FRAME, create);
        }