flashpunk中的Animate / Tween图像大小

时间:2014-10-22 02:03:41

标签: actionscript-3 flash tween

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

2 个答案:

答案 0 :(得分:0)

您可能需要考虑使用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");
    }
}

答案 1 :(得分:0)

你可以使用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。如果你只想改变实体的高度和高度宽度,你需要访问它的图形并弄乱它。