当前位置: 首页>>代码示例>>C#>>正文


C# SpriteBatch类代码示例

本文整理汇总了C#中SpriteBatch的典型用法代码示例。如果您正苦于以下问题:C# SpriteBatch类的具体用法?C# SpriteBatch怎么用?C# SpriteBatch使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SpriteBatch类属于命名空间,在下文中一共展示了SpriteBatch类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DrawDamageDots

 internal void DrawDamageDots(SpriteBatch spriteBatch, Texture2D debugTex, Color color)
 {
     foreach (var dot in frames[currentFrameIndex].DamageDots)
     {
         spriteBatch.Draw(debugTex, dot, color);
     }
 }
开发者ID:rickbatka,项目名称:co-op-engine,代码行数:7,代码来源:LightAnimationSystem.cs

示例2: Initialize

        public override void Initialize()
        {
            this.game = new AntinoidProject.Game ();
            this.game.Initialize (this);

            #region WAVE SOFTWARE LICENSE AGREEMENT
            this.backgroundSplashColor = new Color (32, 32, 32, 255);
            this.spriteBatch = new SpriteBatch (WaveServices.GraphicsDevice);

            var resourceNames = Assembly.GetExecutingAssembly ().GetManifestResourceNames ();
            string name = string.Empty;

            foreach (string item in resourceNames) {
                if (item.Contains ("SplashScreen.wpk")) {
                    name = item;
                    break;
                }
            }

            if (string.IsNullOrWhiteSpace (name)) {
                throw new InvalidProgramException ("License terms not agreed.");
            }

            using (Stream stream = Assembly.GetExecutingAssembly ().GetManifestResourceStream (name)) {
                this.splashScreen = WaveServices.Assets.Global.LoadAsset<Texture2D> (name, stream);
            }

            position = new Vector2 ();
            position.X = (this.Width / 2.0f) - (this.splashScreen.Width / 2.0f);
            position.Y = (this.Height / 2.0f) - (this.splashScreen.Height / 2.0f);
            #endregion
        }
开发者ID:jaumefc,项目名称:arkanoid,代码行数:32,代码来源:App.cs

示例3: Initialize

        /// <summary>
        /// Initialize this instance.
        /// </summary>
        public override void Initialize()
        {
            this.game = new NormalMap.Game();
            this.game.Initialize(this);

            #region WAVE SOFTWARE LICENSE AGREEMENT
            this.backgroundSplashColor = new Color("#ebebeb");
            this.spriteBatch = new SpriteBatch(WaveServices.GraphicsDevice);

            var resourceNames = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceNames();
            string name = string.Empty;

            foreach (string item in resourceNames)
            {
                if (item.Contains("SplashScreen.wpk"))
                {
                    name = item;
                    break;
                }
            }

            if (string.IsNullOrWhiteSpace(name))
            {
                throw new InvalidProgramException("License terms not agreed.");
            }

            using (Stream stream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(name))
            {
                this.splashScreen = WaveServices.Assets.Global.LoadAsset<Texture2D>(name, stream);
            }
            #endregion
        }
开发者ID:WaveEngine,项目名称:Samples,代码行数:35,代码来源:MainWindow.cs

示例4: Draw

		new public void Draw(SpriteBatch batch) {
			if (base._visible) {
				pos = base.ConvertToWorldPos();
				scale = base.ConvertToWorldScale();
				rotation = base.ConvertToWorldRot();
				int size = _text.Length;
				if (this._type == LabelType.TEXT_ALIGNMENT_LEFT) {
					for (int i = 0; i < size; i++) {
						base._textureAtlas.Draw(i, batch, pos[0] + i
								* this._charWidth, pos[1], rotation, scale[0],
								scale[1], batch.GetColor());
					}
				} else if (this._type == LabelType.TEXT_ALIGNMENT_RIGHT) {
					for (int j = 0; j < size; j++) {
						base._textureAtlas.Draw(j, batch, pos[0]
								- (size * this._charWidth) + (j * this._charWidth),
								pos[1], rotation, scale[0], scale[1],
								batch.GetColor());
					}
				} else {
					for (int k = 0; k < size; k++) {
						base._textureAtlas.Draw(k, batch, pos[0]
								- ((size * this._charWidth) / 2)
								+ (k * this._charWidth), pos[1], rotation,
								scale[0], scale[1], batch.GetColor());
					}
				}
			}
		}
开发者ID:207h2Flogintvg,项目名称:LGame,代码行数:29,代码来源:LNLabelAtlas.cs

示例5: LoadContent

		/// <summary>
		/// Load content
		/// </summary>
		public override void LoadContent()
		{
			Trace.WriteLine("[MainMenu] LoadContent()");

			Batch = new SpriteBatch();
	
			Tileset = ResourceManager.CreateAsset<TileSet>("Main Menu");

			Font = ResourceManager.CreateSharedAsset<BitmapFont>("intro", "intro");

			StringTable = ResourceManager.CreateAsset<StringTable>("main");

			Buttons.Add(new ScreenButton("", new Rectangle(156, 324, 340, 14)));
			Buttons[0].Selected += new EventHandler(LoadGameEvent);

			Buttons.Add(new ScreenButton("", new Rectangle(156, 342, 340, 14)));
			Buttons[1].Selected += new EventHandler(StartNewGameEvent);

			Buttons.Add(new ScreenButton("", new Rectangle(156, 360, 340, 14)));
			Buttons[2].Selected += new EventHandler(OptionEvent);

			Buttons.Add(new ScreenButton("", new Rectangle(156, 378, 340, 14)));
			Buttons[3].Selected += new EventHandler(QuitEvent);

			Theme = new AudioStream();
			Theme.LoadOgg("main.ogg");
			Theme.Loop = true;
			//Theme.Play();


		}
开发者ID:melkor54248,项目名称:dungeoneye,代码行数:34,代码来源:MainMenu.cs

示例6: LoadContent

 protected override void LoadContent()
 {
     _mouseIcon = Game.Content.Load<Texture2D>("mouse");
     //_spriteBatch = new SpriteBatch(GraphicsDevice);
     _spriteBatch = new SpriteBatch(GraphicsDevice);
     base.LoadContent();
 }
开发者ID:ImaginationOverflow,项目名称:KinectLibrary,代码行数:7,代码来源:KinectMouse.cs

示例7: DrawOnScreen

	public void DrawOnScreen(SpriteBatch sb, double layer) {
		sb.End();
		sb.Begin(SpriteSortMode.Immediate,BlendState.Additive);
		foreach (ModWorld.Effect e in ModWorld.effects) e.Draw(sb);
		sb.End();
		sb.Begin();
	}
开发者ID:mugmickey,项目名称:Terraria-tConfig-Mods,代码行数:7,代码来源:OSIEffects.cs

示例8: DrawAndUpdate

        public void DrawAndUpdate(SpriteBatch spriteBatch, TimeSpan elapsedTime, Texture2D spriteSheet, float timescale, Texture2D grid)
        {
            if (timescale != 0)
            {
                currentFrameTimer -= TimeSpan.FromMilliseconds(elapsedTime.TotalMilliseconds * timescale);
                if (currentFrameTimer <= TimeSpan.Zero)
                {
                    AdvanceFrameAndReset();
                }
            }

            //threading issue
            if (currentFrameIndex >= frames.Count)
            {
                currentFrameIndex = 0;
            }

            if (frames.Count != 0)
            {
                spriteBatch.Draw(spriteSheet, frames[currentFrameIndex].DrawRectangle, frames[currentFrameIndex].SourceRectangle, Color.White);

                spriteBatch.Draw(grid, frames[currentFrameIndex].DrawRectangle, Color.Red);
                spriteBatch.Draw(grid, frames[currentFrameIndex].SourceRectangle, Color.Blue);
            }
        }
开发者ID:rickbatka,项目名称:co-op-engine,代码行数:25,代码来源:LightAnimationSystem.cs

示例9: DrawSelf

		protected override void DrawSelf(SpriteBatch spriteBatch)
		{
			String newString = GetInputText(currentString);
			if (!newString.Equals(currentString))
			{
				currentString = newString;
				OnTextChange(this, new EventArgs());
			}
			else
			{
				currentString = newString;
			}
			if (++textBlinkerCount >= 20)
			{
				textBlinkerState = (textBlinkerState + 1) % 2;
				textBlinkerCount = 0;
			}
			String displayString = currentString;
			if (this.textBlinkerState == 1)
			{
				displayString = displayString + "|";
			}
			CalculatedStyle space = base.GetDimensions();
			if (currentString.Length == 0)
			{
				Utils.DrawBorderString(spriteBatch, hintText, new Vector2(space.X, space.Y), Color.Gray, 1f);
			}
			else
			{
				Utils.DrawBorderString(spriteBatch, displayString, new Vector2(space.X, space.Y), Color.White, 1f);
			}
		}
开发者ID:JavidPack,项目名称:TerraCustom,代码行数:32,代码来源:UIInputTextField.cs

示例10: Register

	public static void Register() {
		style = Settings.GetChoice("style");
		OnScreenInterface.Register(new OSIBossHPBar(),OnScreenInterface.LAYER_INTERFACE_SCREEN);
		
		if (style == "circular_bottomleft") {
			dss1 = new DepthStencilState {
				StencilEnable = true,
				StencilFunction = CompareFunction.Equal,
				StencilPass = StencilOperation.Increment,
				ReferenceStencil = 0,
				DepthBufferEnable = false,
			};
			bs1 = new BlendState();
			bs1.ColorWriteChannels = ColorWriteChannels.None;
			
			dss2 = new DepthStencilState {
				StencilEnable = true,
				StencilFunction = CompareFunction.NotEqual,
				StencilPass = StencilOperation.Keep,
				ReferenceStencil = 0,
				DepthBufferEnable = false,
			};
			
			rt = new RenderTarget2D(
				Config.mainInstance.graphics.GraphicsDevice,
				1920,
				96,
				false,Config.mainInstance.graphics.GraphicsDevice.DisplayMode.Format,DepthFormat.Depth24Stencil8
			);
			sb = new SpriteBatch(Config.mainInstance.graphics.GraphicsDevice);
		}
	}
开发者ID:mugmickey,项目名称:Terraria-tConfig-Mods,代码行数:32,代码来源:OSIBossHPBar.cs

示例11: HWSurfaceInstance

 static HWSurfaceInstance()
 {
     _atlas = new RenderTexture(_aw, _ah);
     _atlastex = _atlas.Texture;
     _batch = new SpriteBatch(_atlas);
     _batch.SetBlendMode(BlendMode.None);
 }
开发者ID:Radnen,项目名称:sphere-sfml,代码行数:7,代码来源:HWSurfaceInstance2.cs

示例12: Draw

		/// <summary>
		/// Draws
		/// </summary>
		/// <param name="batch"></param>
		public override void Draw(SpriteBatch batch)
		{
			base.Draw(batch);


			// Display message
			if (Hero == null)
			{
				batch.DrawString(GUI.MenuFont, new Point(26, 58), RectangleColor, Message);
			}
			else
			{
				//batch.DrawString(Camp.Font, new Point(16, 76), Color.White, "0 of 0 remaining.");
			}

			#region Draw heroes
			for (int y = 0; y < 3; y++)
			{
				for (int x = 0; x < 2; x++)
				{
					Hero hero = GameScreen.Team.Heroes[y * 2 + x];
					if (hero == null)
						continue;

					float col = (float)Math.Sin(1.0f);
					batch.DrawRectangle(new Rectangle(366 + x * 144, 2 + y * 104, 130, 104), Color.White);
					batch.DrawRectangle(new Rectangle(367 + x * 144, 4 + y * 104, 128, 101), Color.White);
				}
			}
			#endregion
		}
开发者ID:melkor54248,项目名称:dungeoneye,代码行数:35,代码来源:DropCharacterWindow.cs

示例13: DrawOnScreen

	public void DrawOnScreen(SpriteBatch sb, double layer) {
		Player player = Main.player[Main.myPlayer];
		
		if (resetChat) Main.chatMode = false;
		resetChat = false;
		
		if (!Settings.GetBool("toggle") && Main.playerInventory && !Main.craftingHide && (!Codable.RunGlobalMethod("ModWorld","PreDrawAvailableRecipes",sb) || (bool)Codable.customMethodReturn)) {
			if (Main.reforge || player.chest != -1 || Main.npcShop != 0 || player.talkNPC != -1 || Main.craftGuide || Main.ForceGuideMenu) return;
			if (Config.tileInterface == null && Config.npcInterface == null) {
				if (shouldInit) {
					GuiCraft.Init();
					shouldInit = false;
				}
				GuiCraft.Create();
			}
		}
		
		if (Config.tileInterface != null && Config.tileInterface.code is GuiCraft) {
			Config.tileInterface.SetLocation(new Vector2(player.position.X/16f,player.position.Y/16f));
			((GuiCraft)Config.tileInterface.code).PreDrawInterface(sb);
		}
		
		if (Main.playerInventory && Settings.GetBool("toggle") && (Config.tileInterface == null || Config.tileInterface.code is GuiCraft)) {
			Color c = Config.tileInterface != null && Config.tileInterface.code is ModWorld.GuiCraft ? Color.White : Color.Gray;
			sb.Draw(ModWorld.texShow,new Vector2(414,210),GetTexRectangle(texShow),c,0f,default(Vector2),1f,SpriteEffects.None,0f);
		}
	}
开发者ID:mugmickey,项目名称:Terraria-tConfig-Mods,代码行数:27,代码来源:OSICrafting.cs

示例14: Draw

	public override void Draw(SpriteBatch sb, Projectile p) {
		Vector2 pc = p.position+new Vector2(p.width/2f,p.height/2f);
		
		if (fired) {
			sb.End();
			sb.Begin(SpriteSortMode.Immediate,BlendState.Additive);
			
			foreach (Spark spark in sparks) spark.Draw(sb,p,this);
			for (int i = 0; i < sparks.Count; i++) if (sparks[i].dead) sparks.RemoveAt(i--);
			
			sb.End();
			sb.Begin();
			
			if (sparks.Count == 0) p.Kill();
		} else {
			fired = true;
			
			int r, g, b;
			Color c;
			float degrees;
			
			byte[] bytes = BitConverter.GetBytes(seed);
			Random rnd = new Random();
			
			degrees = (float)(rnd.NextDouble()*360d);
			HsvToRgb(bytes[0]*360f/255f,bytes[1]/255f,1f,out r,out g,out b);
			c = new Color(r,g,b);
			for (int i = 0; i < 20; i++) sparks.Add(new MySpark(pc,Util.Vector((float)(1.5f+rnd.NextDouble()*.75f),360f/20f*i+degrees),c,80+rnd.Next(40)));
			
			degrees = (float)(rnd.NextDouble()*360d);
			HsvToRgb(bytes[2]*360f/255f,bytes[3]/255f,1f,out r,out g,out b);
			c = new Color(r,g,b);
			for (int i = 0; i < 40; i++) sparks.Add(new MySpark(pc,Util.Vector((float)(3f+rnd.NextDouble()*1.5f),360f/40f*i+degrees),c,80+rnd.Next(40)));
		}
	}
开发者ID:mugmickey,项目名称:Terraria-tConfig-Mods,代码行数:35,代码来源:FireworkTwoWave.cs

示例15: Draw

	public void Draw(SpriteBatch sb, int xx, ref int yy, int ww) {
		if (!Visible()) return;
		
		if (Main.mouseLeft && Main.mouseLeftRelease && ModWorld.GuiAchievements.MouseIn(sb.GraphicsDevice.ScissorRectangle,new Rectangle(xx,yy,ww,42))) {
			toggled = !toggled;
			if (toggled) GuiAchievements.setScroll = yy+GuiAchievements.scroll-120;
		}
		
		Color white = new Color(255,255,255,191);
		Color limish = new Color(136,255,0,191);
		bool achieved = Achieved();
		sb.Draw(ModWorld.Notifier.frame1,new Rectangle(xx+1,yy,ww-2,42),achieved ? limish : white);
		sb.Draw(ModWorld.Notifier.frame2,new Rectangle(xx,yy,1,42),achieved ? limish : white);
		sb.Draw(ModWorld.Notifier.frame2,new Rectangle(xx+ww-1,yy,1,42),achieved ? limish : white);
		
		ModWorld.DrawStringShadowed(sb,Main.fontMouseText,title,new Vector2(xx+8,yy+10),Color.White,Color.Black);
		string value = ""+Value(true)+"/"+Value(false);
		ModWorld.DrawStringShadowed(sb,Main.fontMouseText,value,new Vector2(xx+ww-12-Main.fontMouseText.MeasureString(value).X,yy+10),Color.White,Color.Black);
		
		yy += 42;
		
		if (toggled) {
			for (int i = 0; i < categories.Count; i++) categories[i].Draw(sb,xx+24,ref yy,ww-48);
			for (int i = 0; i < achievements.Count; i++) achievements[i].Draw(sb,xx+24,ref yy,ww-48);
		}
	}
开发者ID:mugmickey,项目名称:Terraria-tConfig-Mods,代码行数:26,代码来源:Category.cs


注:本文中的SpriteBatch类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。