本文整理汇总了C#中SFML.Graphics.Text.Center方法的典型用法代码示例。如果您正苦于以下问题:C# Text.Center方法的具体用法?C# Text.Center怎么用?C# Text.Center使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SFML.Graphics.Text
的用法示例。
在下文中一共展示了Text.Center方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
示例2: Draw
public override void Draw(RenderTarget rt)
{
Text title = new Text("Oh no! Something went wrong!", 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 blackCardText = new Text(value, Assets.LoadFont(Program.DefaultFont))
{
Position = new Vector2f(GameOptions.Width / 2.0f, GameOptions.Height / 2.0f),
CharacterSize = 36,
Color = Color.White
};
blackCardText.Center();
blackCardText.Round();
rt.Draw(blackCardText);
base.Draw(rt);
}
示例3: 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);
}
示例4: 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("Host Settings", Assets.LoadFont(Program.DefaultFont))
{
Position = new Vector2f(GameOptions.Width / 2.0f, GameOptions.Height * (PaddingVertical * 3.0f)),
Color = Color.Black,
CharacterSize = 48
};
labelSettings.Center();
labelSettings.Round();
rt.Draw(labelSettings);
// boundingY + 64.0f + 80.0f
Text labelDecks = new Text("Decks", Assets.LoadFont(Program.DefaultFont))
{
Position = new Vector2f(GameOptions.Width / 2.0f, GameOptions.Height * (PaddingVertical * 3.0f) + 64.0f + 80.0f + 40.0f),
Color = Color.Black,
CharacterSize = 36
};
labelDecks.Center();
labelDecks.Round();
rt.Draw(labelDecks);
Text portLabel = new Text("Hosts should forward port 1890 to allow players to connect over the internet.", Assets.LoadFont(Program.DefaultFont))
{
Position = new Vector2f(GameOptions.Width / 2.0f,
GameOptions.Height * (1.0f - PaddingVertical * 2.0f) + GameOptions.Height * PaddingVertical - 20.0f),
CharacterSize = 16,
Color = Color.Black
};
portLabel.Center();
portLabel.Round();
rt.Draw(portLabel);
base.Draw(rt);
}
示例5: Draw
public override void Draw(RenderTarget rt)
{
base.Draw(rt);
var textBackSize = new Vector2f(150, 54);
var textBack = new RectangleShape(textBackSize);
textBack.FillColor = new Color(0, 0, 0, 150);
textBack.Origin = textBackSize / 2;
textBack.Position = rt.GetView().Center;
var text = new Text("PAUSED", Assets.LoadFont("OpenSans-Regular.ttf"), 32);
text.Color = Color.White;
text.Position = rt.GetView().Center;
text.Center();
rt.Draw(textBack);
rt.Draw(text);
}
示例6: Draw
public override void Draw(RenderTarget rt)
{
RectangleShape bgColor = new RectangleShape(new Vector2f(GameOptions.Width, GameOptions.Height))
{ FillColor = new Color(0, 0, 0, 128) };
rt.Draw(bgColor);
Text title = new Text(winnerName + " won!", Assets.LoadFont(Program.DefaultFont))
{
Position = new Vector2f(GameOptions.Width / 2.0f, 48.0f),
CharacterSize = 48,
Color = Color.White
};
title.Center();
title.Round();
title.Position += new Vector2f(1, 1);
title.Color = Color.Black;
rt.Draw(title);
title.Position -= new Vector2f(1, 1);
title.Color = Color.White;
rt.Draw(title);
Text blackCardText = GameUtility.Wrap(winnerCombo, Assets.LoadFont(Program.DefaultFont), 36, GameOptions.Width * 0.6f);
blackCardText.Position = new Vector2f(GameOptions.Width / 2.0f, GameOptions.Height / 2.0f - 128.0f);
blackCardText.CharacterSize = 36;
blackCardText.Color = Color.White;
blackCardText.Center();
blackCardText.Origin = new Vector2f(blackCardText.Origin.X, 0.0f);
blackCardText.Round();
blackCardText.Position += new Vector2f(1, 1);
blackCardText.Color = Color.Black;
rt.Draw(blackCardText);
blackCardText.Position -= new Vector2f(1, 1);
blackCardText.Color = Color.White;
rt.Draw(blackCardText);
base.Draw(rt);
}
示例7: Draw
public override void Draw(RenderTarget rt)
{
RectangleShape bgOverlay = new RectangleShape(new Vector2f(GameOptions.Width, GameOptions.Height))
{ FillColor = new Color(0, 0, 0, 128) };
rt.Draw(bgOverlay);
Text title = new Text(isCzar ? "Select a Champion" : "Cards on the Table", Assets.LoadFont(Program.DefaultFont))
{
Position = new Vector2f(GameOptions.Width / 2.0f, 48.0f),
CharacterSize = 48,
Color = Color.White
};
title.Center();
title.Round();
title.Position += new Vector2f(1, 1);
title.Color = Color.Black;
rt.Draw(title);
title.Position -= new Vector2f(1, 1);
title.Color = Color.White;
rt.Draw(title);
Text blackCardText = GameUtility.Wrap(Client.CurrentBlackCard.Info.Value, Assets.LoadFont(Program.DefaultFont), 24, GameOptions.Width / 2.0f);
blackCardText.Position = new Vector2f(GameOptions.Width / 2.0f, 48.0f + 16.0f);
blackCardText.CharacterSize = 24;
blackCardText.Color = Color.White;
blackCardText.Center();
blackCardText.Origin = new Vector2f(blackCardText.Origin.X, 0.0f);
blackCardText.Round();
blackCardText.Position += new Vector2f(1, 1);
blackCardText.Color = Color.Black;
rt.Draw(blackCardText);
blackCardText.Position -= new Vector2f(1, 1);
blackCardText.Color = Color.White;
rt.Draw(blackCardText);
base.Draw(rt);
}
示例8: Draw
public override void Draw(RenderTarget rt)
{
// Outline
rt.Draw(new RectangleShape(new Vector2f(GameOptions.Width - 16, GameOptions.Height - 16))
{
Position = new Vector2f(8, 8),
OutlineColor = Color.Black,
FillColor = Color.White,
OutlineThickness = 8
});
// White card table
rt.Draw(new RectangleShape(new Vector2f(1264.0f, 202.0f))
{
Position = new Vector2f(8.0f, GameOptions.Height - 194.0f - 16.0f),
FillColor = Color.Black
});
// Timer table
rt.Draw(new RectangleShape(new Vector2f(256.0f, 63.0f))
{
Position = new Vector2f(GameOptions.Width - 256.0f - 8.0f, 8.0f),
FillColor = Color.Black
});
// Table border
rt.Draw(new RectangleShape(new Vector2f(8.0f, 502.0f))
{
Position = new Vector2f(GameOptions.Width - 256.0f - 8.0f, 8.0f),
FillColor = Color.Black
});
// Timer text
string timerValue = String.Format("{0}:{1}", (Client.SecondsLeft / 60).ToString("D"),
(Client.SecondsLeft % 60).ToString("D").PadLeft(2, '0'));
Text text = new Text(timerValue, Assets.LoadFont("QuartzMS.ttf"))
{
Position = new Vector2f(GameOptions.Width - 128.0f - 8.0f, 40.0f),
CharacterSize = 48
};
text.Center();
text.Round();
text.Color = Color.White;
rt.Draw(text);
// Draw decks
rt.Draw(new Sprite(Assets.LoadTexture("Decks.png"))
{
Position = new Vector2f(GameOptions.Width / 2.0f - 31.0f - 128.0f - 70.0f, GameOptions.Height / 2.0f - 44.0f - 89.0f - 22.0f)
});
// Draw chat backlog
float y = 0.0f;
for (int i = ChatBacklog.Count - 1; i > ChatBacklog.Count - ChatBacklogItems && i != -1; --i)
{
Text itemText = new Text(ChatBacklog[i], Assets.LoadFont(Program.DefaultFont))
{
Position = new Vector2f(16, GameOptions.Height - 226.0f - 24.0f - 24.0f + y),
CharacterSize = 22,
Color = Color.Black
};
y -= 24.0f;
rt.Draw(itemText);
}
Text chatMessageText = new Text(chatValue + "|", Assets.LoadFont(Program.DefaultFont))
{
Position = new Vector2f(8.0f + 6.0f, GameOptions.Height - 220.0f - 24.0f),
Color = Color.Black,
CharacterSize = 22
};
rt.Draw(chatMessageText);
base.Draw(rt);
}
示例9: Draw
public override void Draw(RenderTarget rt)
{
RectangleShape checkbox = new RectangleShape(Size)
{
Position = Position,
FillColor = Color.Black,
};
rt.Draw(checkbox);
if (mouseIn)
{
RectangleShape checkboxHover = new RectangleShape(new Vector2f(48.0f - 8.0f, 48.0f - 8.0f))
{
Position = Position + new Vector2f(4f, 4f),
FillColor = Color.Black,
OutlineColor = Color.White,
OutlineThickness = 2f
};
rt.Draw(checkboxHover);
}
Text labelText = new Text(Label, Assets.LoadFont(Program.DefaultFont))
{
Position = Position + new Vector2f(48.0f + 16.0f, 24.0f + 2.0f),
CharacterSize = 32,
Color = Color.Black
};
labelText.Center(false);
labelText.Round();
rt.Draw(labelText);
if (Value)
{
RectangleShape x1 = new RectangleShape(new Vector2f(48.0f, 3.0f))
{
Position = Position + new Vector2f(24.0f, 24.0f),
Origin = new Vector2f(24.0f, 2.0f),
FillColor = Color.White,
Rotation = -45.0f
};
rt.Draw(x1);
RectangleShape x2 = new RectangleShape(new Vector2f(48.0f, 3.0f))
{
Position = Position + new Vector2f(24.0f, 24.0f),
Origin = new Vector2f(24.0f, 2.0f),
FillColor = Color.White,
Rotation = 45.0f
};
rt.Draw(x2);
/*RectangleShape legLine = new RectangleShape(new Vector2f(2.0f, 38.0f));
legLine.Position = Position + new Vector2f(39.0f, 7.0f);
legLine.FillColor = Color.White;
legLine.Rotation = 35.0f;
rt.Draw(legLine);
RectangleShape footLine = new RectangleShape(new Vector2f(2.0f, 14.0f));
footLine.Position = Position + new Vector2f(8.0f, 30.0f);
footLine.FillColor = Color.White;
footLine.Rotation = -45.0f;
rt.Draw(footLine);*/
/*Text check = new Text("X", Assets.LoadFont(Program.DefaultFont))
{
Position = Position + Size / 2.0f,
CharacterSize = 48,
Color = Color.White
};
check.Center();
check.Round();
rt.Draw(check);*/
}
base.Draw(rt);
}
示例10: Draw
public override void Draw(RenderTarget rt)
{
// Display connecting message if needed
if (!Client.Connected)
{
RectangleShape bgShape = new RectangleShape(new Vector2f(GameOptions.Width, GameOptions.Height)) { FillColor = Color.Black };
rt.Draw(bgShape);
Text waitingText = new Text("Connecting", Assets.LoadFont(Program.DefaultFont))
{
Position = new Vector2f(GameOptions.Width / 2.0f, GameOptions.Height / 2.0f),
CharacterSize = 48,
Color = Color.White
};
waitingText.Center();
waitingText.Round();
rt.Draw(waitingText);
return;
}
// Draw lobby text
Text lobbyText = new Text("Lobby", Assets.LoadFont(Program.DefaultFont))
{
Position = new Vector2f(GameOptions.Width / 2.0f, 48.0f),
CharacterSize = 48,
Color = Color.Black
};
lobbyText.Center();
lobbyText.Round();
rt.Draw(lobbyText);
// Draw chat area
RectangleShape chatArea = new RectangleShape(
new Vector2f((GameOptions.Width / 3.0f) * 2.0f - 64.0f, (GameOptions.Height / 3.0f) * 2.0f + 64.0f))
{
Position = new Vector2f(GameOptions.Width / 3.0f, GameOptions.Height / 3.0f - 128.0f),
FillColor = new Color(96, 96, 96, 255)
};
rt.Draw(chatArea);
RectangleShape chatBarArea = new RectangleShape(new Vector2f((GameOptions.Width / 3.0f) * 2.0f - 64.0f, 48.0f))
{
Position = new Vector2f(GameOptions.Width / 3.0f, GameOptions.Height - 64.0f - 48.0f),
FillColor = Color.Black
};
rt.Draw(chatBarArea);
Text messageText = new Text(chatValue + "|", Assets.LoadFont(Program.DefaultFont))
{
Position =
new Vector2f(GameOptions.Width / 3.0f + 8.0f, GameOptions.Height - 64.0f - 48.0f + 8.0f + 4.0f),
CharacterSize = 22,
Color = Color.White
};
rt.Draw(messageText);
// Draw chat backlog
float y = 0.0f;
for (int i = ChatBacklog.Count - 1; i > ChatBacklog.Count - ChatBacklogItems && i != -1; --i)
{
Text itemText = new Text(ChatBacklog[i], Assets.LoadFont(Program.DefaultFont))
{
Position = new Vector2f((float)Math.Floor(GameOptions.Width / 3.0f + 8.0f), GameOptions.Height - 144.0f + y),
CharacterSize = 22,
Color = Color.White
};
y -= 24.0f;
rt.Draw(itemText);
}
base.Draw(rt);
}
示例11: Draw
public override void Draw(RenderTarget rt)
{
RectangleShape button = new RectangleShape(new Vector2f(ButtonWidth, ButtonHeight))
{
Position = Position,
FillColor = Color.Black
};
rt.Draw(button);
// Hover
if (mouseIn)
{
RectangleShape buttonHover = new RectangleShape(new Vector2f(ButtonWidth - 8, ButtonHeight - 8))
{
Position = Position + new Vector2f(4f, 4f),
FillColor = Color.Black,
OutlineColor = Color.White,
OutlineThickness = 2f
};
rt.Draw(buttonHover);
}
Text text = new Text(value, Assets.LoadFont(Program.DefaultFont))
{
Position = Position + Size / 2.0f,
CharacterSize = 18
};
text.Center();
text.Round();
rt.Draw(text);
base.Draw(rt);
}
示例12: Draw
public override void Draw(RenderTarget rt)
{
RectangleShape checkbox = new RectangleShape(Size)
{
Position = Position,
FillColor = Color.Black,
};
rt.Draw(checkbox);
if (mouseIn)
{
RectangleShape checkboxHover = new RectangleShape(new Vector2f(48.0f - 8.0f, 48.0f - 8.0f))
{
Position = Position + new Vector2f(4.0f, 4.0f),
FillColor = Color.Black,
OutlineColor = Color.White,
OutlineThickness = 2f
};
rt.Draw(checkboxHover);
}
Text labelText = new Text(Label, Assets.LoadFont(Program.DefaultFont))
{
Position = Position + new Vector2f(48.0f + 16.0f, 24.0f + 2.0f),
CharacterSize = 32,
Color = Color.Black
};
labelText.Center(false);
labelText.Round();
rt.Draw(labelText);
if (Value)
{
RectangleShape x1 = new RectangleShape(new Vector2f(48.0f, 3.0f))
{
Position = Position + new Vector2f(24.0f, 24.0f),
Origin = new Vector2f(24.0f, 2.0f),
FillColor = Color.White,
Rotation = -45.0f
};
rt.Draw(x1);
RectangleShape x2 = new RectangleShape(new Vector2f(48.0f, 3.0f))
{
Position = Position + new Vector2f(24.0f, 24.0f),
Origin = new Vector2f(24.0f, 2.0f),
FillColor = Color.White,
Rotation = 45.0f
};
rt.Draw(x2);
}
base.Draw(rt);
}
示例13: 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("Server List", Assets.LoadFont(Program.DefaultFont))
{
Position = new Vector2f(GameOptions.Width / 2.0f, GameOptions.Height * (PaddingVertical * 3.0f)),
Color = Color.Black,
CharacterSize = 48
};
labelSettings.Center();
labelSettings.Round();
rt.Draw(labelSettings);
if (servers.Count == 0)
{
Text serverLabel = new Text(refreshing ? "Refreshing!" : "No servers found!", Assets.LoadFont(Program.DefaultFont), 36)
{
Position = new Vector2f(GameOptions.Width / 2.0f, GameOptions.Height / 2.0f),
Color = Color.Black
};
serverLabel.Center();
serverLabel.Round();
rt.Draw(serverLabel);
}
else
{
float boundingY = GameOptions.Height * (PaddingVertical * 3.0f) + 64.0f;
float boundingX = GameOptions.Width * (PaddingHorizontal * 2.5f);
float yy = 0.0f;
bool lightGray = true;
for (int i = listOffset; i < listOffset + 6; ++i)
{
// Draw backing
RectangleShape backing = new RectangleShape(new Vector2f(GameOptions.Width - boundingX * 2.0f, 64.0f))
{
Position = new Vector2f(boundingX, boundingY + (i - listOffset) * 64.0f),
FillColor = lightGray ? new Color(192, 192, 192) : new Color(128, 128, 128)
};
if (i == selectedIndex)
backing.FillColor = new Color(100, 149, 237);
rt.Draw(backing);
lightGray = !lightGray;
// Draw server name
if (i >= servers.Count)
continue;
Server server = servers[i];
Text serverLabel = new Text(server.Name, Assets.LoadFont(Program.DefaultFont), 36)
{
Position = new Vector2f(boundingX + 12.0f, boundingY + yy + 32.0f),
Color = Color.White
};
serverLabel.Center(false);
serverLabel.Round();
rt.Draw(serverLabel);
// Draw player count
Sprite playerAvatar = new Sprite(Assets.LoadTexture("Avatar.png"))
{
Position = new Vector2f(boundingX + GameOptions.Width - boundingX * 2.0f - 128.0f, boundingY + yy + 32.0f),
Scale = new Vector2f(0.5f, 0.5f)
};
playerAvatar.Origin = new Vector2f(playerAvatar.TextureRect.Width / 2.0f, playerAvatar.TextureRect.Height / 2.0f);
rt.Draw(playerAvatar);
Text playerCountLabel = new Text(server.PlayerCount.ToString("G") + "/" + Constants.MaxPlayerCount.ToString("G"), Assets.LoadFont(Program.DefaultFont), 36)
{
Position = new Vector2f(boundingX + GameOptions.Width - boundingX * 2.0f - 128.0f + 32.0f, boundingY + yy + 32.0f),
Color = Color.White
};
playerCountLabel.Center(false);
//.........这里部分代码省略.........
示例14: Draw
public override void Draw(RenderTarget rt)
{
RectangleShape numberbox = new RectangleShape(Size)
{
Position = Position,
FillColor = Color.Black,
};
rt.Draw(numberbox);
if (mouseIn)
{
RectangleShape checkboxHover = new RectangleShape(new Vector2f(64.0f - 8.0f, 48.0f - 8.0f))
{
Position = Position + new Vector2f(4f, 4f),
FillColor = Color.Black,
OutlineColor = Color.White,
OutlineThickness = 2f
};
rt.Draw(checkboxHover);
}
Text valueText = new Text(stringValue, Assets.LoadFont(Program.DefaultFont))
{
Position = Position + new Vector2f(8.0f, 8.0f),
CharacterSize = 28,
Color = Color.White
};
valueText.Round();
rt.Draw(valueText);
if (Selected && cursorVisible)
{
RectangleShape cursor = new RectangleShape(new Vector2f(2.0f, Size.Y - 16.0f))
{
Position = Position + new Vector2f(valueText.GetWidth() + 8.0f + 2.0f, 8.0f),
FillColor = Color.White
};
cursor.Round();
rt.Draw(cursor);
}
Text labelText = new Text(label, Assets.LoadFont(Program.DefaultFont))
{
Position = Position + new Vector2f(64.0f + 16.0f, 24.0f + 2.0f),
CharacterSize = 32,
Color = Color.Black
};
labelText.Center(false);
labelText.Round();
rt.Draw(labelText);
}