0

嘿,我试图翻转我的一个背景图像,所以在背景类的构造函数中,我使用了 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);
4

1 回答 1

0

在以下代码中:

public BackgroundSprite(string name, TextureData textureData, SpritePresentationInfo       spritePresentationInfo,
   SpritePositionInfo spritePositionInfo,SpriteEffects spriteEffects)
    : base(name, textureData, spritePresentationInfo, spritePositionInfo)
{

}

您向 BackgroundSprite 发送一个 SpriteEffects,但 SpriteEffects 不会在其他任何地方发送或使用。似乎 SpriteEffects 必须添加到 Base 构造函数中。

public BackgroundSprite(string name, TextureData textureData, SpritePresentationInfo       spritePresentationInfo,
   SpritePositionInfo spritePositionInfo,SpriteEffects spriteEffects)
    : base(name, textureData, spritePresentationInfo, spritePositionInfo, spriteEffects)
{

}
于 2013-11-12T18:19:21.317 回答