• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Graphics.Texture类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: load_batch_textures

        public static void load_batch_textures(string folder)
        {
            //Debug.Log("Loading textures from folder " + folder);
            Debug.StartLogGroup();

                DirectoryInfo dir = new DirectoryInfo(folder);

                if (dir.Exists)
                {

                    FileInfo[] bmpfiles = dir.GetFiles("*.bmp", System.IO.SearchOption.AllDirectories);
                    FileInfo[] pngfiles = dir.GetFiles("*.png", System.IO.SearchOption.AllDirectories);
                    FileInfo[] files = new FileInfo[bmpfiles.Length + pngfiles.Length];

                    bmpfiles.CopyTo(files, 0);
                    pngfiles.CopyTo(files, bmpfiles.Length);

                    if (files.Length > 0) FileWatch.add_folder(folder);

                    for (int f = 0; f < files.Length; f++)
                    {
                        Texture tex = new Texture();
                        tex.assign_path(files[f].FullName);
                        textures.Add(tex.identifier, tex);
                    }
                }

            Debug.EndLogGroup();
        }
开发者ID:AllMyKilobits,项目名称:XFramework,代码行数:29,代码来源:Loader.cs


示例2: Sprite

 public Sprite(string name, int type)
 {
     _path = name;
     _type = type;
     _texture = new Texture(name);
     _loaded = (_texture == null) ? false : true;
 }
开发者ID:ComposerCookie,项目名称:WanderingSoul,代码行数:7,代码来源:Sprite.cs


示例3: ButtonControl

        public ButtonControl(Font font, uint size, Texture button, Texture hover, Texture press)
        {
            left = new RectangleShape();
            middle = new RectangleShape();
            right = new RectangleShape();

            left.Texture = button;
            middle.Texture = button;
            right.Texture = button;

            left.TextureRect = new IntRect(0, 0, (int)button.Size.X / 2 - 1, (int)button.Size.Y);
            middle.TextureRect = new IntRect((int)button.Size.X / 2 - 1, 0, 2, (int)button.Size.Y);
            right.TextureRect = new IntRect((int)button.Size.X / 2 + 1, 0, (int)button.Size.X / 2, (int)button.Size.Y);

            text = new TextControl(font, size) { TextAlignment = Alignment.MiddleCenter, Bold = true };
            text.BackgroundColor = Color.Transparent;

            IsHovered = false;
            IsPressed = false;
            ClickYOffset = 4.0f;

            buttonTexture = button;
            hoverTexture = hover;
            pressedTexture = press;
        }
开发者ID:Scellow,项目名称:sfml-ui,代码行数:25,代码来源:ButtonControl.cs


示例4: SetImage

 public void SetImage(string _source, int _imageWidth, int _imageHeight)
 {
     source = _source;
     imageWidth = _imageWidth;
     imageHeight = _imageHeight;
     image = new Texture("./assets/" + source);
 }
开发者ID:riordanp,项目名称:panjin,代码行数:7,代码来源:TileSet.cs


示例5: Edge

        public Edge()
            : base("edge post-effect")
        {
            // Create the off-screen surface
            mySurface = new RenderTexture(800, 600);
            mySurface.Smooth = true;

            // Load the textures
            myBackgroundTexture = new Texture("resources/sfml.png");
            myBackgroundTexture.Smooth = true;
            myEntityTexture = new Texture("resources/devices.png");
            myEntityTexture.Smooth = true;

            // Initialize the background sprite
            myBackgroundSprite = new Sprite(myBackgroundTexture);
            myBackgroundSprite.Position = new Vector2f(135, 100);

            // Load the moving entities
            myEntities = new Sprite[6];
            for (int i = 0; i < myEntities.Length; ++i)
            {
                myEntities[i] = new Sprite(myEntityTexture, new IntRect(96 * i, 0, 96, 96));
            }

            // Load the shader
            myShader = new Shader(null, "resources/edge.frag");
            myShader.SetParameter("texture", Shader.CurrentTexture);
        }
开发者ID:kaldhu,项目名称:MyGameEngine,代码行数:28,代码来源:Shader.cs


示例6: MainTitleScreen

        public MainTitleScreen(RenderWindow window)
            : base(window)
        {
            Type = ScreenType.MainTitleScreen;

            base.Init();
               // Gui.AddGameWidget(imb);

            initMenu();

            StraightLineVariableData slvd = new StraightLineVariableData(200F, 100 * 4);
               // slvd.AddKeyData(.25F, 100F);
            slvd.AddKeyData(.5F, 300F);
               // slvd.AddKeyData(.75F, 100F);
            slvd.ComputeData();

            img = new Image(800, 600, new Color(0, 0, 0, 0));
            for (int i = 0; i < slvd.GetCount(); ++i)
            {
               // Log.Cl(slvd.GetData(i));
                img.SetPixel((uint)(100 + i / 4), (uint)slvd.GetData(i), Color.Red);
               // img.SetPixel((uint)(100 + i / 4), (uint)slvd.GetData(i) + 4, Color.Blue);
            }

            tex = new SFML.Graphics.Texture(img);
            spre = new Sprite(tex);

            imb.AddMessage("hoy hoy !");
            imb.OnStopping += new MessageBox.EventHandler(imb_OnStopping);
        }
开发者ID:eickegao,项目名称:Blazera,代码行数:30,代码来源:MainTitleScreen.cs


示例7: TileMap

        public TileMap(int width, int height, Texture texture)
        {
            Width = width;
            Height = height;

            var lastTile = texture == null ? ushort.MaxValue : (ushort)((texture.Size.X / GameOptions.TileSize) * (texture.Size.Y / GameOptions.TileSize) - 1);

            tiles = new Tile[width, height];

            for (var y = 0; y < height; y++)
            {
                for (var x = 0; x < width; x++)
                {
                    tiles[x, y].Index = lastTile;
                    tiles[x, y].Solid = false;
                }
            }

            var chunkWidth = (width / GameOptions.TileChunkSize) + 1;
            var chunkHeight = (height / GameOptions.TileChunkSize) + 1;

            chunks = new Chunk[chunkWidth, chunkHeight];

            for (var y = 0; y < chunkHeight; y++)
            {
                for (var x = 0; x < chunkWidth; x++)
                {
                    chunks[x, y] = new Chunk(x, y, tiles, texture);
                }
            }
        }
开发者ID:DatZach,项目名称:HumanityAgainstCards,代码行数:31,代码来源:TileMap.cs


示例8: loadContent

        public override void loadContent()
        {
            float logoScale;

            _logoTexture = ResourceManager.getResource<Texture>("logo_1");
            _logoShape = new RectangleShape();
            _logoShape.Texture = _logoTexture;
            _logoShape.Size = new Vector2f(_logoTexture.Size.X, _logoTexture.Size.Y);
            logoScale = Game.window.GetView().Size.X / (float)_logoTexture.Size.X;
            _logoShape.Scale = new Vector2f(logoScale, logoScale);

            _font = ResourceManager.getResource<Font>("immortal_font");
            _options = new List<Text>();
            _options.Add(new Text("New Game", _font, 48));
            _options.Add(new Text("Continue", _font, 48));
            _options.Add(new Text("Options", _font, 48));
            _options.Add(new Text("Exit", _font, 48));

            for (int i = 0; i < _options.Count; i++)
            {
                Text text = _options[i];

                text.Position = new Vector2f(128, i * 48 + _logoShape.Size.Y * _logoShape.Scale.Y + 64);
            }
        }
开发者ID:klutch,项目名称:Loderpit,代码行数:25,代码来源:MainMenuScreen.cs


示例9: LoadContent

        public void LoadContent()
        {
            Texture tex = new Texture("Assets/Textures/TitelScreen.png");
            Background = new Sprite(tex);

            Background.Scale = Game.WindowSize / new Vec2f(Background.Texture.Size.X, Background.Texture.Size.Y);
        }
开发者ID:Kedreals,项目名称:MicrosoftGameJam2015AwesomeHurray,代码行数:7,代码来源:TitleScreen.cs


示例10: Enemy

        /// <summary>
        /// initializes a new Enemy
        /// </summary>
        /// <param name="direction">the direction to the texture as a string</param>
        /// <param name="sPosition">start position</param>
        public Enemy(string direction, Vector2f sPosition)
        {
            textur = new Texture(direction);
            sprite = new Sprite(textur);

            sprite.Position = sPosition;
        }
开发者ID:endert,项目名称:Intro2D,代码行数:12,代码来源:Enemy.cs


示例11: EmoteBubble

 public EmoteBubble(string emote, Actor parent)
 {
     this.emote = emote.ToLower();
     this.parent = parent;
     this.texture = Content.GetTexture("emote_" + emote +".png");
     life = 60 * 4;
 }
开发者ID:libjared,项目名称:iris,代码行数:7,代码来源:EmoteBubble.cs


示例12: GResource

 public GResource(string path, int type)
 {
     _path = path;
     _loaded = false;
     _myTexture = null;
     _type = type;
 }
开发者ID:ComposerCookie,项目名称:JRPDragon,代码行数:7,代码来源:GResource.cs


示例13: 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


示例14: Player

        public Player(Vector2f _position, String _file, GameWorld _world)
        {
            create(_position, _file, 1);
            mWorld      = _world;

            mEntityType = EntityType.Player;
            mHealth     = 100;
            mSegment    = 10;

            mInvicible = false;
            mOnce      = false;
            mTimer     = new Stopwatch();

            mShoot     = new Stopwatch();
            mShoot.Start();

            for (int i = 0; i < 11; i++)
            {
                Texture tex = new Texture("resources/health/health" + i + ".png");
                mHealthBar[i] = new Sprite(tex);

                Vector2f pos = new Vector2f();
                pos.X -= 17f;
                pos.Y -= 10f;
                mHealthBar[i].Position = mPosition - pos;
            }
        }
开发者ID:Jamsterx1,项目名称:Titan,代码行数:27,代码来源:Player.cs


示例15: Menu

        public Menu()
            : base()
        {
            hoverCursor = Content.GetTexture("cursorHover.png");
            defaultCursor = Content.GetTexture("cursorPointer.png");
            currentCursor = defaultCursor;
            char1 = new Animation(Content.GetTexture("idle.png"), 4, 0, 0, true);
            char2 = new Animation(Content.GetTexture("char2_idle.png"), 4, 0, 0, true);
            shader = new RenderStates(new Shader(null, "Content/bgPrlx.frag"));

            rectConnect = new RectangleShape()
            {
                Size = new Vector2f(150, 30),
                Position = new Vector2f(-25, 70)
            };
            rectIP = new RectangleShape()
            {
                Size = new Vector2f(150, 20),
                Position = new Vector2f(-25, 40)
            };
            rectUsername = new RectangleShape()
            {
                Size = new Vector2f(150, 20),
                Position = new Vector2f(-25, 10)
            };

            MainGame.window.TextEntered += TextEnteredEvent;
        }
开发者ID:libjared,项目名称:iris,代码行数:28,代码来源:Menu.cs


示例16: ClassSelectorComponent

        public ClassSelectorComponent(Screen screen, Texture upArrowTexture, Texture downArrowTexture, Texture classSelectorTexture, List<Texture> classTextures, Vector2f position)
            : base(screen)
        {
            _position = position;
            _classTextures = classTextures;

            _upArrow = new RectangleShape();
            _upArrow.Position = position + new Vector2f(0f, -42f);
            _upArrow.Origin = new Vector2f(8f, 8f);
            _upArrow.Texture = upArrowTexture;
            _upArrow.Size = new Vector2f(16f, 16f);

            _classSelector = new RectangleShape();
            _classSelector.Position = position;
            _classSelector.Origin = new Vector2f(32f, 32f);
            _classSelector.Texture = classSelectorTexture;
            _classSelector.Size = new Vector2f(64f, 64f);

            _classIcon = new RectangleShape();
            _classIcon.Position = position;
            _classIcon.Origin = new Vector2f(32f, 32f);
            _classIcon.Texture = _classTextures[(int)_selectedClass];
            _classIcon.Size = new Vector2f(64f, 64f);

            _downArrow = new RectangleShape();
            _downArrow.Position = position + new Vector2f(0f, 42f);
            _downArrow.Origin = new Vector2f(8f, 8f);
            _downArrow.Texture = downArrowTexture;
            _downArrow.Size = new Vector2f(16f, 16f);
        }
开发者ID:klutch,项目名称:Loderpit,代码行数:30,代码来源:ClassSelectorComponent.cs


示例17: LoadSprite

 public static Sprite LoadSprite(string fileName, Vector2f scale)
 {
     Image image = new Image(fileName);
     Texture texture = new Texture(image);
     Sprite sprite = new Sprite(texture) { Scale = scale };
     return sprite;
 }
开发者ID:krixalis,项目名称:Subject2Change,代码行数:7,代码来源:SFMLwrap.cs


示例18: CluwneSprite

 /// <summary>
 /// Creates a new CluwneSprite with a specified portion of the Texture
 /// </summary>
 /// <param name="texture"> Texture to draw </param>
 /// <param name="rectangle"> What part of the Texture to use </param>
 public CluwneSprite(string key, Texture texture, IntRect rectangle)
     : base(texture,rectangle)
 {
     Key = key;
     Position = new Vector2(X, Y);
     Size = new Vector2(Width, Height);
 }
开发者ID:Tri125,项目名称:space-station-14,代码行数:12,代码来源:CluwneSprite.cs


示例19: CreateShadows

        public static bool CreateShadows()
        {

            Image img = spriteSheet.Texture.CopyToImage();

            for (uint k = 0; k < img.Size.X; k++)
                for (uint j = 0; j < img.Size.Y; j++)
                {
                    Color c = img.GetPixel(k, j);
                    if (c.A == 255)
                    {
                        Color d = new Color();
                        d.A = 40;
                        d.R = d.G = d.B = 0;
                        img.SetPixel(k, j, d);
                    }
                }

            Texture tex = new Texture(img);
            Sprite tempsprite = new Sprite();
            tempsprite.Texture = tex;

            shadowSpriteSheet = new RenderTexture(textureSize, textureSize);
            shadowSpriteSheet.Draw(tempsprite);
            shadowSpriteSheet.Display();

            shadowSprite.Texture = shadowSpriteSheet.Texture;

            img.Dispose();
            tempsprite.Dispose();
            tex.Dispose();

            return true;
        }
开发者ID:starboxgames,项目名称:superstarbox,代码行数:34,代码来源:TextureMan.cs


示例20: BigLabeledButtonComponent

        public BigLabeledButtonComponent(Screen screen, Texture buttonTexture, Vector2f position, string text, Color buttonColor, Action onClick)
            : base(screen)
        {
            _buttonTexture = buttonTexture;
            _position = position;
            _buttonColor = buttonColor;
            _selectedColor = new Color(
                (byte)Math.Min(255, (int)_buttonColor.R + 50),
                (byte)Math.Min(255, (int)_buttonColor.G + 50),
                (byte)Math.Min(255, (int)_buttonColor.B + 50),
                255);
            _onClick = onClick;
            _font = ResourceManager.getResource<Font>("immortal_font");

            // Initialize button shape
            _buttonShape = new RectangleShape();
            _buttonShape.Texture = _buttonTexture;
            _buttonShape.Position = position;
            _buttonShape.Size = new Vector2f(_buttonShape.Texture.Size.X, _buttonShape.Texture.Size.Y);
            _buttonShape.FillColor = _buttonColor;

            // Initialize text
            _firstLetter = new Text(text.Substring(0, 1), _font, 72);
            _firstLetter.Position = position + new Vector2f(30, 0);
            _firstLetter.Color = Color.White;
            _firstLetterShadow = new Text(_firstLetter.DisplayedString, _font, 72);
            _firstLetterShadow.Position = _firstLetter.Position + new Vector2f(3, 3);
            _firstLetterShadow.Color = Color.Black;
            _word = new Text(text.Substring(1, text.Length - 1), _font, 48);
            _word.Position = _firstLetter.Position + new Vector2f(_firstLetter.GetLocalBounds().Width + 4, 13);
            _word.Color = Color.White;
            _wordShadow = new Text(_word.DisplayedString, _font, 48);
            _wordShadow.Position = _word.Position + new Vector2f(3, 3);
            _wordShadow.Color = Color.Black;
        }
开发者ID:klutch,项目名称:Loderpit,代码行数:35,代码来源:BigLabeledButtonComponent.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Graphics.Vector2类代码示例发布时间:2022-05-26
下一篇:
C# Graphics.Text类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap