I have a multi-device application made in Delphi-XE8, in it I have a rocket image ( TImage
) and other 2 arrows, I would like the rocket to move on the X axis of the screen (% ), but with the current code the user would have to press several times to change the position of that component.
Is there any method or event that is activated while the user is holding the finger by pressing the arrow button?
Here is 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 matters to me:
As you can see now I use the MouseDown event, however as I said, it requires the user to click several times to run.