Ejemplo n.º 1
0
        /**
         * Creates a new <code>FlxButton</code> object with a gray background and a
         * callback function on the UI thread.
         *
         * @param X The X position of the button.
         * @param Y The Y position of the button.
         * @param Label The text that you want to appear on the button.
         * @param OnClick The function to call whenever the button is clicked.
         */
        public FlxButton(float x = 0, float y = 0, String label = null, FlxButtonEvent Callback = null) : base(x, y)
        {
            if (label != null)
            {
                Label = new FlxText(x - 1, y + 3, 80, label);
                Label.setFormat(null, 8, new Color(0x33, 0x33, 0x33), "center", Color.Transparent);
                LabelOffset = new FlxPoint(-1, 3);
            }
            loadGraphic(ImgDefaultButton, true, false, 80, 20);
            _callback = Callback;

            /*
             * onUp = OnClick;
             *
             * onDown = null;
             * onOut = null;
             * onOver = null;
             */
            SoundOver = null;
            SoundOut  = null;
            SoundDown = null;
            SoundUp   = null;

            Status       = Normal;
            _onToggle    = false;
            _pressed     = false;
            _initialized = false;
        }
Ejemplo n.º 2
0
        //This is the constructor for the enemy class.  Because we are
        //recycling enemies, we don't want our constructor to have any
        //required parameters.
        public Enemy() : base()
        {
            loadRotatedGraphic(ImgBot, 64, 0, false, true);

            //We want the enemy's "hit box" or actual size to be
            //smaller than the enemy graphic itself, just by a few pixels.
            Width  = 12;
            Height = 12;
            centerOffsets();

            //Here we are setting up the jet particles
            // that shoot out the back of the ship.
            _jets = new FlxEmitter();
            _jets.setRotation();
            //_jets.MakeParticles(ImgJet,15,0,false,0);

            //These parameters help control the ship's
            //speed and direction during the update() loop.
            MaxAngular      = 120;
            AngularDrag     = 400;
            Drag.X          = 35;
            _thrust         = 0;
            _playerMidpoint = new FlxPoint();

            _sfxExplode = new FlxSound().loadEmbedded(SndExplode, false, false);
            _sfxHit     = new FlxSound().loadEmbedded(SndHit, false, false);
            _sfxJet     = new FlxSound().loadEmbedded(SndJet, false, false);
        }
Ejemplo n.º 3
0
        public EnemyBullet() : base()
        {
            loadGraphic(ImgBullet, true);
            addAnimation("idle", new int[] { 0, 1 }, 50);
            addAnimation("poof", new int[] { 2, 3, 4 }, 50, false);
            speed = 120;

            _sfxHit   = new FlxSound().loadEmbedded(SndHit, false, false);
            _sfxShoot = new FlxSound().loadEmbedded(SndShoot, false, false);
        }
Ejemplo n.º 4
0
        //This is the player object class.  Most of the comments I would put in here
        //would be near duplicates of the Enemy class, so if you're confused at all
        //I'd recommend checking that out for some ideas!
        public Player(int x, int y, FlxGroup Bullets, FlxEmitter Gibs /*, FlxVirtualPad pad*/) : base(x, y)
        {
            loadGraphic(ImgSpaceman, true, true, 8);
            _restart = 0;

            //bounding box tweaks
            Width    = 6;
            Height   = 7;
            Offset.X = 1;
            Offset.Y = 1;

            /*
             * _pad = pad;
             * _pad.buttonA.onDown = new IFlxButton(){ public void callback(){jump();}};
             */
            //basic player physics
            int runSpeed = 80;

            Drag.X         = runSpeed * 8;
            Acceleration.Y = 420;
            _jumpPower     = 200;
            MaxVelocity.X  = runSpeed;
            MaxVelocity.Y  = _jumpPower;

            //animations
            addAnimation("idle", new int[] { 0 });
            addAnimation("run", new int[] { 1, 2, 3, 0 }, 12);
            addAnimation("jump", new int[] { 4 });
            addAnimation("idle_up", new int[] { 5 });
            addAnimation("run_up", new int[] { 6, 7, 8, 5 }, 12);
            addAnimation("jump_up", new int[] { 9 });
            addAnimation("jump_down", new int[] { 10 });

            //bullet stuff
            _bullets = Bullets;
            _gibs    = Gibs;

            _sfxExplode  = new FlxSound().loadEmbedded(SndExplode, false, false);
            _sfxExplode2 = new FlxSound().loadEmbedded(SndExplode2, false, false);
            _sfxHurt     = new FlxSound().loadEmbedded(SndHurt, false, false);
            _sfxJam      = new FlxSound().loadEmbedded(SndJam, false, false);
            _sfxJump     = new FlxSound().loadEmbedded(SndJump, false, false);
            _sfxLand     = new FlxSound().loadEmbedded(SndLand, false, false);
        }
Ejemplo n.º 5
0
        public Bullet() : base()
        {
            loadGraphic(ImgBullet, true);
            Width    = 6;
            Height   = 6;
            Offset.X = 1;
            Offset.Y = 1;

            addAnimation("up", new int[] { 0 });
            addAnimation("down", new int[] { 1 });
            addAnimation("left", new int[] { 2 });
            addAnimation("right", new int[] { 3 });
            addAnimation("poof", new int[] { 4, 5, 6, 7 }, 50, false);

            speed = 360;

            _sfxHit   = new FlxSound().loadEmbedded(SndHit, false, false);
            _sfxShoot = new FlxSound().loadEmbedded(SndShoot, false, false);
        }
Ejemplo n.º 6
0
        public Spawner(int x, int y, FlxEmitter Gibs, FlxGroup Bots, FlxGroup BotBullets, FlxEmitter BotGibs, Player ThePlayer) : base(x, y)
        {
            loadGraphic(ImgSpawner, true);
            _gibs       = Gibs;
            _bots       = Bots;
            _botBullets = BotBullets;
            _botGibs    = BotGibs;
            _player     = ThePlayer;
            _timer      = FlxG.random() * 20;
            _open       = false;
            Health      = 8;

            addAnimation("open", new int[] { 1, 2, 3, 4, 5 }, 40, false);
            addAnimation("close", new int[] { 4, 3, 2, 1, 0 }, 40, false);
            addAnimation("dead", new int[] { 6 });

            _sfxExplode  = new FlxSound().loadEmbedded(SndExplode, false, false);
            _sfxExplode2 = new FlxSound().loadEmbedded(SndExplode2, false, false);
            _sfxHit      = new FlxSound().loadEmbedded(SndHit, false, false);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Set up and play a looping background soundtrack.
        /// </summary>
        /// <param name="soundEffect">The sound file you want to loop in the background.</param>
        /// <param name="volume">How loud the sound should be, from 0 to 1.</param>
        public static void playMusic(SoundEffect soundEffect, float volume = 1.0f)
        {
            // flx# - Mediaplayer && Song instance here!

            if (FlxG.music == null)
            {
                FlxG.music = new FlxSound();
            }
            else if (FlxG.music.Active)
            {
                FlxG.music.stop();
            }

            music.loadEmbedded(soundEffect, true);
            music.Volume = volume;
            music.survive = true;
            music.play();
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Creates a new sound object.
        /// </summary>
        /// <param name="soundEffect">The embedded sound resource you want to play. To stream, use the optional URL parameter instead.</param>
        /// <param name="volume">How loud to play it (0 to 1).</param>
        /// <param name="looped">Whether to loop this sound.</param>
        /// <param name="autoDestroy">Whether to destroy this sound when it finishes playing. Leave this value set to "false" if you want to re-use this <code>FlxSound</code> instance.</param>
        /// <param name="autoPlay">Whether to play the sound.</param>
        /// <param name="url">Load a sound from an external web resource instead. Only used if EmbeddedSound = null.</param>
        /// <returns>A <code>FlxSound</code> object.</returns>
        public static FlxSound loadSound(SoundEffect soundEffect, float volume = 1.0f, bool looped = false, bool autoDestroy = false, bool autoPlay = false, string url = null)
        {
            if (!string.IsNullOrEmpty(url))
            {
                throw new NotSupportedException();
            }

            var sound = new FlxSound();
            sound.loadEmbedded(soundEffect, looped, autoDestroy);
            sound.Volume = volume;

            if (autoPlay)
            {
                sound.play();
            }

            return sound;
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Called by FlxGame on state changes to stop and destroy sounds.
        /// </summary>
        /// <param name="forceDestroy">Kill sounds even if they're flagged <code>survive</code>.</param>
        internal static void destroySounds(bool forceDestroy = false)
        {
            if ((music != null) && (forceDestroy || !music.survive))
            {
                music.destroy();
                music = null;
            }

            foreach (FlxSound sound in sounds)
            {
                if (forceDestroy || !sound.survive)
                {
                    sound.destroy();
                }
            }
        }
Ejemplo n.º 10
0
        override public void create()
        {
            base.create();

            rollIndicators = new FlxGroup();

            framesElapsed = 0;

            selected = 0;
            suggestionForClubNoted   = false;
            suggestionForForceNoted  = false;
            suggestionForClubStatus  = 0;
            suggestionForForceStatus = 0;
            selectedClub             = 0;
            playAgainSelected        = 0;

            Globals.ballInHole = false;


            //"Sand Wedge" }

            clubs = new List <string> {
                "Putter", "1 Wood", "3 Wood", "5 Wood",
                "1 Iron", "2 Iron", "3 Iron", "4 Iron", "5 Iron", "6 Iron", "7 Iron", "8 Iron", "9 Iron"
            };

            //, "Chip Shot", "Pitch", "Fade", "Draw", "Lay-up", "Knock Down", "Flop"
            force = new List <string> {
                "Feather Touch", "Firm Putt", "Power Drive"
            };

            playAgain = new List <string> {
                "Yes", "No", "Skip Hole +9"
            };

            game = new FlxSprite(0, 0);
            game.loadGraphic("putt/bg", true, false, 256, 224);
            game.boundingBoxOverride = false;

            add(game);



            ball = new Ball(FlxG.width / 2 - 8, FlxG.height - 24);


            hole = new Hole(FlxG.width / 2, FlxG.height / 2);

            // load the level.
            loadOgmo();


            add(hole);
            add(ball);


            lee = new Lee(FlxG.width / 6, FlxG.height - 170);
            add(lee);

            aim   = new Aim(1, FlxG.height / 2);
            aim.y = hole.y - aim.width;
            add(aim);

            power = new FlxBar(FlxG.width - 110, FlxG.height - 30, FlxBar.FILL_LEFT_TO_RIGHT, 80, 8, null, "", 0, 50, true);
            add(power);
            power.visible         = false;
            power.useCustomColors = true;


            sound = new FlxSound();
            sound.loadEmbedded(Globals.ContentFolder + "/sfx/welcome", false);

            if (Globals.hole == 1)
            {
                sound.play();
            }

            actionButton         = new ActionButton(FlxG.width - 40, FlxG.height - 40);
            actionButton.visible = false;
            add(actionButton);


            if (FlxG.debug && Globals.platform == "Touch")
            {
                FlxG.mouse.show();
            }
            if (Globals.platform == "Touch")
            {
                actionButton.visible = true;
            }


            add(rollIndicators);

            carPark         = new CarPark(0, 0);
            carPark.visible = false;
            add(carPark);

            text = new FlxText(22, 16, 200);
            text.setFormat(FlxG.Content.Load <SpriteFont>("flixel/initials/SMALL_PIXEL"), 1, Color.Yellow, FlxJustification.Left, Color.Black);

            add(text);

            subtitle = new FlxText(22, 2, FlxG.width);
            subtitle.setFormat(FlxG.Content.Load <SpriteFont>("flixel/initials/SMALL_PIXEL"), 1, Color.White, FlxJustification.Left, Color.Black);

            add(subtitle);

            activator = new Carrot((int)text.x - 11, (int)text.y);
            //activator.createGraphic(8, 8, Color.Violet);
            activator.visible = false;
            add(activator);

            log("Welcome to " + Globals.GameNameSplit);


            if (Globals.pirate && Globals.hole >= 4)
            {
                                #if !__IOS__
                FlxU.openURL("http://initialsgames.com/");


                FlxG.Game.Exit();
                                #endif
            }
        }
Ejemplo n.º 11
0
 public static void playMusic(string Music, float Volume)
 {
     if(music == null)
         music = new FlxSound();
     else if(music.Active)
         music.Stop();
     music.LoadEmbedded(Music,true);
     music.volume = Volume;
     music.survive = true;
     music.Play();
 }