Flame 滚动精灵

Flame Scrolling Sprite 是一个 Flame 包,可轻松渲染滚动并根据速度永远重复的精灵。

这可以用来创建像滚动背景这样的东西,甚至可以创建场景,下面你可以看到一个例子

train

可以通过纯类ScrollingSpriteScrollingSpriteComponent来使用此包,它们实际上做同样的事情,但后者可以与Flame组件系统一起使用。

下面你可以找到类接收的所有参数

    //// Resource path of the sprite
    @required String spritePath,

    //// X and Y coordinate do be used to map the sprite
    double spriteX = 0.0,
    double spriteY = 0.0,

    //// Width and height of the mapped sprite
    double spriteWidth,
    double spriteHeight,

    //// Destination width and height of the sprite, in case you want to scale its original size
    double spriteDestWidth,
    double spriteDestHeight,

    //// Width and height of the total area where the sprites will scroll
    double width,
    double height,

    //// Vertical and horizontal speed of the scrolling speed in pixels per second
    this.verticalSpeed = 0.0,
    this.horizontalSpeed = 0.0,

    //// Since the sprites are scrolling on an endless manner, the sprite can be draw outside of its
    //// area, by default, the package already clips the area to prevent it from showing, use this flag to change
    //// this behaviour
    this.clipToDimensions = true,

在使用ScrollingSpriteComponent时,上面的相同参数也适用于它,此外,你还可以告知xy区域将放置的位置。

有关此运行的实时示例,请参阅 示例 文件夹。

GitHub

https://github.com/flame-engine/flame_scrolling_sprite