本文整理汇总了C#中Sprite.GetCenterPosition方法的典型用法代码示例。如果您正苦于以下问题:C# Sprite.GetCenterPosition方法的具体用法?C# Sprite.GetCenterPosition怎么用?C# Sprite.GetCenterPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sprite
的用法示例。
在下文中一共展示了Sprite.GetCenterPosition方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InitScreen
public override void InitScreen(ScreenType screenName)
{
StateManager.ScreenStateChanged += new EventHandler(StateManager_ScreenStateChanged);
StateManager.ScreenResolutionChanged += new EventHandler<ViewportEventArgs>(Options_ScreenResolutionChanged);
base.InitScreen(screenName);
BackgroundSprite = GameContent.Assets.Images.NonPlayingObjects.GlobalBackground;
title = new TextSprite(Sprites.SpriteBatch, GameContent.Assets.Fonts.BoldText, "You Won!", Color.White);
title.X = title.GetCenterPosition(Graphics.Viewport).X;
title.Y = 12.5f;
AdditionalSprites.Add(title);
planet = Sprites.AddNewSprite(new Vector2(-3, Graphics.Viewport.Height - GameContent.Assets.Images.NonPlayingObjects.Planet.Height + 11), GameContent.Assets.Images.NonPlayingObjects.Planet);
msg = new TextSprite(Sprites.SpriteBatch, GameContent.Assets.Fonts.NormalText, MessageText, Color.White);
msg.Y = title.Y + title.Font.LineSpacing;
AdditionalSprites.Add(msg);
netScreenButton = Sprites.AddNewSprite(Vector2.Zero, GameContent.Assets.Images.Controls.Button);
netScreenButton.Position = netScreenButton.GetCenterPosition(Graphics.Viewport);
netScreenLabel = StateManager.CreateButtonTextSprite(false, "Multiplayer", netScreenButton, this);
netScreenLabel.Pressed += StateManager.ButtonSFXHelper;
netScreenLabel.Pressed += new EventHandler(netScreenLabel_Pressed);
}
示例2: InitScreen
public override void InitScreen(ScreenType screenName)
{
base.InitScreen(screenName);
BackgroundSprite = HorizontalMenuBGSprite.CurrentBG;
title = new TextSprite(Sprites.SpriteBatch, GameContent.Assets.Fonts.BoldText, "Available " + (StateManager.NetworkData.SessionType == NetworkSessionType.SystemLink ? "LAN" : "LIVE") + " Sectors");
title.Color = Color.White;
title.Y = 5;
title.X = title.GetCenterPosition(Graphics.Viewport).X;
reloadButton = new Sprite(GameContent.Assets.Images.Controls.Button, new Vector2(0, title.Y + title.Font.LineSpacing + 10), Sprites.SpriteBatch);
reloadButton.X = reloadButton.GetCenterPosition(Graphics.Viewport).X;
reload = new TextSprite(Sprites.SpriteBatch, GameContent.Assets.Fonts.NormalText, "Refresh");
reload.ParentSprite = reloadButton;
reload.NonHoverColor = Color.White;
reload.HoverColor = Color.MediumAquamarine;
reload.IsHoverable = true;
reload.Pressed += new EventHandler(reload_Pressed);
BackButton = new Sprite(GameContent.Assets.Images.Controls.Button, new Vector2(20, Graphics.Viewport.Height), Sprites.SpriteBatch);
BackButton.Y -= BackButton.Height + 20;
BackLabel = new TextSprite(Sprites.SpriteBatch, GameContent.Assets.Fonts.NormalText, "Back", Color.White) { IsHoverable = true, HoverColor = Color.MediumAquamarine, NonHoverColor = Color.White };
BackLabel.ParentSprite = BackButton;
BackLabel.Pressed += new EventHandler(BackLabel_Pressed);
BackLabel.Visible = true;
Sprites.Add(BackButton);
AdditionalSprites.Add(title);
AdditionalSprites.Add(reload);
Sprites.Add(reloadButton);
#if XBOX
AllButtons = new GamePadButtonEnumerator(new TextSprite[,] { { reload }, { BackLabel } }, InputType.LeftJoystick);
AllButtons.FireTextSpritePressed = true;
#endif
}
示例3: InitScreen
public override void InitScreen(ScreenType screenType)
{
base.InitScreen(screenType);
#if WINDOWS
GameScreen.Paused += new EventHandler(GameScreen_Paused);
#endif
Texture2D button = GameContent.Assets.Images.Controls.Button;
StateManager.Options.ScreenResolutionChanged += new EventHandler<ViewportEventArgs>(Options_ScreenResolutionChanged);
PauseLabel = new TextSprite(Sprites.SpriteBatch, Vector2.Zero, GameContent.Assets.Fonts.BoldText, "Paused");
PauseLabel.Position = new Vector2(Sprites.SpriteBatch.GraphicsDevice.Viewport.Width / 2 - PauseLabel.Width / 2, Sprites.SpriteBatch.GraphicsDevice.Viewport.Height * .1f);
PauseLabel.Color = Color.White;
AdditionalSprites.Add(PauseLabel);
LevelLabel = new TextSprite(Sprites.SpriteBatch, Vector2.Zero, GameContent.Assets.Fonts.NormalText, "Points:" + StateManager.SpacePoints + "\nCurrent Level: Level " + StateManager.CurrentLevel.ToInt() + "\n" + StateManager.Lives + " extra lives remaining\nYou have " + StateManager.SpaceBucks + " credits");
LevelLabel.Position = new Vector2(Sprites.SpriteBatch.GraphicsDevice.Viewport.Width / 2 - LevelLabel.Width / 2, Sprites.SpriteBatch.GraphicsDevice.Viewport.Height * .50f);
LevelLabel.Color = Color.White;
AdditionalSprites.Add(LevelLabel);
ResumeButton = new Sprite(button, Vector2.Zero, Sprites.SpriteBatch);
ResumeButton.Position = new Vector2(ResumeButton.GetCenterPosition(Sprites.SpriteBatch.GraphicsDevice.Viewport).X, Sprites.SpriteBatch.GraphicsDevice.Viewport.Height * .2f);
Sprites.Add(ResumeButton);
ResumeLabel = new TextSprite(Sprites.SpriteBatch, Vector2.Zero, GameContent.Assets.Fonts.NormalText, "Resume");
ResumeLabel.ParentSprite = ResumeButton;
ResumeLabel.Color = Color.White;
#if WINDOWS
ResumeLabel.CallKeyboardClickEvent = false;
#endif
ResumeLabel.IsHoverable = true;
ResumeLabel.HoverColor = Color.MediumAquamarine;
ResumeLabel.NonHoverColor = Color.White;
AdditionalSprites.Add(ResumeLabel);
ExitButton = new Sprite(button, new Vector2(ResumeButton.X, Sprites.SpriteBatch.GraphicsDevice.Viewport.Height * .8f), Sprites.SpriteBatch);
Sprites.Add(ExitButton);
ExitLabel = new TextSprite(Sprites.SpriteBatch, Vector2.Zero, GameContent.Assets.Fonts.NormalText, "Exit");
ExitLabel.Color = Color.White;
ExitLabel.IsHoverable = true;
#if WINDOWS
ExitLabel.CallKeyboardClickEvent = false;
#endif
ExitLabel.ParentSprite = ExitButton;
ExitLabel.HoverColor = Color.MediumAquamarine;
ExitLabel.NonHoverColor = Color.White;
AdditionalSprites.Add(ExitLabel);
OptionButton = new Sprite(button, Vector2.Zero, Sprites.SpriteBatch);
OptionButton.Position = new Vector2(ResumeButton.X, Sprites.SpriteBatch.GraphicsDevice.Viewport.Height * .37f);
Sprites.Add(OptionButton);
OptionsLabel = new TextSprite(Sprites.SpriteBatch, Vector2.Zero, GameContent.Assets.Fonts.NormalText, "Options");
OptionsLabel.ParentSprite = OptionButton;
OptionsLabel.Color = Color.White;
OptionsLabel.IsHoverable = true;
#if WINDOWS
OptionsLabel.CallKeyboardClickEvent = false;
#endif
OptionsLabel.HoverColor = Color.MediumAquamarine;
OptionsLabel.NonHoverColor = Color.White;
AdditionalSprites.Add(OptionsLabel);
#if XBOX
AllButtons = new GamePadButtonEnumerator(new TextSprite[,]
{
{ResumeLabel},
{OptionsLabel},
{ExitLabel}
}, InputType.LeftJoystick);
AllButtons.FireTextSpritePressed = true;
#endif
ResumeLabel.Pressed += new EventHandler(ResumeLabel_Pressed);
ExitLabel.Pressed += new EventHandler(ExitLabel_Pressed);
OptionsLabel.Pressed += new EventHandler(OptionsLabel_Pressed);
}
示例4: InitScreen
public override void InitScreen(ScreenType screenType)
{
base.InitScreen(screenType);
BackgroundSprite = new Sprite(GameContent.Assets.Images.Backgrounds.Screens[ScreenBackgrounds.Credits], Vector2.Zero, Sprites.SpriteBatch);
SpriteFont SegoeUIMono = GameContent.Assets.Fonts.NormalText;
_scrollingSpeed = new Vector2(0, -1);
Texture2D logo = GameContent.Assets.Images.Controls.Title;
gameTitle = new Sprite(logo, new Vector2(0, Sprites.SpriteBatch.GraphicsDevice.Viewport.Height), Sprites.SpriteBatch);
gameTitle.X = gameTitle.GetCenterPosition(Sprites.SpriteBatch.GraphicsDevice.Viewport).X;
//credits = new TextSprite(Sprites.SpriteBatch, , "\n\n\n\nWeek 1 - Functional Spec, GameState Management\n
//Week 3 - AI's\n\n\n\n\n\n\n\n\n\n\n\nWeek 4 - Xbox Converson\n\n\n\n\nUnderlying Library written by:\nGlen Husman (glen3b)\nGlib is available on github! \n\n\n\n\n\n\n Music:\n\nFailing Defense - Kevin MacLeod\n\nAll music obtained from Incompetech.com", Color.White);
//credits = new TextSprite(Sprites.SpriteBatch, GameContent.GameAssets.Fonts.NormalText, " Plequarius: Galactic Commanders\n\n\n\n\n\nAll Developement:\nGlen Husman\n\nMinor Assistance:\nAbe", Color.White);
//credits.Position = new Vector2(credits.GetCenterPosition(Sprites.SpriteBatch.GraphicsDevice.Viewport).X, Sprites.SpriteBatch.GraphicsDevice.Viewport.Height+imgSprite.Height);
int lastWeekID = 0;
foreach (KeyValuePair<XmlCredits.Week, XmlCredits.Student> weekStudent in _xmlCredits.Students)
{
int weekID = weekStudent.Key.ID;
if (lastWeekID != weekID)
{
StringBuilder title = new StringBuilder();
title.AppendFormat("\n\n\n\nWeek {0} - ", weekID);
for (int topicCounter = 0; topicCounter < weekStudent.Key.Topics.Count; topicCounter++)
{
KeyValuePair<int, string> topic = weekStudent.Key.Topics[topicCounter];
title.AppendFormat("{0}{1}", topic.Value, topicCounter == weekStudent.Key.Topics.Count - 1 ? "\n" : ", ");
}
TextSprite credit = new TextSprite(Sprites.SpriteBatch, _boldCreditsFont, title.ToString());
credit.X = credit.GetCenterPosition(Sprites.SpriteBatch.GraphicsDevice.Viewport).X;
credit.Color = Color.White;
if (credits.Count == 0)
{
credit.Y = gameTitle.Y + gameTitle.Height;
}
else
{
credit.Y = credits[credits.Count - 1].Y + credits[credits.Count - 1].Height + (_creditsFont.LineSpacing - _creditsFont.MeasureString("A").Y);
}
credits.Add(credit);
lastWeekID = weekID;
}
TextSprite student = new TextSprite(Sprites.SpriteBatch, _creditsFont, String.Format("{0} {1}\n", weekStudent.Value.FirstName, weekStudent.Value.LastName));
student.X = student.GetCenterPosition(Sprites.SpriteBatch.GraphicsDevice.Viewport).X;
student.Color = Color.White;
student.Y = credits[credits.Count - 1].Y + credits[credits.Count - 1].Height + (_creditsFont.LineSpacing - _creditsFont.MeasureString("A").Y);
credits.Add(student);
}
TextSprite helperLabel = new TextSprite(Sprites.SpriteBatch, _boldCreditsFont, "\n\n\n\nHelpers\n", Color.White);
helperLabel.X = helperLabel.GetCenterPosition(Sprites.SpriteBatch.GraphicsDevice.Viewport).X;
helperLabel.Y = credits[credits.Count - 1].Y + credits[credits.Count - 1].Height + (_creditsFont.LineSpacing - _creditsFont.MeasureString("A").Y);
credits.Add(helperLabel);
foreach (PGCGame.Xml.XmlTypes.XmlCredits.Helper assistant in _xmlCredits.AllHelpers)
{
float targetY = credits[credits.Count - 1].Y + credits[credits.Count - 1].Height + (_creditsFont.LineSpacing - _creditsFont.MeasureString("A").Y);
TextSprite name = new TextSprite(Sprites.SpriteBatch, new Vector2(0, targetY), _boldCreditsFont, assistant.FullName, Color.White);
TextSprite job = new TextSprite(Sprites.SpriteBatch, new Vector2(0, targetY+name.Font.LineSpacing), _creditsFont, assistant.Job+"\n", Color.White);
name.X = name.GetCenterPosition(Graphics.Viewport).X;
job.X = job.GetCenterPosition(Graphics.Viewport).X;
credits.Add(name);
credits.Add(job);
}
//The IEnumerable cast method
AdditionalSprites.AddRange(credits.Cast<IDrawableComponent>());
Sprites.Add(gameTitle);
_elapsedTime = TimeSpan.Zero;
}
示例5: InitScreen
public override void InitScreen(ScreenType screenName)
{
Sprites.Clear();
AdditionalSprites.Clear();
_firstInit = true;
gamerInfos = null;
GamerInfos.Clear();
SelectedShips.Clear();
base.InitScreen(screenName);
BackgroundSprite = HorizontalMenuBGSprite.CurrentBG;
title = new TextSprite(Sprites.SpriteBatch, GameContent.Assets.Fonts.BoldText, StateManager.NetworkData.SessionMode.ToFriendlyString() + " Lobby", Color.White);
title.Y = 5;
title.X = title.GetCenterPosition(Graphics.Viewport).X;
AdditionalSprites.Add(title);
StartButton = new Sprite(GameContent.Assets.Images.Controls.Button, new Vector2(0, Graphics.Viewport.Height), Sprites.SpriteBatch);
StartButton.X = StartButton.GetCenterPosition(Graphics.Viewport).X;
StartButton.Y -= StartButton.Height + 20;
StartLabel = new TextSprite(Sprites.SpriteBatch, GameContent.Assets.Fonts.NormalText, "Start", Color.White) { ParentSprite = StartButton, IsHoverable = true, HoverColor = Color.MediumAquamarine, NonHoverColor = Color.White };
StartLabel.Pressed += new EventHandler(StartLabel_Pressed);
StartButton.Visible = false;
StartLabel.Visible = false;
Sprites.Add(StartButton);
AdditionalSprites.Add(StartLabel);
#if XBOX
AllButtons = new GamePadButtonEnumerator(new TextSprite[,] { { StartLabel } }, InputType.LeftJoystick);
AllButtons.FireTextSpritePressed = true;
#endif
}
示例6: InitScreen
public override void InitScreen(ScreenType screenName)
{
base.InitScreen(screenName);
BackgroundSprite = HorizontalMenuBGSprite.CurrentBG;
TitleLabel = new TextSprite(Sprites.SpriteBatch, new Vector2(0, 5), GameContent.Assets.Fonts.BoldText, "Select Match Type", Color.White);
TitleLabel.X = TitleLabel.GetCenterPosition(Graphics.Viewport).X;
AdditionalSprites.Add(TitleLabel);
CoopButton = new Sprite(GameContent.Assets.Images.Controls.Button, new Vector2(0, 10 + TitleLabel.Height), Sprites.SpriteBatch);
CoopButton.X = CoopButton.GetCenterPosition(Graphics.Viewport).X;
CoopLabel = new TextSprite(Sprites.SpriteBatch, GameContent.Assets.Fonts.NormalText, "Co-op", Color.White);
CoopLabel.HoverColor = Color.MediumAquamarine;
CoopLabel.NonHoverColor = Color.White;
CoopLabel.IsHoverable = true;
CoopLabel.ParentSprite = CoopButton;
CoopLabel.Pressed += StateManager.ButtonSFXHelper;
CoopLabel.Pressed += new EventHandler(CoopLabel_Pressed);
Sprites.Add(CoopButton);
AdditionalSprites.Add(CoopLabel);
LMS = new Sprite(GameContent.Assets.Images.Controls.Button, new Vector2(0, 20 + CoopLabel.Height + CoopLabel.Y), Sprites.SpriteBatch);
LMS.X = CoopButton.GetCenterPosition(Graphics.Viewport).X;
LMSLabel = new TextSprite(Sprites.SpriteBatch, GameContent.Assets.Fonts.NormalText, "LMS", Color.White);
LMSLabel.HoverColor = Color.MediumAquamarine;
LMSLabel.NonHoverColor = Color.White;
LMSLabel.IsHoverable = true;
LMSLabel.ParentSprite = LMS;
LMSLabel.Pressed += StateManager.ButtonSFXHelper;
LMSLabel.Pressed += new EventHandler(DeathMatchLabel_Pressed);
Sprites.Add(LMS);
AdditionalSprites.Add(LMSLabel);
TDM = new Sprite(GameContent.Assets.Images.Controls.Button, new Vector2(0, 20 + LMSLabel.Height + LMSLabel.Y), Sprites.SpriteBatch);
TDM.X = LMS.GetCenterPosition(Graphics.Viewport).X;
TDMLabel = new TextSprite(Sprites.SpriteBatch, GameContent.Assets.Fonts.NormalText, "Team Deathmatch", Color.White);
TDMLabel.HoverColor = Color.MediumAquamarine;
TDMLabel.NonHoverColor = Color.White;
TDMLabel.IsHoverable = true;
TDMLabel.ParentSprite = TDM;
TDMLabel.Pressed += StateManager.ButtonSFXHelper;
TDMLabel.Pressed += new EventHandler(TDMLabel_Pressed);
Sprites.Add(TDM);
AdditionalSprites.Add(TDMLabel);
BackButton = new Sprite(GameContent.Assets.Images.Controls.Button, new Vector2(0, 0), Sprites.SpriteBatch);
BackButton.X = BackButton.GetCenterPosition(Graphics.Viewport).X;
BackButton.Y = StateManager.GraphicsManager.GraphicsDevice.Viewport.Height - 50 - BackButton.Height;
BackLabel = new TextSprite(Sprites.SpriteBatch, GameContent.Assets.Fonts.NormalText, "Back", Color.White);
BackLabel.HoverColor = Color.MediumAquamarine;
BackLabel.NonHoverColor = Color.White;
BackLabel.IsHoverable = true;
BackLabel.ParentSprite = BackButton;
BackLabel.Pressed += StateManager.ButtonSFXHelper;
BackLabel.Pressed += new EventHandler(BackLabel_Pressed);
Sprites.Add(BackButton);
AdditionalSprites.Add(BackLabel);
#if XBOX
AllButtons = new GamePadButtonEnumerator(new TextSprite[,] { { CoopLabel }, { LMSLabel }, { TDMLabel }, { BackLabel } }, InputType.LeftJoystick);
AllButtons.FireTextSpritePressed = true;
#endif
}