示例#1
0
 public void play(Animation animation)
 {
     if(getAnimation() != animation)
     {
         setAnimation(animation);
     }
     play();
 }
示例#2
0
 public AnimatedSprite(Texture texture, long frameTime)
 {
     _frameTime = frameTime;
     _texture = texture;
     _sprite = new Sprite(_texture);
     _isPaused = false;
     _animation = new Animation();
     Position = new Vector2f(0, 0);
 }
示例#3
0
文件: Actor.cs 项目: riordanp/panjin
        public void Initialize()
        {
            //To override any of the following, change the variable after calling this function in the constructor
            goldfish = new Font("./assets/goldfish.ttf");
            goldfish.GetTexture(8).Smooth = false;
            nameText = new Text(name, goldfish, 9);
            nameText.Color = Color.Black;
            nameText.Position = new Vector2f(position.X - ((nameText.GetLocalBounds().Width / 4) + 8), position.Y + 17);
            nameText.Style = Text.Styles.Regular;
            healthbarOuter = new RectangleShape(new Vector2f(nameText.GetLocalBounds().Width + 5, nameText.GetLocalBounds().Height + 3));
            healthbar = new RectangleShape(healthbarOuter);
            healthbar.Size = new Vector2f(healthbarOuter.Size.X - 2, healthbarOuter.Size.Y - 2);
            fullHealthPixels = (int)healthbar.Size.X;
            healthbar.FillColor = new Color(153, 255, 153, 170);
            healthbarOuter.FillColor = new Color(0, 0, 0, 120);
            
            orientation = Direction.Down;
            isMoving = false;

            activeWeapon = new Weapon();

            walkingUp = new Animation();
            walkingUp.addFrame(new IntRect(0, 0, 16, 18));
            walkingUp.addFrame(new IntRect(16, 0, 16, 18));
            walkingUp.addFrame(new IntRect(32, 0, 16, 18));

            walkingRight = new Animation();
            walkingRight.addFrame(new IntRect(0, 18, 16, 18));
            walkingRight.addFrame(new IntRect(16, 18, 16, 18));
            walkingRight.addFrame(new IntRect(32, 18, 16, 18));

            walkingDown = new Animation();
            walkingDown.addFrame(new IntRect(0, 18 * 2, 16, 18));
            walkingDown.addFrame(new IntRect(16, 18 * 2, 16, 18));
            walkingDown.addFrame(new IntRect(32, 18 * 2, 16, 18));

            walkingLeft = new Animation();
            walkingLeft.addFrame(new IntRect(0, 18 * 3, 16, 18));
            walkingLeft.addFrame(new IntRect(16, 18 * 3, 16, 18));
            walkingLeft.addFrame(new IntRect(32, 18 * 3, 16, 18));

            boundingbox = new IntRect((int)position.X, (int)position.Y, 16, 16);
        }
示例#4
0
 public void setAnimation(Animation animation)
 {
     _animation = animation;
     _currentFrame = 0;
     setFrame(_currentFrame);
 }