Difference between revisions of "BGRASpriteAnimation"

From Lazarus wiki
Jump to navigationJump to search
(added sprite properties)
(added events)
Line 9: Line 9:
 
Explaining it will go from the most simple to more complex.
 
Explaining it will go from the most simple to more complex.
  
== Beginning ==
+
=== Beginning ===
  
 
Add a new BGRASpriteAnimation from "BGRA Controls" component tab.
 
Add a new BGRASpriteAnimation from "BGRA Controls" component tab.
Line 25: Line 25:
 
Now you can run the application and see the resulting animation.
 
Now you can run the application and see the resulting animation.
  
== Animation ==
+
=== Animation ===
  
 
The animation properties are AnimInvert, AnimPosition, AnimRepeat, AnimRepeatLap, AnimSpeed & AnimStatic.
 
The animation properties are AnimInvert, AnimPosition, AnimRepeat, AnimRepeatLap, AnimSpeed & AnimStatic.
Line 41: Line 41:
 
'''AnimStatic:''' Use to start & stop the animation.
 
'''AnimStatic:''' Use to start & stop the animation.
  
== Sprite ==
+
=== Sprite ===
  
 
The sprite properties are Sprite, SpriteCount, SpriteFillOpacity, SpriteFlipMode, SpriteKeyColor, SpriteResampleFilter, SpriteResampleMode, SpriteRotation.
 
The sprite properties are Sprite, SpriteCount, SpriteFillOpacity, SpriteFlipMode, SpriteKeyColor, SpriteResampleFilter, SpriteResampleMode, SpriteRotation.
Line 49: Line 49:
 
'''SpriteCount:''' A number that indicates the amount of frames of the sprite.
 
'''SpriteCount:''' A number that indicates the amount of frames of the sprite.
  
The following properties graphically modify the sprite.
+
The following properties are sprite modifications.
  
 
'''SpriteFillOpacity:''' The amount of opacity from 0 to 255.
 
'''SpriteFillOpacity:''' The amount of opacity from 0 to 255.
Line 62: Line 62:
  
 
'''SpriteRotation:''' Rotation none, clockwise, counterclockwise.
 
'''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.
  
 
[[Category: Graphics]] [[Category: Components]]
 
[[Category: Graphics]] [[Category: Components]]

Revision as of 22:18, 18 July 2011

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.

Usage

Explaining it will go from the most simple to more complex.

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.