我正在将 OpenGL java 应用程序转换为 Objective-C。这是来自我的 java 构造函数的构造函数副本,该构造函数来自一个名为 AmbientMovement 的文件:
public class AmbientMovement {
private final float FPS;
private final Frame[] FRAMES;
private final int NUMBER_FRAMES;
private final float CYCLE;
private final Random RANDOM;
private int indexAmbient;
private float timeAmbient;
private float timeCurrent;
public AmbientMovement(Frame[] frames, float fps) {
this.FPS = fps;
this.FRAMES = frames;
this.NUMBER_FRAMES = frames.length;
Frame lastframe = frames[this.NUMBER_FRAMES - 1];
this.CYCLE = lastframe.getTime() + lastframe.getDuration();
this.RANDOM = new Random();
this.resetClock();
}
这是我尝试使用 iOS 6 和 X-Code 4.5 的 Objective-c 编写代码:
环境运动.h
#import "VA-Frame.h"
#import "VA-TRSet.h"
#import "VA-Morph.h"
#import "VA-Quaternion.h"
#import "math.h"
@interface VA_AmbientMovement : NSObject{
/* Private members */
@private {
@property float const* FPS;
@property int const* NUMBER_FRAMES;
@property float const* CYCLE;
@property int indexAmbient;
@property float timeAmbient;
@property float timeCurrent;
}
}
环境运动.m
#import "VA_AmbientMovement.h"
@implementation VA_AmbientMovement
/* Initialise the AmbientMovement constructor */
-(id)initAmbientMovement:(Frame[])frames AndFPS :(float)fps{
self=[super init];
if(self){
FPS = 0;
NUMBER_FRAMES = 0;
CYCLE = 0;
indexAmbient = 0;
timeAmbient = 0;
timeCurrent = 0;
Frame* frame = [[Frame alloc] initAmbientManager:frames AndFPS:fps];
TRSet* trset = [[TRSet alloc] initAmbientManager:frames AndFPS:fps];
Morph* morph = [[Morph alloc] initAmbientManager:frames AndFPS:fps];
Quaternion* quat = [[Quaternion alloc] initAmbientManager:frames AndFPS:fps];
}
return self;
};
-(id)init{
return [self initAmbientMovement:0 AndFPS: 0];
};
我感到困惑的主要事情之一是如何传递类类型的参数。在 java 中,这是通过“Frame[] 帧”完成的。我可以使用以下行“(Frame [])aframes”在objective-c中执行此操作还是我犯了错误?
非常感谢