0
I have a multi-device application made in Delphi-XE8, in it I have an image (TImage
) of rocket and other 2 of arrows, would like the rocket moves on the x axis of the screen (Position.X
), but with the current code the user would have to press several times to change the position of this component.
Is there any method or Event that is activated while the user keeps his finger by pressing the arrow button?
Follow the code I currently have:
unit Game;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.Layouts,
FMX.ExtCtrls, FMX.Objects;
type
TForm1 = class(TForm)
ShipImage: TImage;
ImageRightArrow: TImage;
ImageLeftArrow: TImage;
procedure ImageLeftArrowMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Single);
procedure ImageRightArrowMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Single);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.fmx}
procedure TForm1.ImageRightArrowMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Single);
begin
ShipImage.Position.X := (ShipImage.Position.X + 10);
end;
procedure TForm1.ImageLeftArrowMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Single);
begin
ShipImage.Position.X := (ShipImage.Position.X - 10);
end;
end.
And an image of the part of Unit that I care about:
As you can see now I use the Mousedown event, but as I said, it requires the user to keep clicking several times to run.
You can put an example?
– Paz
edited with example
– Tiago Rodrigues
+1 I’ll see if it fits my problem tomorrow, but thank you already
– Paz