home *** CD-ROM | disk | FTP | other *** search
-
- /********************************************
- **** Animation Class Library V1.0 © 1994 Yves Schmid & Alia Development
- ****
- **** Anim.h
- ****
- **** Created: 13 May 1994
- **** Modified: 02 September 1994
- **** Version: 0
- **** Compatible: C++, Mac System 7
- ****
- **** Description: Definitions for the Anim class.
- ****
- **** Anim is a child class of the AnimCObject class.
- ****
- *******************/
-
-
- #ifndef Anim_H
- #define Anim_H
-
-
- #include "AnimCObject.h"
- #include "AnimFrame.h"
-
- struct AnimFrameDef;
- class AnimBase;
-
- class Anim: public AnimCObject
- {
-
- //***********************************************************
- //.............. P U B L I C M E T H O D S.................
-
- public:
-
- // Anim should be linked to a supervisor (AnimBase, Anim, AnimMask,...)
-
- Anim(AnimSupervisor *base);
- Anim(AnimSupervisor *base, AnimFrameDef *def); // An array of AnimFrameDef
-
- Anim(AnimSupervisor *base, AnimGfx *gfx); // Builds a one frame object
- Anim(AnimSupervisor *base, long resID);
-
-
- ~Anim(void);
-
-
- void findmaxsize(short *width, short *height) const; // Finds the maximum pixels size of the
- // current sequence. Checks all frames.
- // You can pass NULL pointers.
-
- void findmaxsize(long sequence, short *width, short *height) const;
- // Same method but you can
- // specify the sequence.
-
- void findmaxsizeseq(short *width, short *height) const;
- // Same method but does the job
- // for all sequences.
-
-
- void findcursize(short *width, short *height); // Finds the maximum pixels size of the
- // current frame. If there is no
- // current frame returns 0.
- // You can pass NULL pointers.
-
- void findcurrect(Rect *rect); // Finds the visual rect of the current frame.
-
-
- void arrangeframes(long sequence, // Arranges the frames
- short horizontalcmd, // of a sequence. This method centers
- short verticalcmd, // or aligns frames on x and/or y axix.
- short baseoffsetx =0, // See arrange cmds.
- short baseoffsety =0); // Base offsets may be used to
- // specify a global offset relative
- // the Anim position.
-
- void arrangeframesall(short horizontalcmd, // Same as "arrangeframes" but
- short verticalcmd, // for all sequences.
- short baseoffsetx =0,
- short baseoffsety =0);
-
- void arrange_moveframeoffsets(long sequence, // Adds a value to all frames
- short addoffsetx, // offsets for a specified
- short addoffsety); // sequence.
-
- void arrange_moveframeoffsetsall(short addoffsetx, // Same as "arrange_moveframeoffsets"
- short addoffsety); // but for all sequences.
-
-
- // Does for each frames: adds or substracts the size of the frame to the offset of the
- // frame. Horizontal and vertical should be equal to -1, 0 or 1. If -1 substracts, if
- // 0 does nothing, if 1 adds.
-
- void arrange_movehandlepoint(long sequence,
- short horizontal, short vertical);
-
- // Same as "arrange_movehandlepoint" but for all sequences
- void arrange_movehandlepointall(short horizontal, short vertical);
-
-
- // Sets/gets animation flags. See anim flags.
- inline unsigned short getanimflags(void) const {return animflags;}
- inline void setanimflags(const unsigned short anfl) {animflags = anfl;}
-
-
- // Changes the state of the frame counter
-
- inline void clearcounter(void) {framecounter = 0;}
- inline short getcounter(void) const {return framecounter;}
- inline void setcounter(const short c) {framecounter = c;}
-
-
- void setsequence(long a, Boolean resetframepos =TRUE); // Sets the current sequence
- void setnsequences(long n); // Specifies the number of sequences
-
- inline long getnsequences(void) const {return getnentry()-1;} // Number of seq.
- inline long getcurrentsequence(void) const {return currentsequence-1;} // Current seq.
- // number
-
- void addframe(short sequence, AnimFrame *frame); // Adds an AnimFrame to a sequence
- void addframe(short sequence, AnimFrame *frame, long pos); // Allows you to specify
- // where the frame should be
- // inserted
-
- virtual AnimFrame *newframe(short sequence); // Creates a frame, adds it and returns it
- virtual AnimFrame *newframe(short sequence, long pos); // Allows you to specify
- // where the frame should be
- // inserted
-
- AnimFrame *getcurrentframe(void); // Returns current frame or NULL if there is no frame
- long getcurrentframepos(void); // Returns current frame position or ~0 if there is no frame
- void setcurrentframe(long framepos); // Sets the current frame
- inline CoreList *getframelist(long seq) {return getentry(seq+1);} // Returns the
- // list of frames
- // for a specified
- // sequence
-
- inline AnimFrame *getfirstframe(long seq) {return (AnimFrame*)getentry(seq+1)->getfirst();}
- // Returns the first
- // frame of a specified
- // entry.
-
- //***********************************************************
-
- //..........................................................
- // You should not call the following methods!
-
-
- virtual void getcollisionmask(BitMap **b, unsigned long **lmask, Rect *);
- virtual Boolean mustbemasked(void) const;
-
- Boolean draw(short basex =0, short basey =0);
-
- //..........................................................
-
-
- protected:
-
- long currentsequence;
-
-
- virtual void initonecontrol(AnimControl *);
-
-
- virtual Boolean processonecontrol(AnimControl *);
-
- virtual void receivecmd(long cmd, void *info);
-
- void process_submasking(AnimBase *base, Rect *maskrect);
-
- private:
-
- short framecounter;
- AnimFrame *currentframe;
-
- long cwaitnframe;
- AnimFrame *cwframe;
-
- unsigned short animflags;
-
- void sortsubanims(void);
-
-
- };
-
- //................................
- // Animation flags
-
- #define ANF_REVERSE (1<<0) // If you set this flag, animation will be
- // reversed. (last frame -> first frame).
-
- #define ANF_PINGPONG (1<<1) // When the animation reachs the last frame
- // the ANF_REVERSE flag is setted and when
- // the first frame is reached the ANF_REVERSE
- // is unsetted. This is ping-pong animation.
-
-
- //................................
- // Cmds for the "arrangeframes" method
-
-
- #define arcmd_null 0 // Does not touch the frame position
- #define arcmd_center 1 // Centers frames
- #define arcmd_alignleft 2 // Aligns frames on left/top
- #define arcmd_aligntop 2
- #define arcmd_alignright 3 // Aligns frames on right/bottom
- #define arcmd_alignbottom 3
-
- //................................
- // You can construct a full animation object simply by passing an array
- // of AnimFrameDef.
- //
- // For example:
- //
- // ResID AnimGfx count offsets command
- // AnimFrameDef myanim[] = {{100, NULL, 1, 0,0, afcmd_frame}, // Adds frames
- // {100, NULL, 1, 0,0, afcmd_frame},
- // {100, NULL, 1, 0,0, afcmd_frame},
- // {100, NULL, 1, 0,0, afcmd_endsequence}, // The next frame starts
- // {100, NULL, 1, 0,0, afcmd_frame}, // a new sequence
- // {100, NULL, 1, 0,0, afcmd_frame},
- // {100, NULL, 1, 0,0, afcmd_endanim}}; // End of animation
-
-
- struct AnimFrameDef
- {
- long pictRESID; // The pict resource ID or...
- AnimGfx *animgfx; // an AnimGfx pointer
- short changecounter; // When must the anim go to next frame
- short offsetx,offsety; // Offset of the object (from the animation origin)
- short cmd; // A command
- };
-
-
- const short afcmd_frame = 1; // a new frame
- const short afcmd_endsequence = 2; // the next frame starts a new sequence
- const short afcmd_endanim = 0; // this is the last frame of the animation
-
- #endif
-
-