本文整理汇总了C#中SpriteEffects类的典型用法代码示例。如果您正苦于以下问题:C# SpriteEffects类的具体用法?C# SpriteEffects怎么用?C# SpriteEffects使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SpriteEffects类属于命名空间,在下文中一共展示了SpriteEffects类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Human
public Human(Game game, SpriteBatch screenSpriteBatch,
PlayerSide playerSide)
: base(game, screenSpriteBatch)
{
string idleTextureName = "";
this.playerSide = playerSide;
if (playerSide == PlayerSide.Left)
{
catapultPosition = new Vector2(140, 332);
idleTextureName = "Textures/Catapults/Blue/blueIdle/blueIdle";
}
else
{
catapultPosition = new Vector2(600, 332);
spriteEffect = SpriteEffects.FlipHorizontally;
idleTextureName = "Textures/Catapults/Red/redIdle/redIdle";
}
Catapult = new Catapult(game, screenSpriteBatch,
idleTextureName, catapultPosition,
spriteEffect,
playerSide == PlayerSide.Left
? false : true, true);
}
示例2: Draw
public void Draw(GameTime gameTime, SpriteBatch spriteBatch, Vector2 position, SpriteEffects spriteEffects)
{
if (Animation == null)
{
throw new NotSupportedException("No animation is currently playing.");
}
time += (float)gameTime.ElapsedGameTime.TotalSeconds;
while (time > Animation.frameTime)
{
time -= Animation.frameTime;
if (Animation.isLooping)
{
frameIndex = (frameIndex + 1) % Animation.FrameCount;
}
else
{
frameIndex = Math.Min(frameIndex + 1, Animation.FrameCount - 1);
}
}
Rectangle source = new Rectangle(FrameIndex * Animation.FrameWidth, 0, Animation.FrameWidth, Animation.FrameHeight);
spriteBatch.Draw(animation.texture, position, source, Color.White, 0.0f, Vector2.Zero, 0.5f, SpriteEffects.None, 0.0f);
}
示例3: SpriteRenderer
public SpriteRenderer(Entity parent)
: base(parent)
{
this.Color = Color.White;
this.Scale = 1;
this.SpriteEffects = SpriteEffects.None;
}
示例4: Graphic
public Graphic(Texture2D texture)
{
this.texture = texture;
this.mode = Mode.Sprite;
this.rotation = 0.0f;
this.effect = SpriteEffects.None;
}
示例5: Robot
public Robot(ADHDGame g, Stage st)
{
//init anims
right = new Animation(new Rectangle(0, 206, Size.X, Size.Y), 9, rate, true);
up = new Animation(new Rectangle(0, 103, Size.X, Size.Y), 9, rate, true);
down = new Animation(new Rectangle(0, 0, Size.X, Size.Y), 9, rate, true);
banjo = new Animation(new Rectangle(0, 618, Size.X, Size.Y), 9, 1.0f / 10.0f, false);
banjoPlay = new Animation(new Rectangle(0, 721, Size.X, Size.Y), 9, 1.0f / 10.0f, true);
die = new Animation(new Rectangle(0, 824, Size.X, Size.Y), 9, 1.0f / 10.0f, false);
pushDown = new Animation(new Rectangle(0, 309, Size.X, Size.Y), 9, 1.0f / 20.0f, false);
pushUp = new Animation(new Rectangle(0, 412, Size.X, Size.Y), 9, 1.0f / 20.0f, false);
pushRight = new Animation(new Rectangle(0, 515, Size.X, Size.Y), 9, 1.0f / 20.0f, false);
tex = g.Content.Load<Texture2D>("robot");
batch = st.batch;
stage = st;
position = Stage.TileToPos(new Point(11, 17));
currAnim = down;
currAnim.Stop();
Dir = Direction.Down;
velocity = Vector2.Zero;
flip = SpriteEffects.None;
game = g;
SnapToTile();
}
示例6: SetSpriteEffects
public override void SetSpriteEffects(int i, int j, ref SpriteEffects effects)
{
if (i % 2 == 1)
{
effects = SpriteEffects.FlipHorizontally;
}
}
示例7: Gun
public Gun(Texture2D[] inputTexture, SoundEffect inputZap)
{
// Gun's textures.
textureHolding = inputTexture;
gunTexture = inputTexture[0];
borderTexture = inputTexture[2];
// Munitions-in-flight.
BULLETS = new List<Bullet>();
// Offset for animation rotation.
rotationOffset = new Vector2(17.5F, 9);
// Width and height of the gun's sprite.
frameWidth = 35;
frameHeight = 18;
// Color, rotation, and effects.
color = Color.White;
rotation = 0;
effects = SpriteEffects.None;
// Where do you want the gun placed relative to the vector it is attached too?
placementXOffset = 15;
placementYOffset = 35;
// Zap sound effect.
zap = inputZap;
animationFrame = new Rectangle(0, 0, frameWidth, frameHeight);
mineSpawn = new Stopwatch();
}
示例8: CreateColored
/// <summary>
/// Creates a <see cref="ColoredString"/> object from an existing string with the specified foreground and background, setting the ignore properties if needed.
/// </summary>
/// <param name="value">The current string.</param>
/// <param name="foreground">The foreground color. If null, <see cref="ColoredString.IgnoreForeground"/> will be set.</param>
/// <param name="background">The background color. If null, <see cref="ColoredString.IgnoreBackground"/> will be set.</param>
/// <param name="spriteEffect">The background color. If null, <see cref="ColoredString.IgnoreEffect"/> will be set.</param>
/// <returns>A <see cref="ColoredString"/> object instace.</returns>
public static ColoredString CreateColored(this string value, Color? foreground = null, Color? background = null, SpriteEffects? spriteEffect = null)
{
var stacks = new ParseCommandStacks();
if (foreground.HasValue)
stacks.AddSafe(new ParseCommandRecolor() { R = foreground.Value.R, G = foreground.Value.G, B = foreground.Value.B, A = foreground.Value.A, CommandType = CommandTypes.Foreground });
if (background.HasValue)
stacks.AddSafe(new ParseCommandRecolor() { R = background.Value.R, G = background.Value.G, B = background.Value.B, A = background.Value.A, CommandType = CommandTypes.Background });
if (spriteEffect.HasValue)
stacks.AddSafe(new ParseCommandSpriteEffect() { Effect = spriteEffect.Value, CommandType = CommandTypes.SpriteEffect });
ColoredString newString = ColoredString.Parse(value, initialBehaviors: stacks);
if (!foreground.HasValue)
newString.IgnoreForeground = true;
if (!background.HasValue)
newString.IgnoreBackground = true;
if (!spriteEffect.HasValue)
newString.IgnoreSpriteEffect = true;
return newString;
}
示例9: DrawAnimation
// draw with sprite effect
public static void DrawAnimation(this SpriteBatch spriteBatch, Animation animation, Vector2 position, float angle, SpriteEffects effect)
{
Point tile = animation.GetTile(animation.CurrentFrame);
Rectangle source = new Rectangle(tile.X * animation.TileWidth, tile.Y * animation.TileHeight, animation.TileWidth, animation.TileHeight);
Rectangle dest = new Rectangle(Round(position.X), Round(position.Y), animation.TileWidth, animation.TileHeight);
spriteBatch.Draw(animation.Texture, dest, source, Color.White, angle, new Vector2(animation.TileWidth / 2, animation.TileHeight / 2), effect, 0);
}
示例10: musicToggleButton
public musicToggleButton(String artName, Rectangle destinationRectangle, Rectangle sourceRectangle, Color color, float rotation,
Vector2 origin, SpriteEffects effects, float layerDepth, Game game)
: base(artName, destinationRectangle, sourceRectangle, color, rotation, origin, effects, layerDepth)
{
//Henter audiomanager fra game
_audioManager = (IManageAudio)(game.Services.GetService(typeof(IManageAudio)));
}
示例11: Animation
public Animation(Vector2 characterVelocity, TimeSpan timePerFrame, SpriteEffects effect, string[] sprites)
{
this.Sprites = sprites;
this.TimePerFrame = timePerFrame;
this.Effect = effect;
this.CharacterVelocity = characterVelocity;
}
示例12: BadGuy
//30sec ttl
/// <summary>
/// Super constructor for enemies. You must call it in subclasses
/// </summary>
/// <param name="_location">Screen location</param>
/// <param name="_pattern">Move pattern to use</param>
/// <param name="_scrollValue">Scroll value trigger</param>
/// <param name="flags">Flags to set on death</param>
/// <param name="flip">Type of flip</param>
/// <param name="scale">Sprite scaling (use Vector2.One if not necessary)</param>
/// <param name="speed">Speed of the enemy</param>
/// <param name="spriteSrc">Spritesheet rectangle selection</param>
/// <param name="_bonusDroppedOnDeath">Bonus the enemy will drop on death</param>
/// <param name="weapon">Enemy weapon</param>
protected BadGuy(Vector2 _location, Vector2 _scrollValue, Bonus _bonusDroppedOnDeath, MovePattern _pattern, String[] flags, SpriteEffects flip, Rectangle spriteSrc, Vector2 speed, Vector2 scale, Weapon weapon)
: base(_location, spriteSrc, speed, scale, 0.0f, 30000f)
{
this.dropOnDeath = _bonusDroppedOnDeath;
this.movePattern = _pattern;
this.scrollValue = _scrollValue;
this.Flags = flags;
if (_pattern != null)
{
bounce = false;
}
else
{
bounce = true;
}
this.onScreen = false;
this.rotation = 0.0f;
this.Flip = flip;
this.Weapon = weapon;
if (this.Weapon != null)
{
this.Weapon.Flip = flip;
}
this.Hitbox = new SquareHitbox(this);
this.Removable = true;
this.InfiniteMovePattern = false;
this.Difficulty = 0;
this.ttl = 120000;
this.FiringLocation = Vectors.ConvertPointToVector2(DstRect.Center);
}
示例13: DrawByCenter
public void DrawByCenter(SpriteBatch sb, Vector2 location, SpriteEffects effects, float layerDepth)
{
Rectangle source = atlas.getSourceRectangle(currentFrame);
Rectangle destination = new Rectangle((int)(location.X - (source.Width / 2)), (int)(location.Y - (source.Height / 2)), source.Width, source.Height);
sb.Draw(atlas.getTexture(), destination, source, Color.White, 0, Vector2.Zero, effects, layerDepth);
}
示例14: DrawArm
public void DrawArm(SpriteBatch spriteBatch, Vector2 Position, Vector2 Origin, SpriteEffects effect = SpriteEffects.None)
{
if (armAni.ContainsKey(State))
{
armAni[State].Draw(spriteBatch, Position, Origin, effect);
}
}
示例15: AnimatedSprite
public AnimatedSprite(iAnimatedSprite iAnimatedSprite)
{
this.iAnimatedSprite = iAnimatedSprite;
this.sourceRectangle = new Rectangle(0, 0, 32, 32);
this.effect = SpriteEffects.None;
this.pivot = new Vector2(16f, 16);
}