BGRASpriteAnimation

From Lazarus wiki
Revision as of 21:22, 18 July 2011 by Lainz (talk | contribs) (→‎Animation: typo)
Jump to navigationJump to search

English (en) español (es)

Overview

BGRASpriteAnimation is a graphic control developed with BGRABitmap library. Is part of BGRAControls package. This control is usefull to create animations from bitmap.

Beginning

Add a new BGRASpriteAnimation from "BGRA Controls" component tab.

The next step is load a "sprite". A sprite is a bitmap that contains all the frames of animation. To load a sprite select "BGRASpriteAnimation1". In the Object Inspector click on the property "Sprite (TBitmap)[...]". Load the sprite the same as you load any bitmap.

This is the sprite we will use to explain the component working:

bgraspriteanimation main sprite.png

We can say the sprite dimensions are 100x500 px. It has 5 frames, so each frame is 100x100 px.

The next step is tell the component that the sprite has 5 frames. To set the number of frames in the Object Inspector click on the property "SpriteCount" and set the value to 5.

Now you can run the application and see the resulting animation.

Animation

The animation properties are AnimInvert, AnimPosition, AnimRepeat, AnimRepeatLap, AnimSpeed & AnimStatic.

AnimInvert: By default the animation is played from AnimPosition to SpriteCount. If you set AnimInvert to True the animation will be played inversely, that is from the last frame to the first.

AnimPosition: The position of the frame in the animation.

AnimRepeat: The number of times the animation will be played. Set 0 for infinite.

AnimRepeatLap: The number of times the animation was played. If reach the same as AnimRepeat the animation will stop.

AnimSpeed: The speed in miliseconds betwen frames.

AnimStatic: Use to start & stop the animation.

Sprite

The sprite properties are Sprite, SpriteCount, SpriteFillOpacity, SpriteFlipMode, SpriteKeyColor, SpriteResampleFilter, SpriteResampleMode, SpriteRotation.

Sprite: A bitmap that contains all the frames of the animation.

SpriteCount: A number that indicates the amount of frames of the sprite.

The following properties are sprite modifications.

SpriteFillOpacity: The amount of opacity from 0 to 255.

SpriteFlipMode: Flip none, horizontal, vertical or both.

SpriteKeyColor: The color that will be replaced with transparency.

SpriteResampleFilter: The filter that will be used on resizing.

SpriteResampleMode: If you choose FineResample the selected resample filter will be used.

SpriteRotation: Rotation none, clockwise, counterclockwise.

Events

The following events are specific to animation.

OnLapChanged: This fires when AnimRepeatLap value has changed (by the animation or by the user).

OnLapChanging: This fires before changing AnimRepeatLap value by the animation.

OnPositionChanged: This fires when AnimPosition value has changed (by the animation or by the user).

OnPositionChanging: This fires before changing AnimPosition value by the animation.

The following events are specific to sprites.

OnRedrawAfter: This fires after applying the sprite modifications.

OnRedrawBefore: This fires before applying the sprite modifications.