2014-10-22 83 views

回答

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"); 
    } 
} 
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半秒。如果你只是想改變實體的高度&寬度,你需要訪問它的圖形和混亂。