所以我得到的錯誤在一張從一本書上抄 接口定義後的代碼中定義了覆蓋方法。這是我似乎遇到問題的地方。試圖讓這個代碼工作,所以我可以繼續學習。
#import <Foundation/Foundation.h>
@interface Sprite : NSObject{
CGFloat x;
CGFloat y;
CGFloat r;
CGFloat g;
CGFloat b;
CGFloat alpha; //alpha value, for transparency
CGFloat speed; //speed of movement in pixels/frame
CGFloat angle; //angle of movement in degrees
CGFloat rotation; //rotation of our sprite in degrees about the center
CGFloat width;
CGFloat height;
CGFloat scale; //uniform scaling factor for size
int frame; //for animation
CGFloat cosTheta; //precomputed for speed
CGFloat sinTheta;
CGRect box; //our bounding box
BOOL render; //true when we're rendering
BOOL offScreen; //true when we're off the screen
BOOL wrap; //true if you want the motion to wrap the screen
}
@property (assign) BOOL wrap, render, offScreen;
@property (assign) CGFloat x, y, r, g, b, alpha;
@property (assign) CGFloat speed, angle, rotation;
@property (assign) CGFloat width, height, scale;
@property (assign) CGRect box;
@property (assign) int frame;
// THIS IS WHERE I'M GETTING THE ERROR
- (void) setRotation: (CGFloat) degrees
{
rotation = degrees * 3.141592/180.0;
}
-(CGFloat) rotation
{
return rotation*180.0/3.141592;
}
- (void) setAngle: (CGFloat) degrees
{
angle = degrees*3.141592/180.0;
cosTheta = cos(angle);
sinTheta = sin(angle);
}
- (CGFloat) angle
{
return angle*180.0/3.141592;
}
@end