【问题标题】:Animate/Tween image size in flashpunkflashpunk 中的动画/补间图像大小
【发布时间】:2014-10-22 02:03:40
【问题描述】:

所以我是 FlashPunk 库的新手,不知道如何调整图像大小? 例如,如何将图像的高度值从实际尺寸设置为 0?

【问题讨论】:

    标签: actionscript-3 flash tween


    【解决方案1】:

    您可能需要考虑使用spritemap

    example from flashgamedojo:

    import net.flashpunk.Entity;
    import net.flashpunk.graphics.Text;
    
    public class AnimatedEntity extends Entity{
        // Embed the animation image.
        [Embed(source = 'my_animated_character.png'] private const MY_ANIM:Class;
    
        protected var animatedSprite:Spritemap = new Spritemap(MY_ANIM,16,16);
        public function AnimatedEntity () {
    
            // You pass in the source image and the height and width of each frame of the animation.
            animatedSprite = new Spritemap(MY_ANIM, 16, 16);
    
            // Let's set our Entity's graphic to our new Spritemap, dawg.
            graphic = animatedSprite;
    
            // Now, you can add animations to your Spritemap!
            // You name the animation, pass in an array consisting of the frame numbers, and the frame rate (milliseconds per frame).
            animatedSprite.add("running", [0, 1, 2, 3], 50);
    
            // It's totally cool to repeat frames, too! Out of order is nuts, but also okay.
            animatedSprite.add("falling", [4, 4, 4, 5, 1], 50);
    
            // Now, you just play your animation like so:
            animatedSprite.play("running");
        }
    }
    

    【讨论】:

      【解决方案2】:

      你可以像这样使用 Flashpunk 的 VarTween 类来做到这一点:

      var image:Image = (Image)(goombaEntity.graphic);
      var sizeTween:VarTween = new VarTween();
      sizeTween.tween(image, "height", 0, 0.5);
      thisWorld.addTween(sizeTween, true);
      

      这将使实体的高度在半秒内从全高变为 0。如果您只想更改实体的高度和宽度,则需要访问其图形并搞砸。

      【讨论】:

        猜你喜欢
        • 2015-06-16
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-05-23
        • 1970-01-01
        • 2021-11-14
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多