Delphi的Firemonkey:上的三维视口在运行时创建多维数据集,从一个不同的单元多维、单元、不同、数据

由网友(丶谁与我闯荡)分享简介:我设计的3D扫雷艇。我想创建一个类来生成3D魔方(这将是由多个TCubes的,在一个立方体形状),这将是在一个单独的班级和单位的3D视口。我需要立方体运行时。我使用的是多维数组(TCube数组的数组的数组)。这是code我现在有它试图这样做。主机:单元mineMainForm;接口用途System.SysUtils,S...

我设计的3D扫雷艇。我想创建一个类来生成3D魔方(这将是由多个TCubes的,在一个立方体形状),这将是在一个单独的班级和单位的3D视口。我需要立方体运行时。我使用的是多维数组(TCube数组的数组的数组)。这是code我现在有它试图这样做。

主机:

 单元mineMainForm;

接口

用途
  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;

类型
  TForm2 =类(TForm3D)
    程序Form3DCreate(发件人:TObject的);
  私人
    {个人}声明
  上市
    {公开声明}
  结束;

变种
  窗体2:TForm2;
  控制器:TController;

履行

{$ R * .fmx}

程序TForm2.Form3DCreate(发件人:TObject的);
开始
Controller.create(Form2,10);
结束;

结束。
 

单元,其问题在于:

 单元mineControl;

接口

用途
 FMX.Forms,FMX.Objects3D,sysutils的;

类型
 tController =类
   私人
     cubeArray:数组[1..10,1..10,1..10] TCube的;
   上市
    构造函数创建(格式:TForm3D; cubeCount:整数);
 结束;

履行

{tController}

构造tController.create(格式:TForm3D; cubeCount:整数); // cubeCount最大10,分1
变种
  的x,y和z:整数;
开始
对于x:= 1到cubeCount做
 开始
  为Y:= 1 cubeCount做
   开始
    针对z:= 1到cubeCount做
     开始
       CubeArray [X,Y,Z] = TCube.Create(表);
        随着CubeArray [X,Y,Z]做
         开始
           可见:= TRUE;
           Position.X:= 0;
           Position.Y:= 0;
           Position.Z:= 0;
           家长:=表;
         结束;
        结束;
    结束;
   结束;
 结束;

结束。
 

我收到一个访问冲突错误,我尝试运行创建使用雷区作为AOwner。我怎么能解决这个问题,以便它工作,或者,如果这样做不行,我会怎么做呢?

我很新的编码(1年半的高中),并将AP preciate如果你以为我知道相当小。非常感谢。

错误:在地址00A0CFBB访问冲突模块mine3D_p.exe写地址00000008的

解决方案

这个问题是要调用

  Controller.create(Form2,10);
 
QtitanComponents Solution 2021.2 for C

而不是

 控制器:= TController.create(Form2,10);
 

I'm designing 3D minesweeper. I would like to create a class to generate the 3D Cube (which will be composed of multiple TCubes, in a cube shape), which will be in a seperate class and unit to the 3D Viewport. I need to make the Cube to runtime. I am using a Multidimensional array (Array of Array of Array of TCube). This is the code I currently have which attempts to do so

Main Unit:

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 in which the issue lies:

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.

I am receiving an Access violation error where I try to run the create using "mineField" as the AOwner. How could I fix this so it works, or if that would not work, how would I do it?

I am quite new to coding (1 1/2 years of high school) and would appreciate if you assume I know quite little. Thanks a lot.

Error: "Access Violation at address 00A0CFBB in module 'mine3D_p.exe'. Write of Address 00000008"

解决方案

The Issue is you are calling

Controller.create(Form2,10);

instead of

Controller := TController.create(Form2,10);

阅读全文

相关推荐

最新文章