From Clomosy Docs
No edit summary |
ClomosyAdmin (talk | contribs) No edit summary |
||
| (15 intermediate revisions by 2 users not shown) | |||
| Line 1: | Line 1: | ||
TclGameForm is a customized game form | TclGameForm is a customized game form. Unlike the TclForm class, it has the following features:<br> | ||
* Animation | |||
* Sound effects | |||
Before using these features, the form must be initialized.<br> | |||
An object of the TclGameForm class should be defined. | |||
<pre> | |||
var | |||
GameForm1:TclGameForm; | |||
</pre> | |||
The defined object must be created using the "Create" function.<br> | |||
<pre> | |||
{ | |||
GameForm1 = TCLGameForm.Create(Self); | |||
GameForm1.Run; | |||
} | |||
</pre> | |||
<div class="alert alert-ligth border border-3 border-warning rounded-5 p-4 shadow-sm" role="alert"> | |||
<strong>NOTE : AddGameAssetFromUrl</strong><br> It is a function used to download an asset from a URL and include it in your application. This function is used to download a file (for example, an image or a sound file(.wav)) from the internet and save it to the file system of the project being used. | |||
<div class="alert alert-warning" role="alert" data-bs-theme="light"> | |||
NOTE: To check if the image has been saved to the file, you can write Clomosy.AppFilesPath in the project to learn the file path extension. (Check the file on Windows.) | |||
</div> | |||
<b> Use of:</b> | |||
<pre> | |||
GameForm1.AddGameAssetFromUrl('https://www.clomosy.com/game/assets/Tank.png'); | |||
</pre> | |||
After adding the images, these images can be transferred to a component (TclProImage, TclImage). The transfer method is as follows:<br> | After adding the images, these images can be transferred to a component (TclProImage, TclImage). The transfer method is as follows:<br> | ||
<pre> | |||
Image1.clSetImage('Tank.png'); //Image1:TclIamge | |||
</pre> | |||
</div> | |||
<h2> Animation </h2> | |||
It is an effect created by displaying animated images and stationary objects as if they were moving. Essentially, a motion effect is created by quickly displaying a series of image or object frames.<br> | |||
<div class="alert alert-ligth border border-3 border-primary-subtle rounded-5 p-4 shadow-sm" role="alert"> | |||
<strong>NOTE:</strong><br> | |||
You can find the details of advanced animation features [[TclBitmapListAnimation|here]]. | |||
</div> | |||
The features and usage are provided in the table below.<br> | |||
<div class="table-responsive"> | |||
{| class="wikitable" style="border: 2px solid #c3d7e0" | |||
! style="background-color: #c3d7e0"| Feature !!style="background-color: #c3d7e0"| Use of !!style="background-color: #c3d7e0"| Definition | |||
|- | |||
|AnimationWidth ||GameForm1.AnimationWidth = 75; || The width of the animation is adjusted. | |||
|- | |||
|AnimationHeight ||GameForm1.AnimationHeight = 75; || The height of the animation is adjusted. | |||
|- | |||
|AnimationCount ||GameForm1.clAnimateBitmap.AnimationCount = 9; || The number of animations is specified by the number of parts into which the visual is divided. | |||
|- | |||
|AnimationRowCount ||GameForm1.clAnimateBitmap.AnimationRowCount = 3; || The number of animation rows is specified by the number of rows into which the visual is divided. | |||
|- | |||
|Delay ||GameForm1.clAnimateBitmap.Delay = 10; || The transition time between visuals is specified. | |||
|- | |||
|Duration ||GameForm1.clAnimateBitmap.Duration = 2; || The animation duration is adjusted. | |||
|- | |||
|clAnimation ||GameForm1.clAnimation(Random() * MyGameForm.clWidth, Random() * MyGameForm.clHeight, 20, 'Explosion.png'); || It is used to activate the animation on the screen. This property takes 4 parameters. The 1st parameter specifies the x position, the 2nd parameter specifies the y position, the 3rd parameter specifies the rotation angle, and the 4th parameter represents the animation image.<br> | |||
In the example, Random() is used to determine a random position. | |||
|} | |||
</div> | |||
<b>Example</b><br> | |||
<pre> | |||
var | |||
MyGameForm:TclGameForm; | MyGameForm:TclGameForm; | ||
BtnRandomFire:TclButton; | BtnRandomFire:TclButton; | ||
void BtnRandomFireClick; | |||
var | |||
i:Integer; | i:Integer; | ||
{ | |||
MyGameForm.AnimationWidth | MyGameForm.AnimationWidth = 75; | ||
MyGameForm.AnimationHeight | MyGameForm.AnimationHeight = 75; | ||
MyGameForm.clAnimateBitmap.AnimationCount | MyGameForm.clAnimateBitmap.AnimationCount =9; | ||
MyGameForm.clAnimateBitmap.AnimationRowCount | MyGameForm.clAnimateBitmap.AnimationRowCount=3; | ||
MyGameForm.clAnimateBitmap.Delay | MyGameForm.clAnimateBitmap.Delay = 10; | ||
MyGameForm.clAnimateBitmap.Duration | MyGameForm.clAnimateBitmap.Duration = 2; | ||
For i | For (i = 0 to 5) | ||
{ | |||
MyGameForm.clAnimateBitmap.Delay | MyGameForm.clAnimateBitmap.Delay = Random()*10; | ||
MyGameForm.clAnimation(Random() * | MyGameForm.clAnimation(Random() * MyGameForm.clWidth, Random() * MyGameForm.clHeight, 20, 'Explosion.png'); | ||
} | |||
} | |||
{ | |||
MyGameForm | MyGameForm = TclGameForm.Create(Self); | ||
MyGameForm.AddGameAssetFromUrl('https://www.clomosy.com/game/assets/Explosion.png'); | MyGameForm.AddGameAssetFromUrl('https://www.clomosy.com/game/assets/Explosion.png'); | ||
BtnRandomFire | BtnRandomFire= MyGameForm.AddNewButton(MyGameForm,'BtnRandomFire','RANDOM FIRE'); | ||
MyGameForm.AddNewEvent(BtnRandomFire,tbeOnClick,'BtnRandomFireClick'); | MyGameForm.AddNewEvent(BtnRandomFire,tbeOnClick,'BtnRandomFireClick'); | ||
BtnRandomFire.Align | BtnRandomFire.Align = alBottom; | ||
MyGameForm.Run; | MyGameForm.Run; | ||
} | |||
</pre> | |||
<h2> Sound Effects </h2> | |||
It is used when you want to trigger an event, alert messages, or anywhere you want to use sound in your applications.<br> | |||
To use the desired sound, it must be included in the project.<br> | |||
The features and usage are provided in the table below.<br> | |||
<div class="table-responsive"> | |||
{| class="wikitable" style="border: 2px solid #c3d7e0" | |||
! style="background-color: #c3d7e0"| Feature !!style="background-color: #c3d7e0"| Use of !!style="background-color: #c3d7e0"| Definition | |||
|- | |||
|RegisterSound ||SoundFile = GameForm1.RegisterSound('https://www.clomosy.com/game/assets/Fire.wav'); //soundFile:Integer;|| The audio file obtained from the URL should be saved to a variable. | |||
|- | |||
|SoundIsActive || GameForm1.SoundIsActive = True; || It is used to activate the sound effect. | |||
|- | |||
|PlayGameSound || GameForm1.PlayGameSound(SoundFile); || The sound activated on the application is made available for use. | |||
|} | |||
</div> | |||
<b>Example</b><br> | |||
<pre> | |||
var | |||
soundForm:TclGameForm; | |||
btnSound:TclButton; | |||
soundFile:Integer; | |||
void BtnSoundOnClick; | |||
{ | |||
soundForm.PlayGameSound(soundFile); | |||
} | |||
{ | |||
soundForm = TclGameForm.Create(Self); | |||
soundForm.AddGameAssetFromUrl('https://www.clomosy.com/game/assets/Fire.wav'); | |||
soundFile = soundForm.RegisterSound('Fire.wav'); | |||
soundForm.SoundIsActive=True; | |||
btnSound= soundForm.AddNewButton(soundForm,'btnSound','PLAY SOUND'); | |||
soundForm.AddNewEvent(btnSound,tbeOnClick,'BtnSoundOnClick'); | |||
btnSound.Align = alBottom; | |||
soundForm.Run; | |||
} | |||
</pre> | |||
<h2> See Also </h2> | |||
* [[Virtual Keyboard]] | |||
* [[TclForm]] | |||
{{#seo:|title=TclGameForm in Clomosy - Clomosy Docs}} | |||
{{#seo:|description=Explore TclGameForm in Clomosy for creating interactive game forms with animations, sound effects, and asset management for enhanced gaming experiences.}} | |||
Latest revision as of 15:12, 24 December 2024
TclGameForm is a customized game form. Unlike the TclForm class, it has the following features:
- Animation
- Sound effects
Before using these features, the form must be initialized.
An object of the TclGameForm class should be defined.
var GameForm1:TclGameForm;
The defined object must be created using the "Create" function.
{
GameForm1 = TCLGameForm.Create(Self);
GameForm1.Run;
}
NOTE : AddGameAssetFromUrl
It is a function used to download an asset from a URL and include it in your application. This function is used to download a file (for example, an image or a sound file(.wav)) from the internet and save it to the file system of the project being used.
NOTE: To check if the image has been saved to the file, you can write Clomosy.AppFilesPath in the project to learn the file path extension. (Check the file on Windows.)
Use of:
GameForm1.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:
Image1.clSetImage('Tank.png'); //Image1:TclIamge
Animation
It is an effect created by displaying animated images and stationary objects as if they were moving. Essentially, a motion effect is created by quickly displaying a series of image or object frames.
NOTE:
You can find the details of advanced animation features here.
The features and usage are provided in the table below.
| Feature | Use of | Definition |
|---|---|---|
| AnimationWidth | GameForm1.AnimationWidth = 75; | The width of the animation is adjusted. |
| AnimationHeight | GameForm1.AnimationHeight = 75; | The height of the animation is adjusted. |
| AnimationCount | GameForm1.clAnimateBitmap.AnimationCount = 9; | The number of animations is specified by the number of parts into which the visual is divided. |
| AnimationRowCount | GameForm1.clAnimateBitmap.AnimationRowCount = 3; | The number of animation rows is specified by the number of rows into which the visual is divided. |
| Delay | GameForm1.clAnimateBitmap.Delay = 10; | The transition time between visuals is specified. |
| Duration | GameForm1.clAnimateBitmap.Duration = 2; | The animation duration is adjusted. |
| clAnimation | GameForm1.clAnimation(Random() * MyGameForm.clWidth, Random() * MyGameForm.clHeight, 20, 'Explosion.png'); | It is used to activate the animation on the screen. This property takes 4 parameters. The 1st parameter specifies the x position, the 2nd parameter specifies the y position, the 3rd parameter specifies the rotation angle, and the 4th parameter represents the animation image. In the example, Random() is used to determine a random position. |
Example
var
MyGameForm:TclGameForm;
BtnRandomFire:TclButton;
void BtnRandomFireClick;
var
i:Integer;
{
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)
{
MyGameForm.clAnimateBitmap.Delay = Random()*10;
MyGameForm.clAnimation(Random() * MyGameForm.clWidth, Random() * MyGameForm.clHeight, 20, 'Explosion.png');
}
}
{
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;
}
Sound Effects
It is used when you want to trigger an event, alert messages, or anywhere you want to use sound in your applications.
To use the desired sound, it must be included in the project.
The features and usage are provided in the table below.
| Feature | Use of | Definition |
|---|---|---|
| RegisterSound | SoundFile = GameForm1.RegisterSound('https://www.clomosy.com/game/assets/Fire.wav'); //soundFile:Integer; | The audio file obtained from the URL should be saved to a variable. |
| SoundIsActive | GameForm1.SoundIsActive = True; | It is used to activate the sound effect. |
| PlayGameSound | GameForm1.PlayGameSound(SoundFile); | The sound activated on the application is made available for use. |
Example
var
soundForm:TclGameForm;
btnSound:TclButton;
soundFile:Integer;
void BtnSoundOnClick;
{
soundForm.PlayGameSound(soundFile);
}
{
soundForm = TclGameForm.Create(Self);
soundForm.AddGameAssetFromUrl('https://www.clomosy.com/game/assets/Fire.wav');
soundFile = soundForm.RegisterSound('Fire.wav');
soundForm.SoundIsActive=True;
btnSound= soundForm.AddNewButton(soundForm,'btnSound','PLAY SOUND');
soundForm.AddNewEvent(btnSound,tbeOnClick,'BtnSoundOnClick');
btnSound.Align = alBottom;
soundForm.Run;
}