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


C# SpriteFont类代码示例

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


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

示例1: Button

 public Button(Texture2D texture, SpriteFont font, SpriteBatch sBatch)
 {
     image = texture;
     this.font = font;
     location = new Rectangle(0, 0, image.Width, image.Height);
     spriteBatch = sBatch;
 }
开发者ID:jrme123,项目名称:Majabaja,代码行数:7,代码来源:Button.cs

示例2: RegisterFont

        /// <summary>
        /// Registers the font with the specified name.
        /// </summary>
        /// <param name="name">The name of the font to register.</param>
        /// <param name="font">The font to register.</param>
        public void RegisterFont(String name, SpriteFont font)
        {
            Contract.RequireNotEmpty(name, "name");
            Contract.Require(font, "font");

            registeredFonts.Add(name, font);
        }
开发者ID:prshreshtha,项目名称:ultraviolet,代码行数:12,代码来源:TextLayoutEngine.cs

示例3: GetUIEntity

        protected  Entity GetUIEntity(SpriteFont font, bool fixedSize, Vector3 position)
        {
            // Create and initialize "Touch Screen to Start"
            var touchStartLabel = new ContentDecorator
            {
                Content = new TextBlock
                {
                    Font = font,
                    TextSize = 32,
                    Text = (fixedSize) ? "Fixed Size UI" : "Regular UI",
                    TextColor = Color.White
                },
                Padding = new Thickness(30, 20, 30, 25),
                HorizontalAlignment = HorizontalAlignment.Center
            };

            //touchStartLabel.SetPanelZIndex(1);

            var grid = new Grid
            {
                BackgroundColor = (fixedSize) ? new Color(255, 0, 255) : new Color(255, 255, 0),
                MaximumWidth = 100,
                MaximumHeight = 100,
                MinimumWidth = 100,
                MinimumHeight = 100,
                VerticalAlignment = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Center,
            };

            grid.RowDefinitions.Add(new StripDefinition(StripType.Auto));
            grid.ColumnDefinitions.Add(new StripDefinition());
            grid.LayerDefinitions.Add(new StripDefinition());

            grid.Children.Add(touchStartLabel);

            // Add the background
            var background = new ImageElement { StretchType = StretchType.Fill };
            background.SetPanelZIndex(-1);

            var uiEntity = new Entity();

            // Create a procedural model with a diffuse material
            var uiComponent = new UIComponent
            {
                Page = new UIPage
                {
                    RootElement = new UniformGrid { Children = { background, grid } }
                },
                //IsBillboard = true,
                IsFixedSize = fixedSize,
                IsFullScreen = false,
                Resolution = new Vector3(100, 100, 100), // Same size as the inner grid
                Size = new Vector3(0.1f), // 10% of the vertical resolution
            };
            uiEntity.Add(uiComponent);

            uiEntity.Transform.Position = position;

            return uiEntity;
        }
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:60,代码来源:TestFixedSizeUI.cs

示例4: AddFont

	// Adds a font to our list:
	static void AddFont(SpriteFont f)
	{
		SpriteFont[] newFonts = new SpriteFont[fonts.Length + 1];
		fonts.CopyTo(newFonts, 0);
		newFonts[fonts.Length] = f;
		fonts = newFonts;
	}
开发者ID:robert-irribarren,项目名称:TraumaOR,代码行数:8,代码来源:FontStore.cs

示例5: TextGameObject

 /// <summary>Create a new text object.</summary>
 /// <param name="assetname">The name of the sprite font to use.</param>
 /// <param name="layer">The layer to draw the text in.</param>
 /// <param name="id">The reference ID for this text object.</param>
 public TextGameObject(string assetname, int layer = 0, string id = "") : base(layer, id)
 {
     spriteFont = GameEnvironment.AssetManager.Content.Load<SpriteFont>(assetname);
     color = Color.White;
     text = "";
     centered = false;
 }
开发者ID:alikimoko,项目名称:Practicum3.Platformer,代码行数:11,代码来源:TextGameObject.cs

示例6: LoadContent

    public static void LoadContent(MainGame game)
    {
        // Load assets
        player = game.Content.Load<Texture2D>("player");
        gun = game.Content.Load<Texture2D>("gun");
        dot = game.Content.Load<Texture2D>("dot");
        create = game.Content.Load<Texture2D>("create");
        bullet = game.Content.Load<Texture2D>("bullet");
        aim = game.Content.Load<Texture2D>("aim");
        font = game.Content.Load<SpriteFont>("spriteFont");

        // Init tiles 
        tileTable.Put('O', new TileData(ETileType.FLOOR, dot, Color.DarkGray));
        tileTable.Put('W', new TileData(ETileType.WALL, dot, Color.Black));
        tileTable.Put('S', new TileData(ETileType.SPAWN, dot, Color.Red));
        tileTable.Put('C', new TileData(ETileType.CRATE, create, Color.Brown));


        // Init key bindings
        inputTable.Put(Player.Commands.MoveUp, new LinkedList<Keys>() { Keys.Up, Keys.W });
        inputTable.Put(Player.Commands.MoveDown, new LinkedList<Keys>() { Keys.Down, Keys.S });
        inputTable.Put(Player.Commands.MoveLeft, new LinkedList<Keys>() { Keys.Left, Keys.A });
        inputTable.Put(Player.Commands.MoveRight, new LinkedList<Keys>() { Keys.Right, Keys.D });


        loadMap(game);
    }
开发者ID:Caresilabs,项目名称:MAH_Artificial_Intelligence,代码行数:27,代码来源:Globals.cs

示例7: GameWorld

    public GameWorld(int width, int height, ContentManager Content)
    {
        screenWidth = width;
        screenHeight = height;
        random = new Random();
        gameState = GameState.Menu;
        inputHelper = new InputHelper();
        block = Content.Load<Texture2D>("block");
        reset = Content.Load<Texture2D>("reset");
        font = Content.Load<SpriteFont>("SpelFont");
        font2 = Content.Load<SpriteFont>("SpriteFont1");
        font3 = Content.Load<SpriteFont>("SpriteFont2");
        playButton = Content.Load<Texture2D>("Play");
        optionsButton = Content.Load<Texture2D>("Options");
        backButton = Content.Load<Texture2D>("Back");
        polytris = Content.Load<Texture2D>("Polytris");
        grid = new TetrisGrid(block);
        level = 1;
        levelspeed = 1;
        score = 0;
        i = (int)random.Next(7) + 1;
        i2 = (int)random.Next(7) + 1;
        blockcounter = 1;

        blocks = new BlockList(block, Content);          //Voegen de verschillende blockobjecten toe aan de lijst
        block1 = new Block1(block, Content);
        blocks.Add(block1, 1);
        block2 = new Block2(block, Content);
        blocks.Add(block2, 2);
        block3 = new Block3(block, Content);
        blocks.Add(block3, 3);
        block4 = new Block4(block, Content);
        blocks.Add(block4, 4);
        block5 = new Block5(block, Content);
        blocks.Add(block5, 5);
        block6 = new Block6(block, Content);
        blocks.Add(block6, 6);
        block7 = new Block7(block, Content);
        blocks.Add(block7, 7);

        //Voegen de verschillende blockobjecten toe aan een tweede lijst voor het tekenen van het volgende blokje
        block1res = new Block1(block, Content);
        blocks.AddToReserve(block1res, 1);
        block2res = new Block2(block, Content);
        blocks.AddToReserve(block2res, 2);
        block3res = new Block3(block, Content);
        blocks.AddToReserve(block3res, 3);
        block4res = new Block4(block, Content);
        blocks.AddToReserve(block4res, 4);
        block5res = new Block5(block, Content);
        blocks.AddToReserve(block5res, 5);
        block6res = new Block6(block, Content);
        blocks.AddToReserve(block6res, 6);
        block7res = new Block7(block, Content);
        blocks.AddToReserve(block7res, 7);

        options = new Options(block, reset, backButton, width, height, font, blocks);
        menu = new Menu(playButton, optionsButton, polytris, width, height);
        gameOver = new GameOver(backButton, width, height);
    }
开发者ID:Supercarlijn,项目名称:Tetris,代码行数:60,代码来源:GameWorld.cs

示例8: FontWidth

 public int FontWidth(SpriteFont font, String text)
 {
     //to get the text exactly in the middle of the screen
     int fontWidth;
     fontWidth = (int)font.MeasureString(text).X;
     return fontWidth;
 }
开发者ID:Suwappertjes,项目名称:Project-Bromied,代码行数:7,代码来源:GameWorld.cs

示例9: DrawStringCall

 public DrawStringCall(SpriteFont font, string value, Vector2 position, Vector4 color)
 {
     this.font = font;
     this.value = value;
     this.position = position;
     this.color = color;
 }
开发者ID:Nakato53,项目名称:FlappyBirdCloneXNAChallenge,代码行数:7,代码来源:DrawStringCall.cs

示例10: FontHeight

 public int FontHeight(SpriteFont font, String text)
 {
     //to get the text exactly in the middle of the screen
     int fontHeight;
     fontHeight = (int)font.MeasureString(text).Y;
     return fontHeight;
 }
开发者ID:Suwappertjes,项目名称:Project-Bromied,代码行数:7,代码来源:GameWorld.cs

示例11: TextStyle

 public TextStyle(SpriteFont font, Boolean? bold, Boolean? italic, Color? color, params GlyphShader[] glyphShaders)
 {
     this.Font = font;
     this.Bold = bold;
     this.Italic = italic;
     this.Color = color;
     this.GlyphShaders = new TextStyleGlyphShaderCollection(glyphShaders);
 }
开发者ID:RUSshy,项目名称:ultraviolet,代码行数:8,代码来源:TextStyle.cs

示例12: Text

 public Text(string Filename, string Text, Vector2 Position)
 {
     if (Filename == "") { Filename = "SpriteFont1"; }
     fontName = Filename;
     font = Cache.Font(Filename);
     position = Position;
     content = Text;
 }
开发者ID:Dahrkael,项目名称:CoRe,代码行数:8,代码来源:Text.cs

示例13: GameWorld

    public GameWorld(int width, int height, ContentManager Content)
    {
        screenWidth = width;
        screenHeight = height;
        gameState = GameState.StartScreen;

        StartScreenFont = Content.Load<SpriteFont>("Fipps");
    }
开发者ID:Suwappertjes,项目名称:Project-Bromied,代码行数:8,代码来源:GameWorld.cs

示例14: LoadContent

 protected override void LoadContent()
 {
     //BGM�̎擾�@���Ǘ\��
     song[0] = Content.Load<Song>("Content/GLORIA");
     font = Content.Load<SpriteFont>("Content/MS20");
     sprite = new SpriteBatch(GraphicsDevice);
     ios = new IOS(Gm.GraphicsDevice, sprite,font ,song ,"Hoge.txt");
     base.LoadContent();
 }
开发者ID:TowerTin,项目名称:SourceCode,代码行数:9,代码来源:Program.cs

示例15: Paddle

 public Paddle(Vector2 position, Vector2 fontPosition, string texture, float multiplier, Keys kUp, Keys kDown)
     : base(texture, position)
 {
     this.kUp = kUp;
     this.kDown = kDown;
     this.multiplier = multiplier;
     this.fontPosition = fontPosition;
     this.score = 98;
     font = AssetHandler.GetSpriteFont("SpriteFont1");
 }
开发者ID:pienpien34,项目名称:RPong,代码行数:10,代码来源:Paddle.cs


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