首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >如何做文字书写动画?

如何做文字书写动画?
EN

Stack Overflow用户
提问于 2015-08-24 04:06:41
回答 1查看 3.5K关注 0票数 18

我想创建像现实生活中一样的文字书写动画,如何在Android上实现?请帮帮忙。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-08-02 14:05:35

除了@Behnam Eskandari answer,你还可以使用Sprite动画。它体积小,速度快,在手机上不占用太多空间。它也很容易实现,你只需要制作你的精灵工作表。您可以看到examples here

要在Android上实现这一点,您可以使用this library。虽然它有一些限制,但它工作得很好。

下面是我如何使用它的代码。

代码语言:javascript
复制
Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.runningcat);
int width = bitmap.getWidth();
int height = bitmap.getHeight();

int frameWidth = width / 5;    //you have 5 columns
int frameHeight = height / 5;  //and 5 rows
int frameNum = 25;             //there would be 25 images


SpriteSheetDrawer spriteSheetDrawer = new SpriteSheetDrawer(
        bitmap,
        frameWidth,
        frameHeight,
        frameNum)
        .spriteLoop(true)
        .frequency(2);   //change it as per your need


DisplayObject displayObject = new DisplayObject();
displayObject
        .with(spriteSheetDrawer)
        .tween()
        .tweenLoop(true)
        .transform(0, 0) //I have changed it according to my need, you can also do this by changing these values
        .toX(4000, 0)    //this one too.
        .end();
//In actual example, it's set as animation starts from one end of the screen and goes till the other one.


FPSTextureView textureView = (FPSTextureView) findViewById(R.id.fpsAnimation);
textureView.addChild(displayObject).tickStart();

希望能有所帮助。

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32170971

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档