帧中的对象-pascal运动图片

威奇

我正在以对象对象为单位在学校项目上工作,并尝试制作水果机。我试图使转盘转动,我得到了这张照片:图标水果机到目前为止,我只显示第一个,但我试图使照片向上移动,以便将其他照片显示为好。这有可能吗?

编辑:图片框为100 * 100像素。图片为100 * 900像素。我希望图片移动,首先显示的像素从0到100,下一步是10到110,下一步是20到120,依此类推。

代码:

unit Unit1;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
  ExtCtrls, Crt;

type

  { TForm1 }

  TForm1 = class(TForm)
    Button1: TButton;
    Button10: TButton;
    Button11: TButton;
    Button12: TButton;
    Button13: TButton;
    Button14: TButton;
    Button15: TButton;
    Button16: TButton;
    Button17: TButton;
    Button18: TButton;
    Button2: TButton;
    Button3: TButton;
    Button4: TButton;
    Button5: TButton;
    Button6: TButton;
    Button7: TButton;
    Button8: TButton;
    Button9: TButton;
    Image1: TImage;
    Image2: TImage;
    Image3: TImage;
    Image4: TImage;
    Image5: TImage;
    Image6: TImage;
    Image7: TImage;
    Image8: TImage;
    Image9: TImage;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Timer1: TTimer;
    Timer2: TTimer;
    procedure Button18Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
    procedure Button5Click(Sender: TObject);
    procedure Button6Click(Sender: TObject);
    procedure Button7Click(Sender: TObject);
    procedure Button8Click(Sender: TObject);
    procedure Button9Click(Sender: TObject);
    procedure Button10Click(Sender: TObject);
    procedure Button11click(Sender: TObject);
    procedure Button12click(Sender: TObject);
    procedure Button13click(Sender: TObject);
    procedure Button14click(Sender: TObject);
    procedure Button15click(Sender: TObject);
    procedure Button16click(Sender: TObject);
    procedure Button17click(Sender: TObject);
    procedure Timer1StopTimer(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
    procedure Timer2Timer(Sender: TObject);
  private
    { private declarations }
  public
    { public declarations }
  end;

var
  Form1: TForm1;
  x1, x2, x3, x4, money: double;
  s1, s2, s3, s4, Smoney: string;
  meloen, pruim, citroen, banaan, zeven: TPicture;

implementation

{$R *.lfm}

{ TForm1 }

procedure TForm1.Button1Click(Sender: TObject);
begin
   s4:=label3.Caption;
  if s4='0' then label1.Caption:='Kies een inzet bedrag!'
  else
  begin
  Smoney:=label2.Caption;
  money:=StrToFloat(Smoney);

  x4:=StrToFloat(s4);
  if x4>money then label1.Caption:='Uw inzet is te hoog!'
  else
  begin
  money:=money-x4;
  Smoney:=FloatToStr(money);
  label2.Caption:=Smoney;
  image1.Picture.LoadFromFile('rol2.png');
  image2.Picture.LoadFromFile('rol2.png');
  image3.Picture.LoadFromFile('rol2.png');
  image4.Picture.LoadFromFile('rol1.png');
  image5.Picture.LoadFromFile('rol2.png');
  image6.Picture.LoadFromFile('rol3.png');
  image7.Picture.LoadFromFile('rol1.png');
  image8.Picture.LoadFromFile('rol2.png');
  image9.Picture.LoadFromFile('rol3.png');
  timer1.Enabled:=true;

  end;

  end;

end;

procedure TForm1.Button18Click(Sender: TObject);
begin
  label1.Caption:='';
  label2.Caption:='100';
  label3.Caption:='0';
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  label3.Caption:='1';
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
  label3.Caption:='2';
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
  label3.Caption:='3';
end;
procedure TForm1.Button5Click(Sender: TObject);
begin
  label3.Caption:='4';
end;
procedure TForm1.Button6Click(Sender: TObject);
begin
  label3.Caption:='5';
end;
procedure TForm1.Button7Click(Sender: TObject);
begin
  label3.Caption:='10';
end;
procedure TForm1.Button8Click(Sender: TObject);
begin
  label3.Caption:='20';
end;
procedure TForm1.Button9Click(Sender: TObject);
begin
  label3.Caption:='25';
end;
procedure TForm1.Button10Click(Sender: TObject);
begin
  label3.Caption:='50';
end;
procedure TForm1.Button11Click(Sender: TObject);
begin
  label3.Caption:='75';
end;
procedure TForm1.Button12Click(Sender: TObject);
begin
  label3.Caption:='100';
end;
procedure TForm1.Button13Click(Sender: TObject);
begin
  label3.Caption:='200';
end;
procedure TForm1.Button14Click(Sender: TObject);
begin
  label3.Caption:='250';
end;
procedure TForm1.Button15Click(Sender: TObject);
begin
  label3.Caption:='500';
end;
procedure TForm1.Button16Click(Sender: TObject);
begin
  label3.Caption:='750';
end;
procedure TForm1.Button17Click(Sender: TObject);
begin
  label3.Caption:='1000';
end;

procedure TForm1.Timer1StopTimer(Sender: TObject);
begin


end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
  x1:=random(2);
  x2:=random(5);
  x3:=random(5);
  if x1=1 then begin
     image1.Picture.LoadFromFile('kers.png');
     image4.Picture.LoadFromFile('meloen.png');
     image7.Picture.LoadFromFile('zeven.png');
     end;
  if x1=2 then begin
     image1.Picture.LoadFromFile('meloen.png');
     image4.Picture.LoadFromFile('zeven.png');
     image7.Picture.LoadFromFile('citroen.png');
  end;
  if x1=3 then begin
     image1.Picture.LoadFromFile('zeven.png');
     image4.Picture.LoadFromFile('citroen.png');
     image7.Picture.LoadFromFile('banaan.png');
  end;
  if x1=4 then begin
     image1.Picture.LoadFromFile('citroen.png');
     image4.Picture.LoadFromFile('banaan.png');
     image7.Picture.LoadFromFile('pruim.png');
       end;
  if x1=5 then begin
     image1.Picture.LoadFromFile('banaan.png');
     image4.Picture.LoadFromFile('pruim.png');
     image7.Picture.LoadFromFile('big.png');
       end;
  if x1=6 then begin
     image1.Picture.LoadFromFile('pruim.png');
     image4.Picture.LoadFromFile('big.png');
     image7.Picture.LoadFromFile('bar.png');
       end;
  if x1=7 then begin
     image1.Picture.LoadFromFile('big.png');
     image4.Picture.LoadFromFile('bar.png');
     image7.Picture.LoadFromFile('sinaas.png');
       end;
  if x1=8 then begin
     image1.Picture.LoadFromFile('bar.png');
     image4.Picture.LoadFromFile('sinaas.png');
     image7.Picture.LoadFromFile('kers.png');
       end;
  if x1=9 then begin
     image1.Picture.LoadFromFile('sinaas.png');
     image4.Picture.LoadFromFile('kers.png');
     image7.Picture.LoadFromFile('meloen.png');
       end;



  if x2=1 then begin
     image2.Picture.LoadFromFile('kers.png');
     image5.Picture.LoadFromFile('meloen.png');
     image8.Picture.LoadFromFile('zeven.png');
       end;
  if x2=2 then begin
     image2.Picture.LoadFromFile('meloen.png');
     image5.Picture.LoadFromFile('zeven.png');
     image8.Picture.LoadFromFile('citroen.png');
       end;
  if x2=3 then begin
     image2.Picture.LoadFromFile('zeven.png');
     image5.Picture.LoadFromFile('citroen.png');
     image8.Picture.LoadFromFile('banaan.png');
       end;
  if x2=4 then begin
     image2.Picture.LoadFromFile('citroen.png');
     image5.Picture.LoadFromFile('banaan.png');
     image8.Picture.LoadFromFile('pruim.png');
       end;
  if x2=5 then begin
     image2.Picture.LoadFromFile('banaan.png');
     image5.Picture.LoadFromFile('pruim.png');
     image8.Picture.LoadFromFile('big.png');
       end;
  if x2=6 then begin
     image2.Picture.LoadFromFile('pruim.png');
     image5.Picture.LoadFromFile('big.png');
     image8.Picture.LoadFromFile('bar.png');
       end;
  if x2=7 then begin
     image2.Picture.LoadFromFile('big.png');
     image5.Picture.LoadFromFile('bar.png');
     image8.Picture.LoadFromFile('sinaas.png');
       end;
  if x2=8 then begin
     image2.Picture.LoadFromFile('bar.png');
     image5.Picture.LoadFromFile('sinaas.png');
     image8.Picture.LoadFromFile('kers.png');
       end;
  if x2=9 then begin
     image2.Picture.LoadFromFile('sinaas.png');
     image5.Picture.LoadFromFile('kers.png');
     image8.Picture.LoadFromFile('meloen.png');
       end;



  if x3=1 then begin
     image3.Picture.LoadFromFile('kers.png');
     image6.Picture.LoadFromFile('meloen.png');
     image9.Picture.LoadFromFile('zeven.png');
       end;
  if x3=2 then begin
     image3.Picture.LoadFromFile('meloen.png');
     image6.Picture.LoadFromFile('zeven.png');
     image9.Picture.LoadFromFile('citroen.png');
       end;
  if x3=3 then begin
     image3.Picture.LoadFromFile('zeven.png');
     image6.Picture.LoadFromFile('citroen.png');
     image9.Picture.LoadFromFile('banaan.png');
       end;
  if x3=4 then begin
     image3.Picture.LoadFromFile('citroen.png');
     image6.Picture.LoadFromFile('banaan.png');
     image9.Picture.LoadFromFile('pruim.png');
       end;
  if x3=5 then begin
     image3.Picture.LoadFromFile('banaan.png');
     image6.Picture.LoadFromFile('pruim.png');
     image9.Picture.LoadFromFile('big.png');
       end;
  if x3=6 then begin
     image3.Picture.LoadFromFile('pruim.png');
     image6.Picture.LoadFromFile('big.png');
     image9.Picture.LoadFromFile('bar.png');
       end;
  if x3=7 then begin
     image3.Picture.LoadFromFile('big.png');
     image6.Picture.LoadFromFile('bar.png');
     image9.Picture.LoadFromFile('sinaas.png');
       end;
  if x3=8 then begin
     image3.Picture.LoadFromFile('bar.png');
     image6.Picture.LoadFromFile('sinaas.png');
     image9.Picture.LoadFromFile('kers.png');
       end;
  if x3=9 then begin
     image3.Picture.LoadFromFile('sinaas.png');
     image6.Picture.LoadFromFile('kers.png');
     image9.Picture.LoadFromFile('meloen.png');
       end;




  if (x1=x2) and (x2=x3) then
     begin
     x4:=x4*10;
     money:=StrToFloat(Smoney);
     money:=money+x4;
     Smoney:=FloatToStr(money);
     label2.caption:=Smoney;
     x4:=x4/4;
     end
  else if (x1=x2) xor (x2=x3) xor (x1=x3) then
     begin
     x4:=x4*3;
     money:=StrToFloat(Smoney);
     money:=money+x4;
     Smoney:=FloatToStr(money);
     label2.caption:=Smoney;
     x4:=x4/2;
     end;
  timer1.Enabled:=false;

end;

procedure TForm1.Timer2Timer(Sender: TObject);
var
  i:integer;
  y:double;
begin
 image1.Picture.LoadFromFile('rol.png');

end;

end.

代码

珍妮·格伯

您可以将100x900图像加载到TBitmap中,然后使用图像的Canvas属性和画布的CopyRect方法从位图中的任何矩形绘制到画布。例如,如果将位图加载到FFruit中,并且您将FPos用于位图中的行(例如,第三张图片将从200开始):

Image1.Canvas.CopyRect(Rect(0, 0, 100, 100), FFruit.Canvas, Rect(0, FPos, 100, FPos+100));

您可以在计时器事件中执行此操作,也可以在其中更新FPos。

对您当前发布的代码的一种批评:不要在计时器中调用LoadFromFile方法。一次将图像加载到TBitmap中,然后在计时器中分配它们。LoadFromFile需要大量磁盘读取和处理。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

帧中的对象-帕斯卡运动图片

来自分类Dev

android中对象的运动

来自分类Dev

从运动捕捉中主动提取帧

来自分类Dev

图片未正确显示在帧布局中

来自分类Dev

如何在成帧器运动中多次使用动画

来自分类Dev

退出反应帧运动中的动画不出现

来自分类Dev

在Inno Setup Pascal脚本中销毁对象

来自分类Dev

如何在GDScript中旋转运动对象以聚焦于另一个运动对象?

来自分类Dev

应用运动以对成帧器运动做出反应

来自分类Dev

是否可以在运动jpeg的同一帧中包含两个图像?

来自分类Dev

如何在pygame中停止将运动图像的每一帧渲染到Surface上?

来自分类Dev

是否可以在运动jpeg的同一帧中包含两个图像?

来自分类Dev

识别QTP中对象结构内的帧

来自分类Dev

注释python对象中的pandas数据帧

来自分类Dev

运动对象与ArrayList中不理想的Vector3比较

来自分类Dev

在Unity中以圆周运动控制/移动对象

来自分类Dev

计算对象pascal中字符串中的不同字符

来自分类Dev

有成帧器运动的孩子

来自分类Dev

成帧器运动的动画路线

来自分类Dev

如何过渡成帧器运动值?

来自分类Dev

成帧器运动不更新scrollYProgress

来自分类Dev

FFMPEG-内插帧或添加运动模糊

来自分类Dev

抽搐效果动画的运动对象

来自分类Dev

libgdx绘制运动对象的尾巴

来自分类Dev

沿运动方向旋转对象

来自分类Dev

将NULL对象转换为数据帧中的可用对象

来自分类Dev

Java中的矢量运动

来自分类Dev

pyglet中的平滑运动

来自分类Dev

在Pygame中自上而下的运动