From Clomosy Docs

Revision as of 15:12, 24 December 2024 by ClomosyAdmin (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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;
}



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.

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;
}

See Also