我正在设计 3D 扫雷。我想创建一个类来生成 3D 立方体(它将由多个 TCube 组成,呈立方体形状),它将位于一个单独的类中,并与 3D 视口相结合。我需要使多维数据集运行时。我正在使用多维数组(Array of Array of Array of TCube)。这是我目前尝试这样做的代码
主机:
unit mineMainForm;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Rtti, System.Classes,
System.Variants, FMX.Types, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.Types3D,
FMX.Objects3D, mineControl;
type
TForm2 = class(TForm3D)
procedure Form3DCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
Controller : TController;
implementation
{$R *.fmx}
procedure TForm2.Form3DCreate(Sender: TObject);
begin
Controller.create(Form2,10);
end;
end.
问题所在单位:
unit mineControl;
interface
uses
FMX.Forms, FMX.Objects3D, sysutils;
Type
tController = class
private
cubeArray : Array[1..10,1..10,1..10] of TCube;
public
constructor create(Form : TForm3D; cubeCount :integer);
end;
implementation
{ tController }
constructor tController.create(Form: TForm3D; cubeCount: integer); //cubeCount Max 10, min 1
var
x, y, z : Integer;
begin
for x := 1 to cubeCount do
begin
for y := 1 to cubeCount do
begin
for z := 1 to cubeCount do
begin
CubeArray[x,y,z] := TCube.Create(Form);
With CubeArray[x,y,z] do
begin
Visible := True;
Position.X := 0;
Position.Y := 0;
Position.Z := 0;
Parent := Form;
end;
end;
end;
end;
end;
end.
我收到一个访问冲突错误,我尝试使用“mineField”作为 AOwner 运行创建。我怎样才能解决这个问题,让它工作,或者如果这不起作用,我该怎么做?
我对编码很陌生(高中 1 1/2 年),如果您认为我知之甚少,我将不胜感激。非常感谢。
错误:“模块'mine3D_p.exe'中地址00A0CFBB的访问冲突。写入地址00000008”