本文整理汇总了C#中GameStateManagement.GameScreen类的典型用法代码示例。如果您正苦于以下问题:C# GameScreen类的具体用法?C# GameScreen怎么用?C# GameScreen使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GameScreen类属于GameStateManagement命名空间,在下文中一共展示了GameScreen类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadingScreen
/// <summary>
/// The constructor is private: loading screens should
/// be activated via the static Load method instead.
/// </summary>
private LoadingScreen (ScreenManager screenManager,bool loadingIsSlow,
GameScreen[] screensToLoad)
{
this.loadingIsSlow = loadingIsSlow;
this.screensToLoad = screensToLoad;
TransitionOnTime = TimeSpan.FromSeconds (0.5);
// If this is going to be a slow load operation, create a background
// thread that will update the network session and draw the load screen
// animation while the load is taking place.
if (loadingIsSlow) {
backgroundThread = new Thread (BackgroundWorkerThread);
backgroundThreadExit = new ManualResetEvent (false);
graphicsDevice = screenManager.GraphicsDevice;
// Look up some services that will be used by the background thread.
IServiceProvider services = screenManager.Game.Services;
networkSession = (NetworkSession)services.GetService (
typeof(NetworkSession));
messageDisplay = (IMessageDisplay)services.GetService (
typeof(IMessageDisplay));
}
}
示例2: GetTexture
// System.Drawing is NOT avaiable on WP7 or Xbox
/*
* http://stackoverflow.com/a/7394185/195722
*
*
*
*/
public static Texture2D GetTexture(this System.Drawing.Bitmap bitmap, GameScreen gameScreen)
{
BlendState oldstate = gameScreen.ScreenManager.GraphicsDevice.BlendState;
gameScreen.ScreenManager.GraphicsDevice.BlendState = BlendState.AlphaBlend;
Texture2D tex = new Texture2D(gameScreen.ScreenManager.GraphicsDevice, bitmap.Width, bitmap.Height, true, SurfaceFormat.Color);
System.Drawing.Imaging.BitmapData data = bitmap.LockBits(new System.Drawing.Rectangle(0, 0, bitmap.Width, bitmap.Height), System.Drawing.Imaging.ImageLockMode.ReadOnly, bitmap.PixelFormat);
int bufferSize = data.Height * data.Stride;
//create data buffer
byte[] bytes = new byte[bufferSize];
// copy bitmap data into buffer
System.Runtime.InteropServices.Marshal.Copy(data.Scan0, bytes, 0, bytes.Length);
// copy our buffer to the texture
tex.SetData(bytes);
// unlock the bitmap data
bitmap.UnlockBits(data);
gameScreen.ScreenManager.GraphicsDevice.BlendState = oldstate;
return tex;
}
示例3: SongSelectionBox
public SongSelectionBox(GameScreen screen, Vector2 position, Vector2 size)
: base(screen.ScreenManager.Game)
{
this.screen = screen;
this.position = position;
this.size = size;
}
示例4: Widget
public Widget(GameScreen screen, ContentManager content)
{
Screen = screen;
spriteBatch = screen.ScreenManager.SpriteBatch;
contentManager = content;
LoadContent();
}
示例5: LoadModScripts
// this is not a permanent solution!
public static void LoadModScripts(GameScreen gameScreen, string dir)
{
foreach (string filename in Directory.GetFiles(dir))
{
if (filename.EndsWith(".fazemod"))
{
bool add = false; // add this script to screen or not?
Script scriptToAdd = GetScriptFromAssembly(filename);
// we have got the script and it's initialized, but is it the one we want?
if (scriptToAdd.SupportedScreenTypes != null)
{
foreach (Type type in scriptToAdd.SupportedScreenTypes)
if (type == gameScreen.GetType()) add = true;
}
else
add = true;
if (add)
{
scriptToAdd.GameScreen = gameScreen;
scriptToAdd.FileName = Path.GetFileName(filename);
gameScreen.Scripts.Add(scriptToAdd);
scriptToAdd.Init(); // dont forget to init them
}
}
}
}
示例6: PauseScreen
public PauseScreen(GameScreen backgroundScreen, Player human, Player computer)
: base(String.Empty)
{
IsPopup = true;
this.backgroundScreen = backgroundScreen;
// Create our menu entries.
MenuEntry startGameMenuEntry = new MenuEntry("Return");
MenuEntry exitMenuEntry = new MenuEntry("Quit Game");
// Hook up menu event handlers.
startGameMenuEntry.Selected += StartGameMenuEntrySelected;
exitMenuEntry.Selected += OnCancel;
// Add entries to the menu.
MenuEntries.Add(startGameMenuEntry);
MenuEntries.Add(exitMenuEntry);
this.human = human;
this.computer = computer;
// Preserve the old state of the game
prevHumanIsActive = this.human.Catapult.IsActive;
prevCompuerIsActive = this.computer.Catapult.IsActive;
// Pause the game logic progress
this.human.Catapult.IsActive = false;
this.computer.Catapult.IsActive = false;
AudioManager.PauseResumeSounds(false);
}
示例7: StoryScreen
/// <summary>
/// Constructor.
/// </summary>
public StoryScreen( List<String> storytext, List<String> titletext, GameScreen DestScreen, GameData saveData)
: base(titletext[0])
{
saveGameData = saveData;
this.DestScreen = DestScreen;
//SpriteFont font = ScreenManager.Font; //Get font of the ScreenManager
// Create our menu entries.
Storyline = storytext;
StoryTitles = titletext;
StorylineEntry = new VarSizeMenuEntry ( Storyline[0] , 0.7f);
BlankEntry = new VarSizeMenuEntry ( " ", 0.7f);
MenuEntry ContinueEntry = new VarSizeMenuEntry ( "Continue", 1f);
// Hook up menu event handlers.
ContinueEntry.Selected += continueSelected;
// Add entries to the menu.
MenuEntries.Add ( StorylineEntry );
MenuEntries.Add ( BlankEntry );
MenuEntries.Add ( ContinueEntry );
//Select the first selectable entry
while (menuEntries[selectedEntry].HasNoHandle)
{
selectedEntry++;
}
}
示例8: Scenario
public Scenario(GameScreen gameScreen, GameWorld world, Camera2D camera)
: base(gameScreen, world, camera)
{
levelNumber = 0;
physics.bodys = new Body[1]{ new Body(world) };
images = new List<SpriteSheet>();
}
示例9: Draw
public void Draw(GameScreen screen)
{
// Grab some common items from the ScreenManager
SpriteBatch spriteBatch = screen.ScreenManager.SpriteBatch;
SpriteFont font = screen.ScreenManager.Font;
spriteBatch.DrawString(font, Text, Position, Microsoft.Xna.Framework.Color.Yellow);
}
示例10: LoadingScreen
/// <summary>
/// The constructor is private: loading screens should
/// be activated via the static Load method instead.
/// </summary>
private LoadingScreen(ScreenManager screenManager, bool loadingIsSlow,
GameScreen[] screensToLoad)
{
this.loadingIsSlow = loadingIsSlow;
this.screensToLoad = screensToLoad;
TransitionOnTime = TimeSpan.FromSeconds(0.5);
}
示例11: AddScreen
public void AddScreen(GameScreen screen)
{
screen.ScreenManager = this;
screen.IsExiting = false;
if (isInitialized)
screen.Activate(false);
screens.Add(screen);
}
示例12: LoadingScreen
/// <summary>
/// The constructor is private: loading screens should
/// be activated via the static Load method instead.
/// </summary>
private LoadingScreen(ScreenManager screenManager, bool loadingIsSlow,
GameScreen[] screensToLoad)
: base(false)
{
this.loadingIsSlow = loadingIsSlow;
this.screensToLoad = screensToLoad;
EnabledGestures = GestureType.Tap; // Monogame goes on an infinite loop if I don't do this..
}
示例13: PhysicObject
public PhysicObject(GameScreen gameScreen, GameWorld world, Camera2D camera)
: base(gameScreen.ScreenManager.Game)
{
this.gameScreen = gameScreen;
physics.world = world;
physics.bodys = null;
this.camera = camera;
}
示例14: MenuButton
/// <summary>
/// Constructs a new menu entry with the specified text.
/// </summary>
public MenuButton(Texture2D sprite, bool flip, Vector2 position, GameScreen screen)
{
_screen = screen;
_scale = 1f;
_sprite = sprite;
_baseOrigin = new Vector2(_sprite.Width / 2f, _sprite.Height / 2f);
_hover = false;
_flip = flip;
Position = position;
}
示例15: LoadingScreen
/// <summary>
/// The constructor is private: loading screens should
/// be activated via the static Load method instead.
/// </summary>
private LoadingScreen(ScreenManager screenManager, bool loadingIsSlow,
GameScreen[] screensToLoad)
{
this.loadingIsSlow = loadingIsSlow;
this.screensToLoad = screensToLoad;
rnd = new Random();
randInt = rnd.Next(3); // 0 to 2
TransitionOnTime = TimeSpan.FromSeconds(0.5);
}