我想创建像现实生活中一样的文字书写动画,如何在Android上实现?请帮帮忙。
发布于 2017-08-02 14:05:35
除了@Behnam Eskandari answer,你还可以使用Sprite
动画。它体积小,速度快,在手机上不占用太多空间。它也很容易实现,你只需要制作你的精灵工作表。您可以看到examples here。
要在Android
上实现这一点,您可以使用this library。虽然它有一些限制,但它工作得很好。
下面是我如何使用它的代码。
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();
希望能有所帮助。
https://stackoverflow.com/questions/32170971
复制相似问题