本文整理汇总了C#中SFML.Graphics.Texture类的典型用法代码示例。如果您正苦于以下问题:C# Texture类的具体用法?C# Texture怎么用?C# Texture使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Texture类属于SFML.Graphics命名空间,在下文中一共展示了Texture类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
示例2: Sprite
public Sprite(string name, int type)
{
_path = name;
_type = type;
_texture = new Texture(name);
_loaded = (_texture == null) ? false : true;
}
示例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;
}
示例4: SetImage
public void SetImage(string _source, int _imageWidth, int _imageHeight)
{
source = _source;
imageWidth = _imageWidth;
imageHeight = _imageHeight;
image = new Texture("./assets/" + source);
}
示例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);
}
示例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);
}
示例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);
}
}
}
示例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);
}
}
示例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);
}
示例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;
}
示例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;
}
示例12: GResource
public GResource(string path, int type)
{
_path = path;
_loaded = false;
_myTexture = null;
_type = type;
}
示例13: HWSurfaceInstance
static HWSurfaceInstance()
{
_atlas = new RenderTexture(_aw, _ah);
_atlastex = _atlas.Texture;
_batch = new SpriteBatch(_atlas);
_batch.SetBlendMode(BlendMode.None);
}
示例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;
}
}
示例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;
}