/[hegemonie]/hegemonie/Model/MdlAnimation.m
ViewVC logotype

Diff of /hegemonie/Model/MdlAnimation.m

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by c-leo, Mon Jun 30 14:19:40 2003 UTC revision 1.2 by dam, Wed Aug 20 14:18:13 2003 UTC
# Line 22  Line 22 
22   */   */
23    
24  #include <Foundation/NSString.h>  #include <Foundation/NSString.h>
25    #include <Foundation/NSKeyValueCoding.h>
26    #include <Foundation/NSException.h>
27    
28  #include "Model/MdlAnimation.h"  #include "Model/MdlAnimation.h"
29    
30  @implementation MdlAnimation  @implementation MdlAnimation
31    
32    /**
33     * Allocates and initializes an animation using the content of the property
34     * list. The animation is also autoreleased.
35     */
36    + (id) animWithPropertyList: (NSDictionary *)propertyList
37    {
38      NSParameterAssert (propertyList);
39    
40      return AUTORELEASE([[self alloc] initWithPropertyList: propertyList]);
41    }
42    
43  /**  /**
44   *Constructor initialize the animation with personal parameters   * Initializes the animation with the given parameters.
45   */   */
46  - (id) initWithAnimationName: (NSString *)animationName  - (id) initWithStartFrame: (int)startFrame
47                         start: (unsigned)startFrame                   nbFrames: (int)nbFrames
48                            nb: (unsigned)nbFrames              loopingFrames: (int)loopingFrames
49                          loop: (unsigned)loopingFrames            framesPerSecond: (int)framesPerSecond
                        frame: (unsigned)framePerSecond  
50  {  {
51    self = [super init];    self = [super init];
52    if (self != nil)    if (self != nil)
53      {      {
54        _animationName = RETAIN(animationName);        [self setStartFrame: startFrame];
55        _startFrame = startFrame;        [self setNbFrames: nbFrames];
56        _nbFrames = nbFrames;        [self setLoopingFrames: loopingFrames];
57        _loopingFrames = loopingFrames;        [self setFramesPerSecond: framesPerSecond];
       _framePerSecond = framePerSecond;  
58      }      }
59        
60    return self;    return self;
61  }  }
62    
63  - (void) dealloc  /**
64     * Initializes the model with the content of the property list.
65     */
66    - (id) initWithPropertyList: (NSDictionary *)propertyList
67  {  {
68    RELEASE(_animationName);    NSParameterAssert (propertyList);
69    
70      self = [super init];
71      if (self != nil)
72        {
73          [self takeValuesFromDictionary: propertyList];
74        }
75        
76    [super dealloc];    return self;
77  }  }
78    
   
79  /**  /**
80   * Returns the name of the current animation   * Returns the number of the first frame in the current animation.
81   */   */
82  - (NSString *) name  - (unsigned) startFrame
83  {  {
84    return _animationName;    return _startFrame;
85  }  }
86    
87  /**  /**
88   * return the number of the first frame of the current animation   * Sets the number of the first frame in the current animation.
89     * The frame number must be positive.
90   */   */
91  - (unsigned) startFrame  - (void) setStartFrame: (int)startFrame
92  {  {
93    return _startFrame;    NSParameterAssert (startFrame >= 0);
94      
95      _startFrame = startFrame;
96  }  }
97    
98    
99  /**  /**
100   * return the number of frames of the current animation   * Returns the current animation number of frames.
101   */   */
102  - (unsigned) nbFrames  - (unsigned) nbFrames
103  {  {
# Line 81  Line 105 
105  }  }
106    
107  /**  /**
108   * Accessor return the animation loopingFrame   * Sets the current animation number of frames.
109     * The number must be strictly positivie.
110     */
111    - (void) setNbFrames: (int)nbFrames
112    {
113      NSParameterAssert (nbFrames > 0);
114      
115      _nbFrames = nbFrames;
116    }
117    
118    /**
119     * Returns the animation loopingFrame
120   */   */
121  - (unsigned) loopingFrames  - (unsigned) loopingFrames
122  {  {
# Line 89  Line 124 
124  }  }
125    
126  /**  /**
127   * return the number of frame per second of the current animation   * Sets the animation loopingFrame.
128     * The number must be positive.
129   */   */
130  - (unsigned) framePerSecond  - (void) setLoopingFrames: (int)loopingFrames
131  {  {
132    return _framePerSecond;    NSParameterAssert (loopingFrames >= 0);
133      
134      _loopingFrames = loopingFrames;
135  }  }
136    
137    /**
138     * Returns the current animation number of frame per second.
139     */
140    - (unsigned) framesPerSecond
141    {
142      return _framesPerSecond;
143    }
144    
145    /**
146     * Sets the current animation number of frames per second.
147     * The number must be stritcly positive.
148     */
149    - (void) setFramesPerSecond: (int)framesPerSecond
150    {
151      NSParameterAssert (framesPerSecond > 0);
152      
153      _framesPerSecond = framesPerSecond;
154    }
155    
156  @end  @end

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26