示例#1
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);
		}
		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);
		}
示例#3
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);
		}
示例#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);

		}
示例#5
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);
		}
示例#6
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(string 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();
        }
示例#7
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(string 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;
        }
示例#8
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();
                }
            }
        }
示例#9
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;
        }