Sign in Join
Wiki copytemporary

BGRASpriteAnimation: what changed

Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
11## Overview
22
33[[BGRASpriteAnimation]] is a graphic control developed with the [[BGRABitmap]] library. It is part of the [[BGRAControls]] package. This control is usefull to create animations from bitmaps.
44
55To use as replace of TImage just turn on the option 'AnimStatic' and you'll be able to load single images.
66
77## Beginning
88
99Add a new BGRASpriteAnimation from the "BGRA Controls" component tab.
1010
1111The next step is to load a "sprite". A sprite is a bitmap that contains all the frames of an animation. To load a sprite select "BGRASpriteAnimation1". In the Object Inspector click on the property "Sprite (TBitmap)\[...\]". Load the sprite the same way as you load any other bitmap.
1212
1313This is the sprite we will use to explain how the component works:
1414
15-<figure>
16-<img src="bgraspriteanimation_main_sprite.png" title="bgraspriteanimation_main_sprite.png" />
17-<figcaption>bgraspriteanimation_main_sprite.png</figcaption>
18-</figure>
15+![](/wiki-images/1/13/Bgraspriteanimation_main_sprite.png)
1916
2017We can say the sprite dimensions are 100x500 px. It has 5 frames, so each frame is 100x100 px.
2118
2219The next step is to 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.
2320
2421Now you can run the application and see the resulting animation.
2522
2623## Animation
2724
2825The animation properties are AnimInvert, AnimPosition, AnimRepeat, AnimRepeatLap, AnimSpeed & AnimStatic.
2926
3027**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.
3128
3229**AnimPosition:** The position of the frame in the animation.
3330
3431**AnimRepeat:** The number of times the animation will be played. Set 0 for infinite.
3532
3633**AnimRepeatLap:** The number of times the animation was played. If it reaches the value of AnimRepeat the animation will stop.
3734
3835**AnimSpeed:** The speed in milliseconds between frames.
3936
4037**AnimStatic:** Use to start & stop the animation.
4138
4239## Sprite
4340
4441The sprite properties are Sprite, SpriteCount, SpriteFillOpacity, SpriteFlipMode, SpriteKeyColor, SpriteResampleFilter, SpriteResampleMode, SpriteRotation.
4542
4643**Sprite:** A bitmap that contains all the frames of the animation.
4744
4845**SpriteCount:** A number that indicates the amount of frames of the sprite.
4946
5047The following properties are sprite modifications.
5148
5249**SpriteFillOpacity:** The amount of opacity from 0 to 255.
5350
5451**SpriteFlipMode:** Flip none, horizontal, vertical or both.
5552
5653**SpriteKeyColor:** The color that will be replaced with transparency.
5754
5855**SpriteResampleFilter:** The filter that will be used on resizing.
5956
6057**SpriteResampleMode:** If you choose FineResample the selected resample filter will be used.
6158
6259**SpriteRotation:** Rotation none, clockwise, counterclockwise.
6360
6461## Events
6562
6663OnRedrawBefore, OnRedrawAfter, OnPositionChanging, OnPositionChanged, OnLapChanging, OnLapChanged in that order.
6764
6865The following events are specific to sprites.
6966
7067**OnRedrawBefore:** This fires before applying the sprite modifications.
7168
7269**OnRedrawAfter:** This fires after applying the sprite modifications, but before applying resample.
7370
7471The following events are specific to animation.
7572
7673**OnPositionChanging:** This fires before the animation changes the AnimPosition value.
7774
7875**OnPositionChanged:** This fires when the AnimPosition value has changed (by the animation or by the user).
7976
8077**OnLapChanging:** This fires before the animation changes the AnimRepeatLap value.
8178
8279**OnLapChanged:** This fires when the AnimRepeatLap value has changed (by the animation or by the user).
8380
8481## How to Create Sprites?
8582
8683Most Graphics software (Gimp, Photoshop) can create Animations as Image Sequences. In Windows you can use IrfanView's (Freeware) panoramamode to Join these Images into a sprite. (Image\> Create Panorama Image…)
8784
8885## How to load images with mutiple rows?
8986
9087Check [this forum post](https://forum.lazarus.freepascal.org/index.php/topic,49164.msg355639.html#msg355639) project attachment.
9188
9289---
9390*From the Free Pascal wiki, page "BGRASpriteAnimation", as it stood on 2020-04-03 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*
9491Category: BGRAControls
9592Category: Components
9693Category: Graphics

Back to history