嘿,我试图翻转我的一个背景图像,所以在背景类的构造函数中,我使用了 SpriteEffects,所以在构造时我可以判断我是否想要翻转,但是这样做没有任何反应。我已经尝试了一些东西,但我很难过。
谁能帮我这个?
背景精灵
public class BackgroundSprite : Sprite
{
public BackgroundSprite(string name, TextureData textureData, SpritePresentationInfo spritePresentationInfo,
SpritePositionInfo spritePositionInfo,SpriteEffects spriteEffects)
: base(name, textureData, spritePresentationInfo, spritePositionInfo)
{
}
//-----------------------------------------------------------------------------------
// Use this if we do not want to use the parents
//-----------------------------------------------------------------------------------
public override void Update(GameTime gameTime)
{
base.Update(gameTime);
}
//-----------------------------------------------------------------------------------
// Use this if we do not want to use the parents
//-----------------------------------------------------------------------------------
public override void Draw(GameTime gameTime)
{
base.Draw(gameTime);
}
}
主要的
//Get the texture to draw.
TextureData sky3TextureData = textureManager.Get("Sky_Back");
//How to draw the Texture
SpritePresentationInfo sky3PresentationInfo = new SpritePresentationInfo(sky3TextureData.FULLSOURCERECTANGLE, 0.8f);
SpritePositionInfo sky3PositionInfo = new SpritePositionInfo(new Vector2(1600, 0), sky3TextureData.Width(), sky3TextureData.Height(), 0, 1f, Vector2.Zero);
//Add the sprite to the game.
SpriteEffects flip = SpriteEffects.FlipHorizontally;
this.backgroundSprite = new BackgroundSprite("Sky_Back", sky3TextureData, sky3PresentationInfo, sky3PositionInfo, flip);
spriteManager.Add(backgroundSprite);