Skip to content

SpriteSheet Animation

MasayukiSuda edited this page Feb 20, 2016 · 1 revision

#SpriteSheet Animation

  1. Create a SpriteSheetDrawer.
    Input SpriteSheet of Bitmap frameWidth, frameHeight, the number of frames of the sprite sheet to the constructor .

  2. To generate a DisplayObject, and Add it to the FPSTextureView or FPSSurfaceView or Container.
    If the Tween animation after with tween(), describe the parabolic() If you do the animation of the parabolic movement.

    SpriteSheetDrawer spriteSheetDrawer = new SpriteSheetDrawer(
            spriteBitmap, 
            frameWidth, 
            frameHeight, 
            frameNum);

    DisplayObject displayObject = new DisplayObject();
    displayObject
            .with(spriteSheetDrawer)
            .tween()
            .tweenLoop(true)
            .transform(-frameWidth, windowHeight / 2)
            .toX(3000, windowWidth)
            .end();

    mFPSTextureView
                .addChild(displayObject);

#Property

function detail
spriteLoopNum(int) If loopNum is 3, the Sprite Animation will loop 3 times.
dpSize(context) Draw a Bitmap in device-specific pixel density.
spriteLoop(boolean) If true, the Sprite Animation will loop when it reaches the last frame.
However, if the spriteLoopNum has been specified, this is ignored.
frequency(int) For example, if a ParabolicMotion with a frequency of 10 is placed on a Stage being updated at 40fps,
then the ParabolicMotion will advance roughly one frame every 4 ticks. This will not be exact,
because the time between each tick will vary slightly between frames.
This feature is dependent on the tick event object being passed into update.
spriteAnimationEndCallBack(AnimCallBack) Set function of dispatched when a spriteSheet animation reaches its ends.
spritePause(boolean) indicates whether to start the SpriteAnimation paused.
customFrameList(List) It will animation play in the frame number order of the value of this array.

Example

        // Sprite sheet frame until 0-26 playback
        List<Integer> list = new ArrayList<Integer>();
        for (int i = 0; i <= 26; i++) list.add(i);

        SpriteSheetDrawer spriteSheetDrawer = new SpriteSheetDrawer(spriteBitmap,
                frameWidth,
                frameHeight,
                frameNum)
                .dpSize(this)
                .customFrameList(list)
                .frequency(2)
                .spriteLoopNum(3)
                .spriteAnimationEndCallBack(new AnimCallBack() {
                    @Override
                    public void call() {
                        // call in three times sprite sheet animation has been executed .
                    }
                });


Clone this wiki locally