Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » about animation

This thread is locked; no one can reply to it. rss feed Print
about animation
keprast
Member #16,794
January 2018

Using a shear in Allegro.You just need to load a picture.
Then, use some, such as a timer.
Making animations.

But I believe there's a simple way to do it.

If have a weapon that a soldier can switch.
I need to use at least two pictures.

There's always a way to do it.Not just that.
-------------------------------------
Supplement the topic:
Subbitmap?
Can it make animations?
-------------------------------------
Of course, this is a discussion.
You can say how you understand.

Rodolfo Lam
Member #16,045
August 2015

Sir I honestly have difficulties understanding your questions, but generally animations are just that, a collection of images being shown in quick succession.

It can be as simple as you would like it to be, but still you need to code it on your own, as Allegro does not directly support doing animations automatically. It just provides the tools for you to do it.

You have sub-bitmaps, clipping rectangles, loading individual images and flipping through them, etc.

While a Timer could be used specifically for this, it may be Overkill having another time apart from your main tick timer, which could be used o drive the flipping of the animations.

Edgar Reynaldo
Member #8,592
May 2007
avatar

Animation is pretty easy if you keep it simple.

AnimationBase.cpp
AnimationBase.hpp

You can take out the EagleEventSource and ANIMATION_EVENT_DATA and WidgetMessage stuff if you remove these functions :
https://github.com/EdgarReynaldo/EagleGUI/blob/master/include/Eagle/AnimationBase.hpp#L54-L58

Then all you do is derive a class from AnimationBase and redefine the OnSetAnimationPercent function. And in there all you have to do is set a redraw flag, and pick what to draw based on the current frame number.

It would be very easy to port this to C as well.

Go to: