为什么会出现这样的运行错误“ undeclared identifier:"tetris_ctr;"?(100分)

  • 主题发起人 主题发起人 dreameast-1
  • 开始时间 开始时间
D

dreameast-1

Unregistered / Unconfirmed
GUEST, unregistred user!
我在程序中引用 "unit tetris;"单元中的类Ttetris_ctr,才出现了如上的错误。部分代码如下:
unit tetris
..........
..........
..........
Type
TTetris_ctr=CLASS(TTetris)
Private
Function CanMove(Dir:TDirection):Boolean;override;//用来判断是否可以移动

Public
// Constructor Create;
// Destructor Destroy;Virtual;
Procedure New;override; //清除

Procedure Move(Dir:TDirection);override;
end;
implementation..............

主程序代码如下:
unit maintetris;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,tetris, StdCtrls, mmsystem,ComCtrls, ExtCtrls, FFPBox, Menus,
ImgList, ToolWin, jpeg ,
Buttons, MPlayer ;

type
TForm1 = class(TForm)
Image1: TImage;
Timer1: TTimer;
MainMenu1: TMainMenu;
d1: TMenuItem;
Menu_Play: TMenuItem;
Menu_Pause: TMenuItem;
Menu_Go: TMenuItem;
N4: TMenuItem;
N5: TMenuItem;
N6: TMenuItem;
N7: TMenuItem;
N8: TMenuItem;
N9: TMenuItem;
N10: TMenuItem;
N11: TMenuItem;
N12: TMenuItem;
N13: TMenuItem;
N14: TMenuItem;
N15: TMenuItem;
N16: TMenuItem;
Panel1: TPanel;
Image2: TImage;
FlickerFreePaintBox1: TFlickerFreePaintBox;
ImageList1: TImageList;
CoolBar1: TCoolBar;
ToolBar1: TToolBar;
Btn_Play: TToolButton;
Btn_Pause: TToolButton;
Btn_Go: TToolButton;
ToolButton4: TToolButton;
PopupMenu1: TPopupMenu;
N17: TMenuItem;
N18: TMenuItem;
Label1: TLabel;
Label2: TLabel;
Label_Score: TLabel;
Label_Level: TLabel;
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure FlickerFreePaintBox1Paint(Sender: TObject; Canvas: TCanvas);
procedure Timer1Timer(Sender: TObject);
procedure FlickerFreePaintBox2Paint(Sender: TObject; Canvas: TCanvas);
procedure XP_Button1Click(Sender: TObject);
procedure XP_Button2Click(Sender: TObject);
procedure Menu_PlayClick(Sender: TObject);
procedure Btn_PauseClick(Sender: TObject);
procedure Btn_GoClick(Sender: TObject);
procedure N4Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
t:Ttetris;
t_ctr:Ttetris_ctr;????????总是通不过??????
Pic:Array[0..6] of TBitMap;
implementation

 
多贴电代码
 
什么意思啊?
 
主程序:unit maintetris;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, mmsystem,ComCtrls, ExtCtrls, FFPBox, Menus,
ImgList, ToolWin, jpeg ,
Buttons, MPlayer ,
tetris;
type
TForm1 = class(TForm)
Image1: TImage;
Timer1: TTimer;
MainMenu1: TMainMenu;
d1: TMenuItem;
Menu_Play: TMenuItem;
Menu_Pause: TMenuItem;
Menu_Go: TMenuItem;
N4: TMenuItem;
N5: TMenuItem;
N6: TMenuItem;
N7: TMenuItem;
N8: TMenuItem;
N9: TMenuItem;
N10: TMenuItem;
N11: TMenuItem;
N12: TMenuItem;
N13: TMenuItem;
N14: TMenuItem;
N15: TMenuItem;
N16: TMenuItem;
Panel1: TPanel;
Image2: TImage;
FlickerFreePaintBox1: TFlickerFreePaintBox;
ImageList1: TImageList;
CoolBar1: TCoolBar;
ToolBar1: TToolBar;
Btn_Play: TToolButton;
Btn_Pause: TToolButton;
Btn_Go: TToolButton;
ToolButton4: TToolButton;
PopupMenu1: TPopupMenu;
N17: TMenuItem;
N18: TMenuItem;
Label1: TLabel;
Label2: TLabel;
Label_Score: TLabel;
Label_Level: TLabel;
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure FlickerFreePaintBox1Paint(Sender: TObject; Canvas: TCanvas);
procedure Timer1Timer(Sender: TObject);
procedure FlickerFreePaintBox2Paint(Sender: TObject; Canvas: TCanvas);
procedure XP_Button1Click(Sender: TObject);
procedure XP_Button2Click(Sender: TObject);
procedure Menu_PlayClick(Sender: TObject);
procedure Btn_PauseClick(Sender: TObject);
procedure Btn_GoClick(Sender: TObject);
procedure N4Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
t:Ttetris;
t_ctr:Ttetris_ctr;!!!!!!!!!!!!出错行!!!!!!!!!!
Pic:Array[0..6] of TBitMap;
implementation


{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
var
i:integer;
s:String;
begin
t:=Ttetris.Create;
Randomize;
t.SheetType:=Random(7);
t.left:=10;
t.top:=10;
t.code:=10;
t.Play:=False;
t.X:=4;
t.Y:=0;
t.Dead:=False;
//t.StepTime:=100;
t.LevelBase:=1000;
Randomize;
t.NextSheetType:=Random(7);
for i:=0 to 6 do //初始画方块的图片
Begin
Pic:=TBitMap.Create;
s:=Inttostr(i+1)+'.bmp';
Pic.LoadFromFile(s);
End;

end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
t.Free;
t_ctr.free;
end;

procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if t.Play then
Begin
Case Key of
vk_Down:T.Move(drDown);
VK_Left: t_ctr.Move(drLeft);
VK_Right: t_ctr.Move(drRight);
// VK_Up:T.Move(drTurn);
End;
Label_Score.Caption:=Inttostr(t.Score); //得分
Label_Level.Caption:=Inttostr(t.Level); //等级
FlickerFreePaintBox1.Repaint; //主画面重画
//FlickerFreePaintBox2.Repaint; //预览窗口重画

ENd;
end;

procedure TForm1.FlickerFreePaintBox1Paint(Sender: TObject;
Canvas: TCanvas);
var
i,j,FXX,Fyy:integer;
Begin
Canvas.Brush.Color:=$00FF8080;
Canvas.FillRect(Rect(0,0,250,500));//画背景
Label_Score.Caption:=Inttostr(t.Score);//重画得分
Label_Level.Caption:=Inttostr(t.Level);//重画等级
if(t.Play) then//如果游戏进行中则重画
Begin
for i:=0 to 19 do //重画已经落下的方块
for j:=0 to 9 do
Begin
FXX:=i*25;
FYY:=j*25;
if t.ClassMap[i,j]<>0 then
Canvas.Draw(Fyy,Fxx,Pic[t.ClassMap[i,j]-1]);
End;
for i:=0 to 3 do //重画正在下落的方块
for j:=0 to 3 do
Begin
FXX:=(i+t.Y)*25;
FYY:=(j+t.X)*25;
if Sheet[t.SheetType,t.Sheet_Turn,i,j]=1 then
Canvas.Draw(Fyy,Fxx,Pic[t.SheetType]);
End;
end;
End;


procedure TForm1.Timer1Timer(Sender: TObject);
begin
if (not t.Dead)and(t.Play) then //如果游戏没有结束或没有暂停
Begin
t.Move(drDown);
FlickerFreePaintBox1.Repaint;
// FlickerFreePaintBox2.Repaint;
end;
end;

procedure TForm1.FlickerFreePaintBox2Paint(Sender: TObject;
Canvas: TCanvas);
var
i,j,FXX,Fyy:integer;
begin
Canvas.Brush.Color:=ClBlack;
Canvas.FillRect(Rect(0,0,125,100));
if t.Play then
Begin
for i:=0 to 3 do
for j:=0 to 3 do
Begin
FXX:=(i)*25;
FYY:=(j)*25;
if NextSheet[t.NextSheetType,i,j]=1 then
CAnvas.Draw(Fyy,Fxx,Pic[t.NextSheetType]);
End;
end;
end;

类单元为:::::::::
unit tetris;

interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,Math;

Type
TDirection=(drLeft,drRight,drDown);
TFigureWorksheet=array [0..3,0..3] of Byte;
TMap=Array[0..19,0..9] of byte;
Var
NextSheet:Array[0..6,0..3,0..3] of Byte=
(
((0,1,0,0),(1,1,1,0),(0,1,0,0),(1,1,1,0)),
((0,1,0,0),(1,1,1,0),(0,1,0,0),(1,1,1,0)),
((0,1,0,0),(1,1,1,0),(0,1,0,0),(1,1,1,0)),
((0,1,0,0),(1,1,1,0),(0,1,0,0),(1,1,1,0)),
((0,1,0,0),(1,1,1,0),(0,1,0,0),(1,1,1,0)),
((0,1,0,0),(1,1,1,0),(0,1,0,0),(1,1,1,0)),
((0,1,0,0),(1,1,1,0),(0,1,0,0),(1,1,1,0))
);
Sheet:Array[0..6,0..3,0..3,0..3] of Byte=
(
(((0,1,0,0),(1,1,1,0),(0,1,0,0),(1,1,1,0)),//"_|_"
((0,1,0,0),(1,1,1,0),(0,1,0,0),(1,1,1,0)),//"|-"
((0,1,0,0),(1,1,1,0),(0,1,0,0),(1,1,1,0)),//-|-"
((0,1,0,0),(1,1,1,0),(0,1,0,0),(1,1,1,0))),//"-|"
(((0,1,0,0),(1,1,1,0),(0,1,0,0),(1,1,1,0)),//"_|_"
((0,1,0,0),(1,1,1,0),(0,1,0,0),(1,1,1,0)),//"|-"
((0,1,0,0),(1,1,1,0),(0,1,0,0),(1,1,1,0)),//-|-"
((0,1,0,0),(1,1,1,0),(0,1,0,0),(1,1,1,0))),
(((0,1,0,0),(1,1,1,0),(0,1,0,0),(1,1,1,0)),//"_|_"
((0,1,0,0),(1,1,1,0),(0,1,0,0),(1,1,1,0)),//"|-"
((0,1,0,0),(1,1,1,0),(0,1,0,0),(1,1,1,0)),//-|-"
((0,1,0,0),(1,1,1,0),(0,1,0,0),(1,1,1,0))),
(((0,1,0,0),(1,1,1,0),(0,1,0,0),(1,1,1,0)),//"_|_"
((0,1,0,0),(1,1,1,0),(0,1,0,0),(1,1,1,0)),//"|-"
((0,1,0,0),(1,1,1,0),(0,1,0,0),(1,1,1,0)),//-|-"
((0,1,0,0),(1,1,1,0),(0,1,0,0),(1,1,1,0))),
(((0,1,0,0),(1,1,1,0),(0,1,0,0),(1,1,1,0)),//"_|_"
((0,1,0,0),(1,1,1,0),(0,1,0,0),(1,1,1,0)),//"|-"
((0,1,0,0),(1,1,1,0),(0,1,0,0),(1,1,1,0)),//-|-"
((0,1,0,0),(1,1,1,0),(0,1,0,0),(1,1,1,0))),
(((0,1,0,0),(1,1,1,0),(0,1,0,0),(1,1,1,0)),//"_|_"
((0,1,0,0),(1,1,1,0),(0,1,0,0),(1,1,1,0)),//"|-"
((0,1,0,0),(1,1,1,0),(0,1,0,0),(1,1,1,0)),//-|-"
((0,1,0,0),(1,1,1,0),(0,1,0,0),(1,1,1,0))),
(((0,1,0,0),(1,1,1,0),(0,1,0,0),(1,1,1,0)),//"_|_"
((0,1,0,0),(1,1,1,0),(0,1,0,0),(1,1,1,0)),//"|-"
((0,1,0,0),(1,1,1,0),(0,1,0,0),(1,1,1,0)),//-|-"
((0,1,0,0),(1,1,1,0),(0,1,0,0),(1,1,1,0)))
);

Type
TTetris=CLASS
Private
FLeft,FTop :Integer; //地图的偏移量
FX,FY :Integer; // 移动方块的位置
FXX,FYY :Integer;
FDirection :TDirection; // 方块移动的方向
FStepTime :Integer; // 方块移动的时间间隔
FCode :Integer; // 消去一行得分
FLevel :Integer; // 当前级别
FLevelBase :Integer; // 表示升级的标准
FScore :Integer; // 表示当前得分
FPlay :Boolean; // 表示游戏是否开始
FDead :Boolean; //表示游戏是否结束
FSheetType :Integer; // 方块的种类
FNextSheetType :Integer; // 下一个方块的种类
FSheet_Turn :Integer; // 方块的状态
FClassMap :TMap;
Function CanMove(Dir:TDirection):Boolean;virtual;//用来判断是否可以移动
Procedure EraseLine;virtual; //删除该删除的行
Public
// Constructor Create;
// Destructor Destroy;Virtual;
Procedure New;virtual; //清除

Procedure Move(Dir:TDirection);virtual;
property Left:Integer Read FLeft Write FLeft;
property Top:Integer Read FTop Write FTop;
property X:Integer Read FX Write FX;
property Y:Integer Read FY Write FY;
property XX:Integer Read FXX Write FXX;
property StepTime:Integer Read FStepTime Write FStepTime;
property Score:Integer Read FScore Write FScore;
property Code:Integer Read FCode Write FCode;
property Level:Integer Read FLevel Write FLevel;
property LevelBase:Integer Read FLevelBase Write FLevelBase;
property YY:Integer Read FYY Write FYY;
property Play:Boolean Read FPlay Write FPlay;
property Dead:Boolean Read FDead Write FDead;
property SheetType:Integer Read FSheetType Write FSheetType;
property NextSheetType:Integer Read FNextSheetType Write FNextSheetType;
property Sheet_Turn:Integer Read FSheet_Turn Write FSheet_Turn;
property Direction:TDirection Read FDirection Write FDirection;
property ClassMap :TMap Read FClassMap Write FClassMap;
end;



implementation
//判断是否可以移动
FunCtion TTetris.CanMove(Dir:TDirection):Boolean;
var
i,j,s:integer;
Begin
CanMove:=True;
//根据不同的方向来判断
Case Dir of
drLeft:
Begin
for i:=0 to 3 do
for j:=0 to 3 do
Begin
if(Sheet[FSheetType,FSheet_Turn,j,i]=1) then
if(Fx+i-1)<0 then //移动出界
Begin
CanMove:=False;
Exit;
End
else
Begin
if FClassMap[Fy+j,FX+i-1]<>0 then
Begin
CanMove:=False;
Exit;
End;
End;
ENd;
End;
drRight:
Begin
for i:=0 to 3 do
for j:=0 to 3 do
Begin
if(Sheet[FSheetType,FSheet_Turn,j,i]=1) then
if(Fx+i+1)>9 then //移动出界
Begin
CanMove:=False;
Exit;
End
else
Begin
if FClassMap[Fy+j,FX+i+1]<>0 then
Begin
CanMove:=False;
Exit;
End;
End;
ENd;
End;
drDown:
Begin
for i:=0 to 3 do
for j:=0 to 3 do
Begin
if(Sheet[FSheetType,FSheet_Turn,j,i]=1) then
if(FY+j-7)>19 then //移动出界
Begin
EraseLine;
CanMove:=False;
Exit;
End
else
Begin
if FClassMap[Fy+j-2,FX+i]<>0 then
Begin
EraseLine;
CanMove:=False;
Exit;
End;
End;
ENd;
End;
end;
End;
Procedure TTetris.New; //初始化,每次新游戏时调用该过程
var
i,j:Integer;
Begin
for j:=Fy to 19 do
For i:=0 to 9 do
FClassMap[j,i]:=0; //将地图清零
FScore:=0; //得分清零
FLevel:=0; //级别清零
Fx:=0; //坐标初始化
Fy:=0;
FDead:=False;
FPlay:=True;
//fsheet_turn:=2;
//Randomize; //产生第一个预览的方块类型
//FNextSheetType:=Random(7);
Randomize; //产生第一个下落的方块类型
FSheetType:=Random(7);
End;
Procedure TTetris.Move(Dir:TDirection);
var
i,j,s,Tempx,tempy:Integer;
Begin
Tempx:=Fx;
Tempy:=Fy;
if CanMove(Dir) then
Begin
Case Dir of
drLeft :Dec(FX);
drRight:Inc(FX);
drDown :Inc(FY);
//drTurn :FSheet_Turn:=(FSheet_Turn+1) mod 4;
End;
end;
End;

Procedure TTetris.EraseLine;
var
i,j,k,l,IsFull,LineCount,nowlevel:integer;
Begin
// FNewSheet:=True;
IsFull:=1;
LineCount:=0;
// For i:=0 to 3 do //将下落的方块合并到地图里
// for j:=0 to 3 do
// Begin
// if Sheet[FSheetType,FSheet_Turn,j,i]=1 then
// FCLassMap[FY+j,Fx+i]:=FSheetType+1;
// End;
for j:=Fy to 19 do //计算可以消去的行数
Begin
IsFull:=1;
For i:=0 to 9 do
Begin
if FClassMap[j,i]=0 then
Begin
IsFull:=0;
Break;
End;
end;
if (IsFull=1) then
Begin
Inc(LineCount);
//将上面的行全部下移
// for k:=j downto 1 do
// For l:=0 to 9 do
// FClassMap[k,l]:=FClassMap[k-1,l];
// for l:=0 to 9 do
// // FClassMap[0,l]:=0;
End;
End;
//处理得分
if (LineCount<>0) then
Begin
Case LineCount of
1: FScore:=FScore+FCode;
2: FScore:=FScore+FCode*3;
3: FScore:=FScore+FCode*5;
4: FScore:=FScore+FCode*9;
end;
nowlevel:=FLevelBase; //计算是否升级
for i:=0 to FLevel-2 do
nowlevel:=Round(nowlevel*1.5);
if(FScore>=nowlevel+FLevelBase*FLevel) then
Begin
Inc(FLevel);
FStepTime:=Round(FStepTime/1.3);
End;
End
else
Inc(FScore,4);
Fx:=0;
Fy:=0;
// Sleep(50);
//FSheetType:=FNextSheetType;
Randomize;
FSheet_Turn:=random(4);
Randomize;
FNextSheetType:=Random(7);
For i:=0 to 3 do //判断游戏是否结束
for j:=0 to 3 do
Begin
if Sheet[FSheetType,FSheet_Turn,j,i]=1 then
if FCLassMap[FY+j,Fx+i]<>0 then
Begin
FDead:=True;
FPlay:=False;
End;
End;

End;
end.
Type
TTetris_ctr=CLASS(TTetris)
Private
Function CanMove(Dir:TDirection):Boolean;override;//用来判断是否可以移动

Public
// Constructor Create;
// Destructor Destroy;Virtual;
Procedure New;override; //清除

Procedure Move(Dir:TDirection);override;
end;
implementation
//判断是否可以移动
FunCtion TTetris_ctr.CanMove(Dir:TDirection):Boolean;
var
i,j,s:integer;
Begin
CanMove:=True;
//根据不同的方向来判断
Case Dir of
drLeft:
Begin
for i:=0 to 3 do
for j:=0 to 3 do
Begin
if(Sheet[FSheetType,FSheet_Turn,j,i]=1) then
if(Fx+i-1)<0 then //移动出界
Begin
CanMove:=False;
Exit;
End
else
Begin
if FClassMap[Fy+j,FX+i-1]<>0 then
Begin
CanMove:=False;
Exit;
End;
End;
ENd;
End;
drRight:
Begin
for i:=0 to 3 do
for j:=0 to 3 do
Begin
if(Sheet[FSheetType,FSheet_Turn,j,i]=1) then
if(Fx+i+1)>9 then //移动出界
Begin
CanMove:=False;
Exit;
End
else
Begin
if FClassMap[Fy+j,FX+i+1]<>0 then
Begin
CanMove:=False;
Exit;
End;
End;
ENd;
End;

end;
End;
Procedure TTetris_ctr.New; //初始化,每次新游戏时调用该过程
var
i,j:Integer;
Begin
// for j:=Fy to 19 do
// For i:=0 to 9 do
// FClassMap[j,i]:=0; //将地图清零
//得分清零
//级别清零
Fx:=5; //坐标初始化
Fy:=16;
FDead:=False;
FPlay:=True;
//fsheet_turn:=2;
//Randomize; //产生第一个预览的方块类型
//FNextSheetType:=Random(7);
Randomize; //产生第一个下落的方块类型
FSheetType:=Random(1);
End;
Procedure TTetris_ctr.Move(Dir:TDirection);
var
i,j,s,Tempx,tempy:Integer;
Begin
Tempx:=Fx;
Tempy:=Fy;
if CanMove(Dir) then
Begin
Case Dir of
drLeft :Dec(FX);
drRight:Inc(FX);
// drDown :Inc(FY);
//drTurn :FSheet_Turn:=(FSheet_Turn+1) mod 4;
End;
end;
End;

end.

注::::::unit Ttetris单元中写了两个类,第一个为Ttetris,在主程序中可以引用,
第二个类为Ttetris_ctr ,在主程序中引用时出错(如上)。









 
把所有的类声明放在一起,也就是第一个TYPE后面!!!
 
[red]end.[/red] //end.后面的代码被忽略了....怎么会在[red] . [/red]之后呢
Type
TTetris_ctr=CLASS(TTetris)
Private
Function CanMove(Dir:TDirection):Boolean;override;//用来判断是否可以移动

Public
// Constructor Create;
 
to yaai:什么事类声明阿,这方面的知识我不太理解,求你给我举个例子好么?
 
unit demo;

interface

uses
.................
type
//声明都放在这下面
TLibFuncShowForm = function (const hWndApplication: HWND;
const hWnd: HWND;const pSID:PChar):Longint;stdCall;
TLibFuncCloseAll = function ():Longint;stdCall;
TLibInfo = class
LibName : string;
Haldle : THandle;
FuncName : string;
ShowForm : TLibFuncShowForm;
CloseAll : TLibFuncCloseAll;
end;
TFrmSaleInvoiceEdit = class(TForm)
Spl: TTeThemeSplitter;
PanLeft: TTeThemePanel;
PanLeftTop: TTeThemePanel;
//.........
end;
var
FrmSaleInvoiceEdit: TFrmSaleInvoiceEdit;

implementation

//实现部分的代码........
 
你把这个
Type
TTetris_ctr=CLASS(TTetris)
....

挪到这个的后面
Type
TTetris=CLASS

把下面这些挪到 end. 的前面

//判断是否可以移动
FunCtion TTetris_ctr.CanMove(Dir:TDirection):Boolean;
var
i,j,s:integer;
Begin
CanMove:=True;
//根据不同的方向来判断
Case Dir of
drLeft:
 
哦是这样啊!
 
谢谢你们,刚才的错误解决了,可是还有一个问题,在主程序里不能显示出第二个类(Ttetris_ctr)的对象,
你们看看程序。为什么不能啊! !!!一会我就给你们分!!!
 
t_ctr在那里Create的? 没Create就给释放了[:(]
 

我加进去了,可是还是不显示啊???

procedure TForm1.FormCreate(Sender: TObject);
var
i:integer;
s:String;
begin
t:=Ttetris.Create;

//Randomize;
//t.SheetType:=Random(7);
// t.left:=10;
//t.top:=10;
// t.code:=10;
t.Play:=False;

// t.X:=4;
//t.Y:=0;
t.Dead:=False;

//t.StepTime:=100;
t.LevelBase:=1000;
Randomize;
// t.NextSheetType:=Random(7);
for i:=0 to 6 do //初始画方块的图片
Begin
Pic:=TBitMap.Create;
s:=Inttostr(i+1)+'.bmp';
Pic.LoadFromFile(s);
End;
t_ctr:=Ttetris_ctr.Create;
t_ctr.play:=false;
t_ctr.play:=false;
for i:=0 to 6 do //初始画方块的图片
Begin
Pic:=TBitMap.Create;
s:=Inttostr(i+1)+'.bmp';
Pic.LoadFromFile(s);
End;

end;
 
你这样试试
procedure TForm1.FormCreate(Sender: TObject);
var
i:integer;
s:String;
begin
t:=Ttetris.Create; //改成t := Ttetris_ctr.Create看看, 目的是检测你的类有没有问题..
 
太长了,看不清楚,呵呵
 
to:tseug
照你的改了以后,第一个类的图形就不能显示了,到底是怎么回事啊?
 
Procedure TTetris_ctr.Move(Dir:TDirection);
var
i,j,s,Tempx,tempy:Integer;
Begin
//这里inherited ??
Tempx:=Fx;
Tempy:=Fy;
if CanMove(Dir) then
Begin
Case Dir of
drLeft :Dec(FX);
drRight:Inc(FX);
// drDown :Inc(FY);
//drTurn :FSheet_Turn:=(FSheet_Turn+1) mod 4;
End;
end;
End;
 
继承什么啊?
 
t_ctr:=Ttetris_ctr.Create(self);
/////
t_ctr.parent:=self;
///
t_ctr.visible:=true;
top,left,width,height等等
 
多人接受答案了。
 
后退
顶部