Ejemplo n.º 1
0
        //private FlxVirtualPad _pad;

        public override void create()
        {
            //		FlxG.mouse.hide();

            /*_sfxCount = new FlxSound().loadEmbedded(SndCount, false, false, FlxSound.SFX);*/

            /*
             * _pad = new FlxVirtualPad(FlxVirtualPad.DPAD_FULL, FlxVirtualPad.A_B);
             * _pad.Alpha = 0.5f;
             */
            //		if(Gdx.app.getType() == ApplicationType.Desktop || MenuState.attractMode)
            //			_pad.visible = false;

            //Here we are creating a pool of 100 little metal bits that can be exploded.
            //We will recycle the crap out of these!
            _littleGibs = new FlxEmitter();
            _littleGibs.setXSpeed(-150, 150);
            _littleGibs.setYSpeed(-200, 0);
            _littleGibs.setRotation(-720, -720);
            _littleGibs.gravity = 350;
            _littleGibs.bounce  = 0.5f;
            _littleGibs.makeParticles(ImgGibs, 100, 10, true, 0.5f);

            //Next we create a smaller pool of larger metal bits for exploding.
            _bigGibs = new FlxEmitter();
            _bigGibs.setXSpeed(-200, 200);
            _bigGibs.setYSpeed(-300, 0);
            _bigGibs.setRotation(-720, -720);
            _bigGibs.gravity = 350;
            _bigGibs.bounce  = 0.35f;
            _bigGibs.makeParticles(ImgSpawnerGibs, 50, 20, true, 0.5f);

            //Then we'll set up the rest of our object groups or pools
            _blocks       = new FlxGroup();
            _decorations  = new FlxGroup();
            _enemies      = new FlxGroup();
            _spawners     = new FlxGroup();
            _hud          = new FlxGroup();
            _enemyBullets = new FlxGroup();
            _bullets      = new FlxGroup();

            //Now that we have references to the bullets and metal bits,
            //we can create the player object.
            _player = new Player(316, 300, _bullets, _littleGibs /*, _pad*/);

            //This refers to a custom function down at the bottom of the file
            //that creates all our level geometry with a total size of 640x480.
            //This in turn calls buildRoom() a bunch of times, which in turn
            //is responsible for adding the spawners and spawn-cameras.
            generateLevel();

            //Add bots and spawners after we add blocks to the state,
            //so that they're drawn on top of the level, and so that
            //the bots are drawn on top of both the blocks + the spawners.
            add(_spawners);
            add(_littleGibs);
            add(_bigGibs);
            add(_blocks);
            add(_decorations);
            add(_enemies);

            //Then we add the player and set up the scrolling camera,
            //which will automatically set the boundaries of the world.
            add(_player);
            FlxG.camera.setBounds(0, 0, 640, 640, true);
            FlxG.camera.follow(_player, FlxCamera.StylePlatformer);

            //We add the bullets to the scene here,
            //so they're drawn on top of pretty much everything
            add(_enemyBullets);
            add(_bullets);
            add(_hud);

            //Finally we are going to sort things into a couple of helper groups.
            //We don't add these groups to the state, we just use them for collisions later!
            _hazards = new FlxGroup();
            _hazards.add(_enemyBullets);
            _hazards.add(_spawners);
            _hazards.add(_enemies);
            _objects = new FlxGroup();
            _objects.add(_enemyBullets);
            _objects.add(_bullets);
            _objects.add(_enemies);
            _objects.add(_player);
            _objects.add(_littleGibs);
            _objects.add(_bigGibs);

            //From here on out we are making objects for the HUD,
            //that is, the player score, number of spawners left, etc.
            //First, we'll create a text field for the current score
            _score = new FlxText(FlxG.width / 4, 0, FlxG.width / 2);

            /*
             * if(Gdx.app.getType() == ApplicationType.WebGL)
             *      _score.setFormat(ImgFont20,20,0xd8eba2,"center",0x131c1b);
             * else*/
            /*_score.setFormat(null,16,0xd8eba2,"center",0x131c1b);*/
            _hud.add(_score);
            if (FlxG.scores == null)
            {
                FlxG.scores = new int[2] {
                    0, 0
                };
            }

            //Then for the player's highest and last scores
            if (FlxG.score > (int)FlxG.scores.GetValue(0))
            {
                FlxG.scores.SetValue(0, FlxG.score);
            }
            if ((int)FlxG.scores.GetValue(0) != 0)
            {
                _score2 = new FlxText(FlxG.width / 2, 0, FlxG.width / 2);
                //_score2.setFormat(null,8,0xd8eba2,"right",_score.getShadow());
                _hud.add(_score2);
                _score2.text = "HIGHEST: " + FlxG.scores.GetValue(0) + "\nLAST: " + FlxG.score;
            }
            FlxG.score  = 0;
            _scoreTimer = 0;

            //Then we create the "gun jammed" notification
            _gunjam = new FlxGroup();
            _gunjam.add(new FlxSprite(0, FlxG.height - 22).makeGraphic((uint)FlxG.width, 24, Color.Orange));

            /*
             * if(Gdx.app.getType() == ApplicationType.WebGL)
             *      _gunjam.add(new FlxText(0,FlxG.height-22,FlxG.width,"GUN IS JAMMED").setFormat(ImgFont20,20,0xd8eba2,"center"));
             * else*/
            _gunjam.add(new FlxText(0, FlxG.height - 22, FlxG.width, "GUN IS JAMMED"));       /*.setFormat(null,16,0xd8eba2,"center"));*/
            _gunjam.Visible = false;
            _hud.add(_gunjam);

            //After we add all the objects to the HUD, we can go through
            //and set any property we want on all the objects we added
            //with this sweet function.  In this case, we want to set
            //the scroll factors to zero, to make sure the HUD doesn't
            //wiggle around while we play.
            _hud.SetAll("ScrollFactor", new FlxPoint(0, 0));
            _hud.SetAll("Cameras", new List <FlxCamera> {
                FlxG.camera
            });

            /*FlxG.playMusic(SndMode);*/
            FlxG.flash(Color.White);
            _fading = false;

            //Debugger Watch examples
            FlxG.watch(_player, "x");
            FlxG.watch(_player, "y");
            //FlxG.watch(FlxG.class,"score");
        }
Ejemplo n.º 2
0
		//private FlxVirtualPad _pad;
		
		public override void create()
		{
	//		FlxG.mouse.hide();
			
			/*_sfxCount = new FlxSound().loadEmbedded(SndCount, false, false, FlxSound.SFX);*/
			/*
			_pad = new FlxVirtualPad(FlxVirtualPad.DPAD_FULL, FlxVirtualPad.A_B);
			_pad.Alpha = 0.5f;
			*/		
	//		if(Gdx.app.getType() == ApplicationType.Desktop || MenuState.attractMode)
	//			_pad.visible = false;

			//Here we are creating a pool of 100 little metal bits that can be exploded.
			//We will recycle the crap out of these!
			_littleGibs = new FlxEmitter();
			_littleGibs.setXSpeed(-150,150);
			_littleGibs.setYSpeed(-200,0);
			_littleGibs.setRotation(-720,-720);
			_littleGibs.gravity = 350;
			_littleGibs.bounce = 0.5f;
			_littleGibs.makeParticles(ImgGibs,100,10,true,0.5f);

			//Next we create a smaller pool of larger metal bits for exploding.
			_bigGibs = new FlxEmitter();
			_bigGibs.setXSpeed(-200,200);
			_bigGibs.setYSpeed(-300,0);
			_bigGibs.setRotation(-720,-720);
			_bigGibs.gravity = 350;
			_bigGibs.bounce = 0.35f;
			_bigGibs.makeParticles(ImgSpawnerGibs,50,20,true,0.5f);

			//Then we'll set up the rest of our object groups or pools
			_blocks = new FlxGroup();
			_decorations = new FlxGroup();
			_enemies = new FlxGroup();
			_spawners = new FlxGroup();
			_hud = new FlxGroup();
			_enemyBullets = new FlxGroup();
			_bullets = new FlxGroup();

			//Now that we have references to the bullets and metal bits,
			//we can create the player object.
			_player = new Player(316,300,_bullets,_littleGibs/*, _pad*/);

			//This refers to a custom function down at the bottom of the file
			//that creates all our level geometry with a total size of 640x480.
			//This in turn calls buildRoom() a bunch of times, which in turn
			//is responsible for adding the spawners and spawn-cameras.
			generateLevel();

			//Add bots and spawners after we add blocks to the state,
			//so that they're drawn on top of the level, and so that
			//the bots are drawn on top of both the blocks + the spawners.
			add(_spawners);
			add(_littleGibs);
			add(_bigGibs);
			add(_blocks);
			add(_decorations);
			add(_enemies);

			//Then we add the player and set up the scrolling camera,
			//which will automatically set the boundaries of the world.
			add(_player);
			FlxG.camera.setBounds(0,0,640,640,true);
			FlxG.camera.follow(_player,FlxCamera.StylePlatformer);

			//We add the bullets to the scene here,
			//so they're drawn on top of pretty much everything
			add(_enemyBullets);
			add(_bullets);
			add(_hud);

			//Finally we are going to sort things into a couple of helper groups.
			//We don't add these groups to the state, we just use them for collisions later!
			_hazards = new FlxGroup();
			_hazards.add(_enemyBullets);
			_hazards.add(_spawners);
			_hazards.add(_enemies);
			_objects = new FlxGroup();
			_objects.add(_enemyBullets);
			_objects.add(_bullets);
			_objects.add(_enemies);
			_objects.add(_player);
			_objects.add(_littleGibs);
			_objects.add(_bigGibs);

			//From here on out we are making objects for the HUD,
			//that is, the player score, number of spawners left, etc.
			//First, we'll create a text field for the current score
			_score = new FlxText(FlxG.width/4,0,FlxG.width/2);
			/*
			if(Gdx.app.getType() == ApplicationType.WebGL)
				_score.setFormat(ImgFont20,20,0xd8eba2,"center",0x131c1b);			
			else*/
				/*_score.setFormat(null,16,0xd8eba2,"center",0x131c1b);*/
			_hud.add(_score);
			if (FlxG.scores == null) {
				FlxG.scores = new int[2] { 0,0 };
			}

			//Then for the player's highest and last scores
			if(FlxG.score > (int)FlxG.scores.GetValue(0))
				FlxG.scores.SetValue(0, FlxG.score);
			if((int)FlxG.scores.GetValue(0) != 0)
			{
				_score2 = new FlxText(FlxG.width/2,0,FlxG.width/2);
				//_score2.setFormat(null,8,0xd8eba2,"right",_score.getShadow());
				_hud.add(_score2);
				_score2.text = "HIGHEST: "+FlxG.scores.GetValue(0)+"\nLAST: "+FlxG.score;
			}
			FlxG.score = 0;
			_scoreTimer = 0;

			//Then we create the "gun jammed" notification
			_gunjam = new FlxGroup();
			_gunjam.add(new FlxSprite(0,FlxG.height-22).makeGraphic((uint)FlxG.width,24,Color.Orange));
			/*
			if(Gdx.app.getType() == ApplicationType.WebGL)
				_gunjam.add(new FlxText(0,FlxG.height-22,FlxG.width,"GUN IS JAMMED").setFormat(ImgFont20,20,0xd8eba2,"center"));
			else*/
			_gunjam.add(new FlxText(0,FlxG.height-22,FlxG.width,"GUN IS JAMMED"));/*.setFormat(null,16,0xd8eba2,"center"));*/
			_gunjam.Visible = false;
			_hud.add(_gunjam);

			//After we add all the objects to the HUD, we can go through
			//and set any property we want on all the objects we added
			//with this sweet function.  In this case, we want to set
			//the scroll factors to zero, to make sure the HUD doesn't
			//wiggle around while we play.
			_hud.SetAll("ScrollFactor",new FlxPoint(0,0));
			_hud.SetAll("Cameras",new List<FlxCamera> {FlxG.camera});

			/*FlxG.playMusic(SndMode);*/
			FlxG.flash(Color.White);
			_fading = false;

			//Debugger Watch examples
			FlxG.watch(_player,"x");
			FlxG.watch(_player,"y");
			//FlxG.watch(FlxG.class,"score");
		}