本文整理汇总了C#中System.Image.LoadContent方法的典型用法代码示例。如果您正苦于以下问题:C# Image.LoadContent方法的具体用法?C# Image.LoadContent怎么用?C# Image.LoadContent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Image
的用法示例。
在下文中一共展示了Image.LoadContent方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Arrow
public Arrow(Keys lastKey, object obj)
{
Image = new Image();
switch (lastKey)
{
case Keys.W:
Image.Path = "Gameplay/Projectiles/arrow_up";
break;
case Keys.S:
Image.Path = "Gameplay/Projectiles/arrow_down";
break;
case Keys.A:
Image.Path = "Gameplay/Projectiles/arrow_left";
break;
case Keys.D:
Image.Path = "Gameplay/Projectiles/arrow_right";
break;
}
DirectionKey = lastKey;
if (obj.GetType() == typeof(Player))
{
Player p = (Player)obj;
Image.Position = p.Image.Position;
}
MoveSpeed = 250f;
Image.Scale = new Vector2(1, 2);
Image.LoadContent();
}
示例2: LoadContent
public override void LoadContent()
{
base.LoadContent();
Image = new Image();
Image.Path = "Gameplay/UI/loadingscreenanimation";
//Image.SourceRect = new Rectangle(0, 0, 400, 100);
//Image.Position = new Vector2 ((ScreenManager.Instance.GraphicsDevice.Viewport.Width / 2) - 100,
// (ScreenManager.Instance.GraphicsDevice.Viewport.Height / 2) - 100);
Image.LoadContent();
Image.SourceRect = new Rectangle(0, 0, 100, 100);
//Image.Position = new Vector2 ((ScreenManager.Instance.GraphicsDevice.Viewport.Width / 2) - 100,
// (ScreenManager.Instance.GraphicsDevice.Viewport.Height / 2) - 100);
Image.IsActive = true;
Image.ActivateEffect ("SpriteSheetEffect");
Image.SpriteSheetEffect.IsActive = true;
/* Turn the fade effect off */
Image.FadeEffect.IsActive = false;
/* Make the player face the camera */
Image.SpriteSheetEffect.SwitchFrame = 250;
Image.SpriteSheetEffect.AmountOfFrames = new Vector2(4, 1);
Image.SpriteSheetEffect.DefaultFrame = Vector2.Zero;
Image.SpriteSheetEffect.CurrentFrame = Image.SpriteSheetEffect.DefaultFrame;
Image.Position = new Vector2 (Image.Position.X - 50, Image.Position.Y - 50);
}
示例3: LoadContent
public override void LoadContent()
{
loadingImage = new Image();
loadingImage.Path = "Gameplay/UI/loadingscreenanimation";
//Image.SourceRect = new Rectangle(0, 0, 400, 100);
//Image.Position = new Vector2 ((ScreenManager.Instance.GraphicsDevice.Viewport.Width / 2) - 100,
// (ScreenManager.Instance.GraphicsDevice.Viewport.Height / 2) - 100);
loadingImage.LoadContent();
loadingImage.SourceRect = new Rectangle(0, 0, 100, 100);
//Image.Position = new Vector2 ((ScreenManager.Instance.GraphicsDevice.Viewport.Width / 2) - 100,
// (ScreenManager.Instance.GraphicsDevice.Viewport.Height / 2) - 100);
loadingImage.IsActive = true;
loadingImage.ActivateEffect ("SpriteSheetEffect");
loadingImage.SpriteSheetEffect.IsActive = true;
loadingImage.FadeEffect.IsActive = false;
loadingImage.SpriteSheetEffect.SwitchFrame = 250;
loadingImage.SpriteSheetEffect.AmountOfFrames = new Vector2(4, 1);
loadingImage.SpriteSheetEffect.DefaultFrame = Vector2.Zero;
loadingImage.SpriteSheetEffect.CurrentFrame = loadingImage.SpriteSheetEffect.DefaultFrame;
loadingImage.Position = new Vector2 (loadingImage.Position.X - 50, loadingImage.Position.Y - 50);
IsInitializing = true;
base.LoadContent();
InputManager.Instance.ResetInputState();
Camera2D.Instance.PlayerPosition = Camera2D.Instance.ScreenCenter;
Camera2D.Instance.Position = Camera2D.Instance.ScreenCenter;
LoadBackground();
LoadSongism();
LoadButtons();
//_guessingItem = new SongismGuessingItem("All Mixed Up");
//_guessingItem.Position = new Vector2(16, 16);
//_guessingItem.LoadContent();
_fDiscovered = currentSongism.Discovered;
if (_fDiscovered) {
_oSongInfoList = new SongismSongInfoListBox (currentSongism.SongInfo);
_oSongInfoList.LoadContent ();
} else {
_guessingList = new SongismGuessingListBox();
_guessingList.LoadContent();
}
IsInitializing = false;
}
示例4: LoadContent
public void LoadContent()
{
Image = new Image();
Image.Path = "Gameplay/UI/backpack";
Image.LoadContent();
Image.SourceRect = new Rectangle(0, 0, 64, 64);
Image.IsActive = true;
Image.DeactivateEffect ("SpriteSheetEffect");
Image.SpriteSheetEffect.IsActive = false;
Image.FadeEffect.IsActive = false;
Image.TextAlignment = Globals.TextAlignment.Center;
Image.TextColor = Color.White;
Image.AddText(Inventory.Instance.SongBook.Count.ToString());
}
示例5: LoadContent
public void LoadContent()
{
Image = new Image();
Image.Path = "Gameplay/UI/areaprogressicon";
Image.FontName = "Fonts/GameFont_Size32";
Image.LoadContent();
Image.SourceRect = new Rectangle(0, 0, 100, 100);
Image.IsActive = true;
Image.DeactivateEffect ("SpriteSheetEffect");
Image.SpriteSheetEffect.IsActive = false;
Image.FadeEffect.IsActive = false;
Image.TextAlignment = Globals.TextAlignment.Center;
Image.TextColor = Color.White;
Image.AddText(Inventory.Instance.SongBook.Count.ToString());
}
示例6: LoadContent
public void LoadContent()
{
IsInitializing = true;
SongInfoImage = new Image();
SongInfoImage.Text = _sSongInfoText;
SongInfoImage.FontName = "Fonts/GameFont_Size32";
SongInfoImage.LoadContent();
SongInfoImage.DeactivateEffect("FadeEffect");
SongInfoImage.DeactivateEffect("SpriteSheetEffect");
SongInfoImage.Alpha = 1.0f;
SongInfoImage.AddText(SongInfoImage.Text);
//SongNameImage.AddTextThreadSafe(SongNameImage.Text);
SongInfoImage.Position = Position;
_songNameBoundingBox = new Rectangle((int)SongInfoImage.Position.X, (int)SongInfoImage.Position.Y, SongInfoImage.SourceRect.Width, SongInfoImage.SourceRect.Height);
IsInitializing = false;
}
示例7: CreateItem
private Image CreateItem(XmlNode currentNode)
{
var item = currentNode.SelectSingleNode("Item");
if (item != null)
{
var image = new Image
{
Texture = _manager.Load<Texture2D>("gfx/Items/" + item.SelectSingleNode("Type").InnerText)
};
if (item.SelectSingleNode("Rotation") != null)
image.Rotation = int.Parse(item.SelectSingleNode("Rotation").InnerText) *
(float)(Math.PI / 180f);
if (item.SelectSingleNode("Position") != null)
{
var pos = item.SelectSingleNode("Position").InnerText.Split(',');
image.Position = new Vector2(int.Parse(pos[0]), int.Parse(pos[1]));
}
image.LoadContent();
return image;
}
return null;
}
示例8: LoadContent
/// <summary>
/// Loads relaven screen content.
/// </summary>
public override void LoadContent()
{
base.LoadContent();
//Load enemies images.
for (int i = 0; i < enemies.Count; i++)
{
enemies[i].LoadContent();
enemies[i].SpriteImage.Position = Constants.EnemyPositions[i];
}
//Load background.
XmlManager<Image> backgroundLoader = new XmlManager<Image>();
background = backgroundLoader.Load("Load/Battle/Background.xml");
background.LoadContent();
//Load player.
Player.SpriteImage.Position = Constants.PlayerPosition1;
//Start music
backgroundMusic = content.Load<Song>("Music/BattleTheme");
BackgroundMusicPlayer.Play(backgroundMusic);
//Seed both enemies and player with a random action slice
Player.ActionTimeCurrent = (Constants.Random.Next(0, ((Constants.maxActionTimer*10)/Player.Speed))/10f);
foreach (var enemy in enemies)
{
enemy.ActionTimeCurrent = (Constants.Random.Next(0, ((Constants.maxActionTimer*10)/enemy.Speed))/10f);
}
}
示例9: LoadButtons
void LoadButtons()
{
_btnNewGame = new DialogButton(true);
_btnLoadGame = new DialogButton(CheckForExistingGameFiles());
Image newGameImage = new Image();
newGameImage.Path = "Gameplay/UI/buttonsheet";
newGameImage.Effects = "SpriteSheetEffect";
newGameImage.FontName = "Fonts/GameFont_Size32";
newGameImage.TextAnimationTravel = new Vector2(0, 9);
newGameImage.TextAlignment = Globals.TextAlignment.Center;
newGameImage.LoadContent();
Image loadGameImage = new Image();
loadGameImage.Path = "Gameplay/UI/buttonsheet";
loadGameImage.Effects = "SpriteSheetEffect";
loadGameImage.FontName = "Fonts/GameFont_Size32";
loadGameImage.TextAnimationTravel = new Vector2(0, 9);
loadGameImage.TextAlignment = Globals.TextAlignment.Center;
if (!CheckForExistingGameFiles())
loadGameImage.TextColor = Color.Gray;
loadGameImage.LoadContent();
_btnNewGame.ButtonName = "_btnNewGame";
_btnNewGame.Image = newGameImage;
newGameImage.SpriteSheetEffect.AmountOfFrames = new Vector2(1, 2);
newGameImage.SpriteSheetEffect.CurrentFrame = new Vector2(0, 0);
newGameImage.UpdateSourceRectPosition ((int)newGameImage.Position.X, (int)newGameImage.Position.Y);
_btnNewGame.Image.Position = new Vector2 ((ScreenManager.Instance.GraphicsDevice.Viewport.Width / 2) - (newGameImage.SourceRect.Width),
(ScreenManager.Instance.GraphicsDevice.Viewport.Height / 2) - newGameImage.SpriteSheetEffect.FrameHeight);
newGameImage.AddText("New Game");
_btnLoadGame.ButtonName = "_btnLoadGame";
_btnLoadGame.Image = loadGameImage;
loadGameImage.SpriteSheetEffect.AmountOfFrames = new Vector2(1, 2);
loadGameImage.SpriteSheetEffect.CurrentFrame = new Vector2(0, 0);
loadGameImage.UpdateSourceRectPosition ((int)loadGameImage.Position.X, (int)loadGameImage.Position.Y);
_btnLoadGame.Image.Position = new Vector2((ScreenManager.Instance.GraphicsDevice.Viewport.Width - loadGameImage.SourceRect.Width) - (ScreenManager.Instance.GraphicsDevice.Viewport.Width / 25),
(ScreenManager.Instance.GraphicsDevice.Viewport.Height - loadGameImage.SpriteSheetEffect.FrameHeight - 16));
_btnLoadGame.Image.Position = new Vector2 ((ScreenManager.Instance.GraphicsDevice.Viewport.Width / 2) - (newGameImage.SourceRect.Width),
(_btnNewGame.Image.Position.Y + loadGameImage.SpriteSheetEffect.FrameHeight + 50));
loadGameImage.AddText("Load Game");
_btnNewGame.OnButtonRelease += _btnNewGame_OnButtonRelease;
_btnLoadGame.OnButtonRelease += _btnLoadGame_OnButtonRelease;
}
示例10: LoadContent
public override void LoadContent()
{
base.LoadContent();
SpriteImage = new Image();
XmlManager<Image> spriteLoader = new XmlManager<Image>();
SpriteImage = spriteLoader.Load(this.ImageLoadPath);
SpriteImage.LoadContent();
}
示例11: LoadSongism
void LoadSongism()
{
XmlManager<Songism> currentSongismLoader = new XmlManager<Songism>();
currentSongism = currentSongismLoader.Load(System.IO.Path.Combine(Globals.LoadGameplaySongismsDirectory, "CurrentSongism.xml"));
CurrentSongismImage = new Image();
CurrentSongismImage.Path = currentSongism.Image.Path;
CurrentSongismImage.LoadContent();
CurrentSongismImage.DeactivateEffect("FadeEffect");
CurrentSongismImage.DeactivateEffect("SpriteSheetEffect");
CurrentSongismImage.Alpha = 1.0f;
CurrentSongismImage.Scale = new Vector2((512 / CurrentSongismImage.SourceRect.Width), (512 / CurrentSongismImage.SourceRect.Height));
CurrentSongismImage.Position = new Vector2((ScreenManager.Instance.GraphicsDevice.Viewport.Width / 2) + (ScreenManager.Instance.GraphicsDevice.Viewport.Width / 4) - (ScreenManager.Instance.GraphicsDevice.Viewport.Width / 20), // - (ScreenManager.Instance.GraphicsDevice.Viewport.Width / 100),
(ScreenManager.Instance.GraphicsDevice.Viewport.Height / 2) - (ScreenManager.Instance.GraphicsDevice.Viewport.Height / 10));
_songismName = new Image();
_songismName.FontName = "Fonts/GameFont_Size32";
_songismName.TextAlignment = Globals.TextAlignment.Center;
if (currentSongism.Discovered)
_songismName.Text = currentSongism.Name;
else
_songismName.Text = "????";
_songismName.LoadContent();
_songismName.DeactivateEffect("FadeEffect");
_songismName.DeactivateEffect("SpriteSheetEffect");
_songismName.Alpha = 1.0f;
if (currentSongism.Discovered)
_songismName.AddText(currentSongism.Name);
else
_songismName.AddText("????");
_songismName.Position = new Vector2(CurrentSongismImage.Position.X + (CurrentSongismImage.SourceRect.Width / 2) - (_songismName.SourceRect.Width / 2), 16);
}
示例12: LoadButtons
void LoadButtons()
{
addToSongBook = new DialogButton(!currentSongism.Discovered);
cancel = new DialogButton(true);
Image addImage = new Image();
addImage.Path = "Gameplay/UI/buttonsheet";
addImage.Effects = "SpriteSheetEffect";
addImage.FontName = "Fonts/GameFont_Size32";
addImage.TextAnimationTravel = new Vector2(0, 9);
addImage.TextAlignment = Globals.TextAlignment.Center;
if (currentSongism.Discovered)
addImage.TextColor = Color.Gray;
addImage.LoadContent();
Image cancelImage = new Image();
cancelImage.Path = "Gameplay/UI/buttonsheet";
cancelImage.Effects = "SpriteSheetEffect";
cancelImage.FontName = "Fonts/GameFont_Size32";
cancelImage.TextAnimationTravel = new Vector2(0, 9);
cancelImage.TextAlignment = Globals.TextAlignment.Center;
cancelImage.LoadContent();
addToSongBook.ButtonName = "Add";
addToSongBook.Image = addImage;
//addToSongBook.Image.Position = new Vector2((ScreenManager.Instance.GraphicsDevice.Viewport.Width / 2) - (addImage.SourceRect.Width / 2),
// (ScreenManager.Instance.GraphicsDevice.Viewport.Height - addImage.SourceRect.Height));
//addToSongBook.Image.Position = new Vector2((ScreenManager.Instance.GraphicsDevice.Viewport.Width / 2) - (addImage.SourceRect.Width),
// (ScreenManager.Instance.GraphicsDevice.Viewport.Height - addImage.SourceRect.Height));
addImage.SpriteSheetEffect.AmountOfFrames = new Vector2(1, 2);
addImage.SpriteSheetEffect.CurrentFrame = new Vector2(0, 0);
addImage.UpdateSourceRectPosition ((int)addImage.Position.X, (int)addImage.Position.Y);
//addToSongBook.Image.Position = new Vector2((ScreenManager.Instance.GraphicsDevice.Viewport.Width / 2) - (addImage.SourceRect.Width),
// (ScreenManager.Instance.GraphicsDevice.Viewport.Height - addImage.SpriteSheetEffect.FrameHeight - 16));
addToSongBook.Image.Position = new Vector2(CurrentSongismImage.Position.X - addImage.SpriteSheetEffect.FrameWidth + 16,
ScreenManager.Instance.GraphicsDevice.Viewport.Height - addImage.SpriteSheetEffect.FrameHeight - 16);
addImage.AddText("Add");
cancel.ButtonName = "Cancel";
cancel.Image = cancelImage;
//cancel.Image.Position = new Vector2((ScreenManager.Instance.GraphicsDevice.Viewport.Width - cancelImage.SourceRect.Width) - (ScreenManager.Instance.GraphicsDevice.Viewport.Width / 25),
// (ScreenManager.Instance.GraphicsDevice.Viewport.Height - cancelImage.SourceRect.Height));
cancelImage.SpriteSheetEffect.AmountOfFrames = new Vector2(1, 2);
cancelImage.SpriteSheetEffect.CurrentFrame = new Vector2(0, 0);
cancelImage.UpdateSourceRectPosition ((int)cancelImage.Position.X, (int)cancelImage.Position.Y);
//cancel.Image.Position = new Vector2((ScreenManager.Instance.GraphicsDevice.Viewport.Width - cancelImage.SourceRect.Width) - (ScreenManager.Instance.GraphicsDevice.Viewport.Width / 25),
// (ScreenManager.Instance.GraphicsDevice.Viewport.Height - cancelImage.SpriteSheetEffect.FrameHeight - 16));
cancel.Image.Position = new Vector2(CurrentSongismImage.Position.X + (CurrentSongismImage.SourceRect.Width / 2) + 16,
ScreenManager.Instance.GraphicsDevice.Viewport.Height - cancelImage.SpriteSheetEffect.FrameHeight - 16);
cancelImage.AddText("Cancel");
addToSongBook.OnButtonRelease += addToSongBook_OnButtonRelease;
cancel.OnButtonRelease += cancel_OnButtonRelease;
}
示例13: LoadContent
public override void LoadContent(ContentManager content, GraphicsDevice graph)
{
base.LoadContent(content, graph);
Settings.UseFPECollisionCategories = true;
ConvertUnits.SetDisplayUnitToSimUnitRatio(32f);
ServiceHelper.Get<SoundService>().AddSound("zap", "Sounds/zap.wav");
if (world == null)
{
world = new World(Vector2.Zero);
}
else
{
world.Clear();
}
world.Gravity = gravity;
if (debugView == null)
{
debugView = new DebugViewXNA(world);
debugView.LoadContent(graph, content);
}
projection = Matrix.CreateOrthographicOffCenter(
0f, ConvertUnits.ToSimUnits(graph.Viewport.Width),
ConvertUnits.ToSimUnits(graph.Viewport.Height), 0f,
0f, 1f
);
///////////////////////////////////////////////////////////////////////////////
player = BodyFactory.CreateCapsule(world, 0.5f, 0.8f, 1f);
player.CollisionCategories = Category.Cat2;
player.CollidesWith = Category.Cat1;
player.BodyType = BodyType.Dynamic;
player.Position = new Vector2(10, 3);
player.FixedRotation = true;
playerAnimation.LoadContent(
content,
"Graphics/CodingMadeEasyPlatformer/Hero1", Color.White,
ConvertUnits.ToDisplayUnits(player.Position),
200, new Vector2(3, 4)
);
playerAnimation.ScaleToBody(player);
playerAnimation.isActive = true;
for (int i = 0; i < 5; ++i)
{
Body platform = BodyFactory.CreateRectangle(world, 2f, 2f, 1f);
platform.CollisionCategories = Category.Cat1;
platform.CollidesWith = Category.Cat2;
platform.BodyType = BodyType.Static;
platform.Position = new Vector2(2 + (i * 3), 10);
Image platformImage = new Image();
platformImage.LoadContent(
content,
"Graphics/minecraft", Color.White,
ConvertUnits.ToDisplayUnits(platform.Position)
);
platformImage.ScaleToBody(platform);
platforms.Add(platform);
platformsImages.Add(platformImage);
}
}
示例14: LoadContent
public void LoadContent()
{
IsInitializing = true;
RadioButton = new Image();
RadioButton.Path = "Gameplay/UI/radiobuttonsheet";
RadioButton.SourceRect = new Rectangle(0, 0, 36, 36);
RadioButton.Effects = "SpriteSheetEffect";
RadioButton.LoadContent();
RadioButton.DeactivateEffect("FadeEffect");
RadioButton.Alpha = 1.0f;
RadioButton.SpriteSheetEffect.AmountOfFrames = new Vector2(1, 2);
RadioButton.SpriteSheetEffect.CurrentFrame = new Vector2(0, 0);
RadioButton.Position = Position;
RadioButton.UpdateSourceRectPosition ((int)RadioButton.Position.X, (int)RadioButton.Position.Y);
font = ScreenManager.Instance.Content.Load<SpriteFont> ("Fonts/GameFont_Size32");
_radioButtonBoundingBox = new Rectangle(RadioButton.SourceRect.X, RadioButton.SourceRect.Y, RadioButton.SourceRect.Width, RadioButton.SourceRect.Height);
_songNameBoundingBox = new Rectangle((int)RadioButton.Position.X + RadioButton.SpriteSheetEffect.FrameWidth + 10, (int)Position.Y - 10, (int)font.MeasureString(SongName).X, (int)font.MeasureString(SongName).Y);
Loaded = true;
IsInitializing = false;
}