From Clomosy Docs
No edit summary |
No edit summary |
||
| Line 128: | Line 128: | ||
BtnRandomFire.Align := alBottom; | BtnRandomFire.Align := alBottom; | ||
MyGameForm.Run; | MyGameForm.Run; | ||
'''End;''' | |||
:<span style="color:blue">Activating the Vibration Feature.</span> | |||
TclDeviceManager class is used to activate the vibration feature of the device in games.<br> | |||
Let's define the variable first.<br> | |||
myDeviceManager:TclDeviceManager; | |||
Let's create the variable defined on this class to activate it on the form. | |||
myDeviceManager := TclDeviceManager.Create; | |||
Now we add the property "Vibrate" to our variable. This property takes a parameter. Time in milliseconds must be entered into this parameter. | |||
myDeviceManager.Vibrate(1000); | |||
'''Example:'''<br> | |||
'''Var''' | |||
MyForm:TclGameForm; | |||
DeviceMotionSensor:TClMotionSensor; | |||
GameTimer:TClTimer; | |||
BtnStartGame:TclButton; | |||
myDeviceManager:TclDeviceManager; | |||
durum : Boolean; | |||
'''Procedure''' BtnStartGameClick; | |||
'''begin''' | |||
myDeviceManager.Vibrate(1000); | |||
'''End;''' | |||
'''Begin''' | |||
MyForm := TclGameForm.Create(Self); | |||
MyForm.SetFormColor('#CBEDD5','#f5e884',clGVertical); | |||
myDeviceManager := TclDeviceManager.Create; | |||
BtnStartGame:= MyForm.AddNewButton(MyForm,'BtnStartGame','Vibrate'); | |||
BtnStartGame.Align := alBottom; | |||
BtnStartGame.Height:=100; | |||
BtnStartGame.StyledSettings := ssFamily; | |||
BtnStartGame.TextSettings.FontColor := clAlphaColor.clHexToColor('#FFFFFF'); | |||
MyForm.AddNewEvent(BtnStartGame,tbeOnClick,'BtnStartGameClick'); | |||
MyForm.Run; | |||
'''End;''' | '''End;''' | ||
Revision as of 07:53, 12 April 2023
TclGameForm is a customized game form design for Clomosy. Here you can use features such as animation and sound effects. Now, to create the form, it is necessary to define.
MyGameForm:TclGameForm;
Now we need to add and run the form before giving properties to the form.
begin MyGameForm := TclGameForm.Create(Self); ... MyGameForm.Run; End;
Documents taken from url addresses are added to the form with the "AddGameAssetFromUrl" parameter. For example; such as background and animation images, sound file.
MyForm.AddGameAssetFromUrl('https://www.clomosy.com/game/assets/Tank.png');
After adding the images, these images can be transferred to a component (TclProImage, TclImage). The transfer method is as follows:
ImgTank.clSetImage('Tank.png');
We can use animation and sound effects in TclGameForm.
- How to Animation?
It is making a movie by showing animated pictures and still objects as if they are moving. This is how we make the pictures added on Clomosy animated.
You can set the animation height and width on the form. For this:
MyGameForm.AnimationWidth := 75; MyGameForm.AnimationHeight := 75;
If you want to give the number of animations:
MyGameForm.clAnimateBitmap.AnimationCount :=9;
To adjust the number of animation lines:
MyGameForm.clAnimateBitmap.AnimationRowCount:=3;
You can set the animation delay time on the form.
MyGameForm.clAnimateBitmap.Delay := 10;
You can set the animation duration time on the form.
MyGameForm.clAnimateBitmap.Duration := 2;
Now the "clAnimation" parameter is used so that we can show the animation on our screen. This parameter takes 4 values. (x_position,y_position,integer_value, animation_document)
Random() is used below to set a random location.
MyGameForm.clAnimation(Random() * TForm(MyGameForm).ClientWidth, Random() * TForm(MyGameForm).ClientHeight, 20, 'Explosion.png');
Example:
var
MyGameForm:TclGameForm;
BtnRandomFire:TclButton;
Procedure BtnRandomFireClick;
var
i:Integer;
begin
MyGameForm.AnimationWidth := 75;
MyGameForm.AnimationHeight := 75;
MyGameForm.clAnimateBitmap.AnimationCount :=9;
MyGameForm.clAnimateBitmap.AnimationRowCount:=3;
MyGameForm.clAnimateBitmap.Delay := 10;
MyGameForm.clAnimateBitmap.Duration := 2;
For i:=0 to 5 do
Begin
MyGameForm.clAnimateBitmap.Delay := Random()*10;
MyGameForm.clAnimation(Random() * TForm(MyGameForm).ClientWidth, Random() * TForm(MyGameForm).ClientHeight, 20, 'Explosion.png');
End;
End;
begin
MyGameForm := TclGameForm.Create(Self);
MyGameForm.AddGameAssetFromUrl('https://www.clomosy.com/game/assets/Explosion.png');
BtnRandomFire:= MyGameForm.AddNewButton(MyGameForm,'BtnRandomFire','RANDOM FIRE');
MyGameForm.AddNewEvent(BtnRandomFire,tbeOnClick,'BtnRandomFireClick');
BtnRandomFire.Align := alBottom;
MyGameForm.Run;
End;
- How to Sound Effect?
You can include the sound effect in an event triggered within your applications, messages to alert, or wherever you want to use it.
We need to add the sound that we will use in the form to our project.
MyGameForm.AddGameAssetFromUrl('https://www.clomosy.com/game/assets/Fire.wav');
Then we record the sound in a variable with the "RegisterSound" parameter.
SndFire := MyGameForm.RegisterSound('Fire.wav');
To enable the sound effect to be heard, we need to activate it.
MyGameForm.SoundIsActive:=True;
We have activated the sound in our application by making all the definitions. Now to run this in the project:
MyGameForm.PlayGameSound(SndFire);
Example:
var
MyGameForm:TclGameForm;
BtnRandomFire:TclButton;
SndFire:Integer;
Procedure BtnRandomFireClick;
begin
MyGameForm.PlayGameSound(SndFire);
End;
begin
MyGameForm := TclGameForm.Create(Self);
MyGameForm.AddGameAssetFromUrl('https://www.clomosy.com/game/assets/Fire.wav');
SndFire := MyGameForm.RegisterSound('Fire.wav');
MyGameForm.SoundIsActive:=True;
BtnRandomFire:= MyGameForm.AddNewButton(MyGameForm,'BtnRandomFire','RANDOM FIRE');
MyGameForm.AddNewEvent(BtnRandomFire,tbeOnClick,'BtnRandomFireClick');
BtnRandomFire.Align := alBottom;
MyGameForm.Run;
End;
- Activating the Vibration Feature.
TclDeviceManager class is used to activate the vibration feature of the device in games.
Let's define the variable first.
myDeviceManager:TclDeviceManager;
Let's create the variable defined on this class to activate it on the form.
myDeviceManager := TclDeviceManager.Create;
Now we add the property "Vibrate" to our variable. This property takes a parameter. Time in milliseconds must be entered into this parameter.
myDeviceManager.Vibrate(1000);
Example:
Var
MyForm:TclGameForm;
DeviceMotionSensor:TClMotionSensor;
GameTimer:TClTimer;
BtnStartGame:TclButton;
myDeviceManager:TclDeviceManager;
durum : Boolean;
Procedure BtnStartGameClick;
begin
myDeviceManager.Vibrate(1000);
End;
Begin
MyForm := TclGameForm.Create(Self);
MyForm.SetFormColor('#CBEDD5','#f5e884',clGVertical);
myDeviceManager := TclDeviceManager.Create;
BtnStartGame:= MyForm.AddNewButton(MyForm,'BtnStartGame','Vibrate');
BtnStartGame.Align := alBottom;
BtnStartGame.Height:=100;
BtnStartGame.StyledSettings := ssFamily;
BtnStartGame.TextSettings.FontColor := clAlphaColor.clHexToColor('#FFFFFF');
MyForm.AddNewEvent(BtnStartGame,tbeOnClick,'BtnStartGameClick');
MyForm.Run;
End;