![]() |
| ||
|
|
Новости |
Поиск |
FAQ |
Статьи |
Книги |
Новости VCL
| | Форумы ЧАТ |
Орешник |
|
| |||
| |||
« предыдущая ветвь | форум | следующая ветвь »
помогите с объектом!
novai © (2008-09-10 13:56:00)не понимаю в чем ошибка
TStar = class(TObject)
timer:TTimer;
x,y, width, height:integer;
oldx, oldy:integer;
constructor Create;
destructor Destroy; override;
procedure OnTimerStar(Sender: TObject);не работает
procedure SetTo(x,y:integer);
procedure Draw ;
procedure Move;
end;
constructor TStar.Create;
begin
inherited Create;
x:=0; y:=0;
oldx:=x; oldy:=y;
width:=10;
height:=10;
Timer:=TTimer.Create(nil);
timer.Interval:=100;
timer.Enabled:=true;
timer.OnTimer:=OnTimerStar;
end;
Destructor TStar.Destroy;
begin
timer.Enabled:=false;
timer.Destroy;
inherited Destroy;
end;
procedure OnTimerStar(Sender: TObject);
begin
star.Move;
end;
procedure TStar.SetTo(x,y:integer);
begin
star.x:=x;
star.y:=y;
// star.oldx:=x;
// star.oldy:=y;
draw;
end;
procedure TStar.Draw;
begin
if (oldx<>x) or (oldy<>y) then
begin
PatBlt(scene.Canvas.Handle, oldx, oldy, Width, Height, WHITENESS);
oldx:=x;
oldy:=y;
end;
Scene.Canvas.Rectangle(x,y, x+width,y+height);
Scene.DrawScene;
end;
procedure TStar.Move;
begin
inc(star.y,10);
if star.y+star.height>=scene.Height then star.y:=0;
Draw;
end;
novai (2008-09-10 14:10:00) [21]там я заводил конечно переменную Star:Tstar;
Palladin (2008-09-10 14:09:00) [22]
> procedure OnTimerStar(Sender: TObject);
в ясли...
oldman (2008-09-10 14:08:00) [23]
> procedure OnTimerStar(Sender: TObject);
> begin
> star.Move;
> end;
>
> procedure TStar.Move;
> begin
> inc(star.y,10);
> if star.y+star.height>=scene.Height then star.y:=0;
> Draw;
> end;
А почему же не:
procedure OnTimerStar(Sender: TObject);
begin
inc(star.y,10);
if star.y+star.height>=scene.Height then star.y:=0;
Draw;
end;
???
Германн (2008-09-10 14:08:00) [24]
> то "движужуяся звезда будер рисоваться" еще очень не скоро.
Опередил, блин. Прям слово в слово :)
Германн (2008-09-10 14:07:00) [25]
> А что за таинственная переменная star?
> <Цитата>
>
> novai (10.09.08 14:05) [2]
>
> это type
Хм.
Юрий Зотов (2008-09-10 14:07:00) [26]> novai (10.09.08 14:05) [2]
Eсли star - это type, то "движужуяся звезда будер рисоваться" еще очень не скоро.
brother (2008-09-10 14:05:00) [27]> движужуяся
она будет что?))))
novai (2008-09-10 14:05:00) [28]это type ... когда все отлажу будер рисоваться движужуяся звезда...
Юрий Зотов (2008-09-10 14:03:00) [29]А что за таинственная переменная star?