コード例 #1
0
        internal DeathEffect(Sprite _deadSprite, ParticleEmitter _particleEmitter, float sampleWidthPercent, float sampleHeightPercent)
            : base("DeathEffect", new Actor(new DummyAnimation()))
        {
            deadSprite      = _deadSprite;
            particleEmitter = _particleEmitter;

            particleEmitter.ZOrder = deadSprite.ZOrder;

            //Scale of Sprite
            scale = deadSprite.Scale;

            //Sprite Frame
            frame = deadSprite.GetAnimation();

            //Store frame width and height
            frameWidth  = (int)((float)frame.Width);
            frameHeight = (int)((float)frame.Height);

            //Region of Texture that the current frame is in
            imageRegion = new Rectangle((int)frame.StartPos.X, (int)frame.StartPos.Y, frameWidth, frameHeight);

            //Sprite Color Data as Array from Texture2D
            image = new Color[frameWidth * frameHeight];
            frame.Image.GetData <Color>(0, imageRegion, image, 0, frameHeight * frameWidth);

            //Top left position of image (copied from Sprite Draw Function)
            topLeftPosition = deadSprite.Pos - deadSprite.GetAnimation().AnimationPeg +
                              deadSprite.Center - deadSprite.Center * scale + //this places scaling in the correct spot (i think)
                              (deadSprite.Hflip ? frame.MirrorOffset * 2 : -frame.MirrorOffset);

            createParticles(sampleWidthPercent, sampleHeightPercent);
        }
コード例 #2
0
ファイル: HUD.cs プロジェクト: nemec/4Realms
            internal override void Draw(GameTime gameTime)
            {
                base.Draw(gameTime);

                This.Game.spriteBatch.Draw(background, new Rectangle(
                                               (int)Pos.X,
                                               (int)Pos.Y,
                                               (int)GetAnimation().Width,
                                               (int)GetAnimation().Height), Color.White);

                if (Player.ItemBag.Count > 0)
                {
                    for (int x = 0; x < Player.ItemBag.Count; x++)
                    {
                        Sprite icon = Player.ItemBag[x].Icon;
                        icon.Pos.X = Pos.X + itemSpacing.X + 1 +  // Initial alignment of 1px
                                     (x % itemsPerRow) * (icon.GetAnimation().Width + itemSpacing.X);
                        icon.Pos.Y = Pos.Y + itemSpacing.Y +
                                     (x / itemsPerRow) * (icon.GetAnimation().Height + itemSpacing.Y);
                        icon.Visible = true;
                        icon.Draw(gameTime);
                    }
                }
            }
コード例 #3
0
 internal void CenterOn(Sprite target)
 {
     Pos = target.Pos + target.GetAnimation().AnimationPeg - GetAnimation().AnimationPeg;
 }