私はこれができるようにしたかった:
vec2 pos(1,5);
myActor.position = [Coord positionFrom: pos ];
私の構造を使用する:
typedef float32 float;
struct vec2 {
vec2(float32 xx, float32 yy) {
x = xx;
y = yy;
}
float32 x, y;
};
Coord.h
@interface Coord : NSObject {
}
+(CGPoint) positionFrom: (vec2) pos;
+(CGPoint) positionFromAngle: (float32) angle;
Coord.mm
#import "Coord.h"
@implementation Coord
+(CGPoint) positionFrom:(vec2) pos {
return CGPointMake( pos.x * 32, pos.y * 32);
}
+(CGPoint) positionFromAngle:(float32) angle {
return CGPointMake( cos(angle) * 32, cos(angle) * 32);
}
@end
しかし、これらのエラーが発生します(Coord.hのpositionFrom行):
Expected ')' before 'vec2'
Expected ')' before 'float32'