本文整理汇总了C#中SFML.Graphics.Text类的典型用法代码示例。如果您正苦于以下问题:C# Text类的具体用法?C# Text怎么用?C# Text使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Text类属于SFML.Graphics命名空间,在下文中一共展示了Text类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Draw
public void Draw()
{
Text t = new Text();
t.Font = Program.Data.Font;
t.CharacterSize = 14;
SFML.Graphics.Sprite s = new SFML.Graphics.Sprite(Program.Data.SpriteBasedOnType(SpriteType.Button)[ID]);
s.Position = new Vector2f(X, Y);
_screen.Draw(s);
ConstructionGUI g = (ConstructionGUI)Program.SM.States[1].GameGUI[9];
if (Logic.CurrentParty.MainParty.MyParty[0].CurMap.SpawnedSpawnableLocation[g.LocY][g.LocX] > -1)
{
SpawnBuildable b = (SpawnBuildable)Logic.CurrentParty.MainParty.MyParty[0].CurMap.SpawnedSpawnable[Logic.CurrentParty.MainParty.MyParty[0].CurMap.SpawnedSpawnableLocation[g.LocY][g.LocX]];
if (SlotID + 3 * g.CurPage < b.Required.Count)//SlotID + 3 * g.CurPage < Program.Data.MySpawnable[Logic.CurrentParty.MainParty.MyParty[0].CurMap.SpawnedSpawnable[Logic.CurrentParty.MainParty.MyParty[0].CurMap.SpawnedSpawnableLocation[g.LocY][g.LocX]].ID].)
{
s = new SFML.Graphics.Sprite(Program.Data.SpriteBasedOnType(SpriteType.Items)[Program.Data.MyItems[b.Required.ElementAt(SlotID + 3 * g.CurPage).Key.ID].Sprite]);
s.Position = new Vector2f(X, Y);
_screen.Draw(s);
t.DisplayedString = Program.Data.MyItems[b.Required.ElementAt(SlotID + 3 * g.CurPage).Key.ID].Name + ": " + (Program.Data.GetBuildableList()[b.ID].RequiredItems.ElementAt(SlotID + 3 * g.CurPage).Value - b.Required.ElementAt(SlotID + 3 * g.CurPage).Value.Count - b.Built.ElementAt(SlotID + 3 * g.CurPage).Value.Count) + "/" + b.Required.ElementAt(SlotID + 3 * g.CurPage).Value.Count + "/" + b.Built.ElementAt(SlotID + 3 * g.CurPage).Value.Count;
t.Position = new Vector2f(X + 38, Y + 8);
_screen.Draw(t);
if (State == 1)
{
b.Required.ElementAt(SlotID + 3 * g.CurPage).Key.DrawSprite(_screen, Mouse.GetPosition(_screen).X - (int)Program.Data.SpriteBasedOnType(SpriteType.Items)[Program.Data.MyItems[b.Required.ElementAt(SlotID + 3 * g.CurPage).Key.ID].Sprite].Size.X / 2, Mouse.GetPosition(_screen).Y - (int)Program.Data.SpriteBasedOnType(SpriteType.Items)[Program.Data.MyItems[b.Required.ElementAt(SlotID + 3 * g.CurPage).Key.ID].Sprite].Size.Y / 2);
}
}
}
}
示例2: MapRenderer
public MapRenderer(IntPtr mapRenderWindowHandle, IntPtr tileSetRenderHandle, MapEditor.MapEditorProperties mapEditorProperties)
{
_mapRenderWindow = new RenderWindow(mapRenderWindowHandle);
_tileSetRenderWindow = new RenderWindow(tileSetRenderHandle);
_mapRenderWindow.MouseButtonPressed += mapRenderWindow_MouseButtonPressed;
_mapRenderWindow.MouseMoved += mapRenderWindow_MouseMoved;
_tileSetRenderWindow.MouseButtonPressed += tileSetRenderWindow_MouseButtonPressed;
_tileSetRenderWindow.MouseMoved += tileSetRenderWindow_MouseMoved;
_tileSetRenderWindow.MouseButtonReleased += tileSetRenderWindow_MouseButtonReleased;
_mapEditorProperties = mapEditorProperties;
_mapEditorProperties.CurrentLayer = World.Map.Layers.Ground;
_mapEditorProperties.MapView = new View(this._mapRenderWindow.DefaultView);
_mousePositionText = new Text("", new Font(AppDomain.CurrentDomain.BaseDirectory + "/Data/Graphics/Fonts/MainFont.ttf"), 20);
this.LoadTileSets();
_tileSetView = this._tileSetRenderWindow.DefaultView;
this.Running = true;
this._mapRenderWindow.SetActive(false);
this._tileSetRenderWindow.SetActive(false);
new Thread(UpdateLoop).Start();
}
示例3: Main
static void Main(string[] args)
{
// initialize window and view
win = new RenderWindow(new VideoMode(1000, 700), "Hadoken!!!");
view = new View();
resetView();
gui = new GUI(win, view);
// exit Program, when window is being closed
//win.Closed += new EventHandler(closeWindow);
win.Closed += (sender, e) => { (sender as Window).Close(); };
// initialize GameState
handleNewGameState();
// initialize GameTime
GameTime gameTime = new GameTime();
gameTime.Start();
// debug Text
Text debugText = new Text("debug Text", new Font("Fonts/calibri.ttf"));
while (running && win.IsOpen())
{
KeyboardInputManager.update();
currentGameState = state.update();
// gather draw-stuff
win.Clear(new Color(100, 149, 237)); //cornflowerblue ftw!!! 1337
state.draw(win, view);
state.drawGUI(gui);
// first the state must be drawn, before I can change the currentState
if (currentGameState != prevGameState)
{
handleNewGameState();
}
// do the actual drawing
win.SetView(view);
win.Display();
// check for window-events. e.g. window closed
win.DispatchEvents();
// update GameTime
gameTime.Update();
float deltaTime = (float)gameTime.EllapsedTime.TotalSeconds;
// idleLoop for fixed FrameRate
float deltaPlusIdleTime = deltaTime;
while (deltaPlusIdleTime < (1F / fixedFps))
{
gameTime.Update();
deltaPlusIdleTime += (float)gameTime.EllapsedTime.TotalSeconds;
}
Console.WriteLine("real fps: " + (int)(1F / deltaPlusIdleTime) + ", theo fps: " + (int)(1F / deltaTime));
}
}
示例4: Draw
public void Draw()
{
Text t = new Text();
t.Font = Program.Data.Font;
t.CharacterSize = 14;
SFML.Graphics.Sprite s = new SFML.Graphics.Sprite(Program.Data.SpriteBasedOnType(SpriteType.Button)[ID]);
s.Position = new Vector2f(X, Y);
_screen.Draw(s);
BuildGUI g = (BuildGUI)Program.State[1].GameGUI[8];
if (g.CurPick + 3 * g.PickPage < Logic.KnownBluePrintForThisCharacter(Program.Data.MyPlayerData[Program.CurrentSaveData].MainParty.MyParty[0], g.CurClass).Count)
{
if (SlotID + 3 * g.CurPage < Program.Data.GetBuildableList()[Logic.KnownBluePrintForThisCharacter(Program.Data.MyPlayerData[Program.CurrentSaveData].MainParty.MyParty[0], g.CurClass)[g.CurPick + 3 * g.PickPage]].RequiredItems.Count)
{
s = new SFML.Graphics.Sprite(Program.Data.SpriteBasedOnType(SpriteType.Items)[Program.Data.GetBuildableList()[Logic.KnownBluePrintForThisCharacter(Program.Data.MyPlayerData[Program.CurrentSaveData].MainParty.MyParty[0], g.CurClass)[g.CurPick + 3 * g.PickPage]].RequiredItems.ElementAt(SlotID + 3 * g.CurPage).Key.ID]);
s.Position = new Vector2f(X, Y);
_screen.Draw(s);
t.DisplayedString = Program.Data.MyItems[Program.Data.GetBuildableList()[Logic.KnownBluePrintForThisCharacter(Program.Data.MyPlayerData[Program.CurrentSaveData].MainParty.MyParty[0], g.CurClass)[g.CurPick + 3 * g.PickPage]].RequiredItems.ElementAt(SlotID + 3 * g.CurPage).Key.ID].Name + ": " + Program.Data.GetBuildableList()[Logic.KnownBluePrintForThisCharacter(Program.Data.MyPlayerData[Program.CurrentSaveData].MainParty.MyParty[0], g.CurClass)[g.CurPick + 3 * g.PickPage]].RequiredItems.ElementAt(SlotID + 3 * g.CurPage).Value;
t.Position = new Vector2f(X + 40, Y + 7);
_screen.Draw(t);
}
}
}
示例5: 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;
}
示例6: Counter
public Counter()
{
Text = new Text("", Game.Assets.Fonts["DejaVuSans"]);
Text.Color = TextColor;
Position = Game.Target.GetView().Size * 0.5f;
}
示例7: OnEngineInit
public override void OnEngineInit()
{
base.OnEngineInit();
this.fnt = new Font(Environment.GetFolderPath(Environment.SpecialFolder.Fonts) + Path.DirectorySeparatorChar + "georgia.ttf");
this.txt = new Text(string.Empty, fnt, 24);
}
示例8: Draw
public void Draw(RenderTarget rt)
{
DateTime now = DateTime.Now;
Text message = new Text("", myFont);
message.CharacterSize = 14;
int removeCount = 0;
foreach(KeyValuePair<DateTime, String> pair in msgList){
message.DisplayedString += pair.Value + "\n";
if((now - pair.Key).TotalSeconds > messageLifeTime)
removeCount++;
}
msgList.RemoveRange(0, removeCount);
message.Position = new Vector2f(14, rt.Height - 54 - message.GetRect().Height);
rt.Draw(message);
if(writing){
Text display = new Text("say : " + toWrite + "_", myFont);
display.CharacterSize = 14;
display.Position = new Vector2f(14, rt.Height - 36 - display.GetRect().Height);
rt.Draw(display);
}
}
示例9: MenuState
private int selected; //the menu option we have selected
public MenuState()
{
//initializing the menu object we have selected
//this is honesty unnecessary, but i like to make things explicit
selected = 0;
//our font object our text uses
//(note: use a different font, this one is pulled directly from the SFML.net examples)
font = new Font("sansation.ttf");
//the title of our menu
title = new Text("INVASION GRID", font);
title.Position = new Vector2f(50.0f, 10.0f);
title.CharacterSize = 40;
//setup for our options text
options = new Text[4];
options[0] = new Text("Easy Mode", font);
options[1] = new Text("HARDCORE MODE", font);
options[2] = new Text("High Scores", font);
options[3] = new Text("Quit", font);
for (int i = 0; i < 4; i++)
{
options[i].Position = new Vector2f(50.0f, 100.0f * (i + 1));
options[i].Color = Color.Red;
}
//setup for our pointer
pointer = new Text(">", font);
pointer.Position = new Vector2f(30.0f, 100.0f);
pointer.Color = Color.White;
}
示例10: Draw
public override void Draw(RenderTarget r)
{
var text = ((int)(1000/EntityManager.FrameTime)).ToString () + " FPS";
DebugText = new Text(text, DebugText.Font)
{Position = r.GetView ().Center - r.GetView ().Size/2, Color = DebugText.Color};
r.Draw (DebugText);
}
示例11: Draw
public override void Draw(RenderTarget rt)
{
RectangleShape bgOverlay = new RectangleShape(new Vector2f(GameOptions.Width, GameOptions.Height)) { FillColor = Color.Black };
rt.Draw(bgOverlay);
Text title = new Text("Game Over", Assets.LoadFont(Program.DefaultFont))
{
Position = new Vector2f(GameOptions.Width / 2.0f, 48.0f),
CharacterSize = 48,
Color = Color.White
};
title.Center();
title.Round();
rt.Draw(title);
Text winnerTitle = new Text(GetWinnerText(), Assets.LoadFont(Program.DefaultFont))
{
Position = new Vector2f(GameOptions.Width / 2.0f, GameOptions.Height / 2.0f),
CharacterSize = 48,
Color = Color.White
};
winnerTitle.Center();
winnerTitle.Round();
rt.Draw(winnerTitle);
base.Draw(rt);
}
示例12: Draw
public override void Draw(RenderTarget rt)
{
RectangleShape overylay = new RectangleShape(new Vector2f(GameOptions.Width, GameOptions.Height))
{
FillColor = new Color(0, 0, 0, 128)
};
rt.Draw(overylay);
RectangleShape window = new RectangleShape(new Vector2f(GameOptions.Width * (1.0f - PaddingHorizontal * 2.0f), GameOptions.Height * (1.0f - PaddingVertical * 2.0f)))
{
Position = new Vector2f(GameOptions.Width * PaddingHorizontal, GameOptions.Height * PaddingVertical),
FillColor = Color.White,
OutlineColor = Color.Black,
OutlineThickness = 2.0f
};
rt.Draw(window);
Text labelSettings = new Text("Join by IP", Assets.LoadFont(Program.DefaultFont))
{
Position = new Vector2f(GameOptions.Width / 2.0f, GameOptions.Height * PaddingVertical + 48.0f),
Color = Color.Black,
CharacterSize = 32
};
labelSettings.Center();
labelSettings.Round();
rt.Draw(labelSettings);
base.Draw(rt);
}
示例13: HeadsUpDisplay
public HeadsUpDisplay(Game Game)
: base(Game, null)
{
// Score
Score = new Text("00000000", Game.TidyHand, 50);
Score.Color = new Color(255, 255, 255, 180);
Score.Position = new Vector2f(Game.Size.X - 270, 2);
AddChild(Score);
ScoreMultiplier = new Text("x001", Game.TidyHand, 35);
ScoreMultiplier.Color = new Color(200, 200, 200, 180);
ScoreMultiplier.Position = new Vector2f(Game.Size.X - 100, 50);
AddChild(ScoreMultiplier);
// Powerups
Layer_Powerups = new Layer();
AddChild(Layer_Powerups);
// FPS
if (DisplayFPS)
{
FPS = new Text("00.0", Game.TidyHand, 30);
FPS.Position = new Vector2f(Game.Size.X - 70, Game.Size.Y - 40);
AddChild(FPS);
FPSUpdateTimer = new Timer(500); // Update every 0.5 seconds
FPSUpdateTimer.Elapsed += FPSUpdate;
FPSUpdateTimer.Start();
}
}
示例14: Init
public override void Init()
{
label = new Text(Text, Font);
label.Scale = new SFML.Window.Vector2f(Scale, Scale);
UpdateScale();
base.Init();
}
示例15: PauseState
public PauseState(StateStack stack, Context context)
: base(stack, context)
{
RenderWindow window = mContext.window;
mBackgroundSprite = new Sprite();
mPausedText = new Text();
mInstructionText = new Text();
mPausedText.Font = mContext.fonts.get(FontID.Main);
mPausedText.DisplayedString = "Game Paused";
mPausedText.CharacterSize = 70;
mPausedText.centerOrigin();
mPausedText.Position = new Vector2f(0, 0);
mInstructionText.Font = mContext.fonts.get(FontID.Main);
mInstructionText.DisplayedString = "(Press Backspace to return to main menu)";
mInstructionText.centerOrigin();
mInstructionText.Position = new Vector2f(0, 0);
backgroundShape = new RectangleShape();
backgroundShape.FillColor = new Color(0, 0, 0, 150);
backgroundShape.Position = window.GetView().Center;
backgroundShape.centerOrigin();
backgroundShape.Size = window.GetView().Size;
}