我使用這個圖片:圖像插值C#2010
我想用出的顏色的混合超級它的大小。有沒有辦法通過C#中的顏色混合來放大它?我在網上查了一下,但所有的方法都沒有成功。
我應該給我怎麼回事,通過把圖像在屏幕上。
的Game1:(設置了整個程序)
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
namespace **
{
public class Game1 : Microsoft.Xna.Framework.Game
{
GraphicsDeviceManager graphics;
SpriteBatch spriteBatch;
enum GameStates { StartUp, TitleScreen, Options, Credits, Paused, Playing, Death, Continue }
GameStates gameState = GameStates.TitleScreen;
public static int screenHeight = 768;
public static int screenWidth = 1024;
public Game1()
{
graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
graphics.PreferredBackBufferHeight = screenHeight;
graphics.PreferredBackBufferWidth = screenWidth;
graphics.IsFullScreen = false;
graphics.ApplyChanges();
StartUp.Images.Content = Content;
}
protected override void Initialize()
{
this.IsMouseVisible = true;
base.Initialize();
}
protected override void LoadContent()
{
spriteBatch = new SpriteBatch(GraphicsDevice);
StartUp.Images.Load();
}
protected override void UnloadContent()
{
// TODO: Unload any non ContentManager content here
}
protected override void Update(GameTime gameTime)
{
// Allows the game to exit
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
this.Exit();
switch (gameState)
{
case GameStates.StartUp:
break;
case GameStates.TitleScreen:
break;
case GameStates.Options:
break;
case GameStates.Credits:
break;
}
base.Update(gameTime);
}
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.CornflowerBlue);
spriteBatch.Begin();
if (gameState == GameStates.TitleScreen ||
gameState == GameStates.Options ||
gameState == GameStates.Credits)
{
spriteBatch.Draw(StartUp.Images.Background, new Rectangle(0, 0, screenWidth, screenHeight), Color.White);
}
if (gameState == GameStates.TitleScreen)
{
StartUp.TitleScreen.Draw(spriteBatch);
}
if (gameState == GameStates.Options)
{
StartUp.Options.Draw(spriteBatch);
}
spriteBatch.End();
base.Draw(gameTime);
}
}
}
圖片:(載荷使用的圖像)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
namespace **.StartUp
{
class Images
{
#region Define
public static ContentManager Content;
//TitleScreen
public static Texture2D Background;
public static Texture2D Continue;
public static Texture2D Credits;
public static Texture2D Exit;
public static Texture2D Logo;
public static Texture2D Options;
public static Texture2D Play;
public static Texture2D Version;
//End
//Options
public static Texture2D OptionsLogo;
public static Texture2D OffNotSelected;
public static Texture2D OffSelected;
public static Texture2D OnNotSelected;
public static Texture2D OnSelected;
public static Texture2D FullScreen;
public static Texture2D Menu;
public static Texture2D Music;
public static Texture2D SliderBackground;
public static Texture2D Slider;
public static Texture2D SoundFX;
//End
#endregion
#region Load
public static void Load()
{
Background = Content.Load<Texture2D>(@"Images\StartUp\Background");
Continue = Content.Load<Texture2D>(@"Images\StartUp\Continue");
Credits = Content.Load<Texture2D>(@"Images\StartUp\Credits");
Exit = Content.Load<Texture2D>(@"Images\StartUp\Exit");
FullScreen = Content.Load<Texture2D>(@"Images\StartUp\FullScreen");
Logo = Content.Load<Texture2D>(@"Images\StartUp\Logo");
Menu = Content.Load<Texture2D>(@"Images\StartUp\Menu");
Music = Content.Load<Texture2D>(@"Images\StartUp\Music");
OffNotSelected = Content.Load<Texture2D>(@"Images\StartUp\OffNotSelected");
OffSelected = Content.Load<Texture2D>(@"Images\StartUp\OffSelected");
OnNotSelected = Content.Load<Texture2D>(@"Images\StartUp\OnNotSelected");
OnSelected = Content.Load<Texture2D>(@"Images\StartUp\OnSelected");
Options = Content.Load<Texture2D>(@"Images\StartUp\Options");
OptionsLogo = Content.Load<Texture2D>(@"Images\StartUp\OptionsLogo");
Play = Content.Load<Texture2D>(@"Images\StartUp\Play");
Slider = Content.Load<Texture2D>(@"Images\StartUp\Slider");
SliderBackground = Content.Load<Texture2D>(@"Images\StartUp\SliderBackground");
SoundFX = Content.Load<Texture2D>(@"Images\StartUp\SoundFX");
Version = Content.Load<Texture2D>(@"Images\StartUp\Version");
}
#endregion
}
}
TitleScreen:(繪製圖像並定位圖像)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
namespace **.StartUp
{
class TitleScreen
{
#region Define
static new Rectangle con = new Rectangle(330, 246, 364, 84);
static new Rectangle cre = new Rectangle(330, 430, 364, 84);
static new Rectangle exit = new Rectangle(330, 522, 364, 84);
static new Rectangle logo = new Rectangle(216, 37, 591, 71);
static new Rectangle opt = new Rectangle(330, 338, 364, 84);
static new Rectangle play = new Rectangle(330, 154, 364, 84);
static new Rectangle ver = new Rectangle(7, 701, 215, 39);
static Vector2 love = new Vector2(100, 100);
#endregion
#region Update and Draw
public static void Update(GameTime gameTime)
{
MouseState mouse = Mouse.GetState();
}
public static void Draw(SpriteBatch spriteBatch)
{
spriteBatch.Draw(Images.Continue, con, Color.White);
spriteBatch.Draw(Images.Credits, cre, Color.White);
spriteBatch.Draw(Images.Exit, exit, Color.White);
spriteBatch.Draw(Images.Play, play, Color.White);
spriteBatch.Draw(Images.Options, opt, Color.White);
spriteBatch.Draw(Images.Logo, logo, Color.White);
spriteBatch.Draw(Images.Version, love, Color.White);
}
#endregion
#region Methods
#endregion
}
}
編輯:(10:21_11/26/2013年)
我正在關閉,但需要多一點幫助,我準備好通過SpriteBatch.Begin Methods
和他們做什麼,但還是很失落我喜歡一些幫助,這個問題。
如果我使用矢量,它會超小,它將無法被看到。我需要增加它的尺寸,使它失去其全部顏色並保持它的顏色。 –
請理解:http://i.imgur.com/Cgx9AYz.png我想有一個矩形具有正確的尺寸,並保持它好,因爲當它是小 –
你的意思是'VECTOR',可容納無數的信息或將圖像定位在屏幕上的'vector2'。 –