Recent

Author Topic: Castle GE Castle2DControl  (Read 4609 times)

JasonLugg

  • Jr. Member
  • **
  • Posts: 67
Castle GE Castle2DControl
« on: March 05, 2018, 05:05:26 pm »
Hi All

Thx in advance.

I am new to the Castle Game Engine, but have compiled/installed all successfully.

I have put a Castle2DControl on a form and have successfully drawn an image to it.

When I move the image < in the Castle2DControlUpdate> the image moves as expected but does not erase the last position so I get a trail of images.

How do i clear the background? I have tried this:

Code: Pascal  [Select][+][-]
  1.  
Castle2DControl1.EraseBackground(Form1.Canvas.Handle);
Code: Pascal  [Select][+][-]
  1.  

But no joy? What do I have to do?


Eugene Loza

  • Hero Member
  • *****
  • Posts: 663
    • My games in Pascal
Re: Castle GE Castle2DControl
« Reply #1 on: March 05, 2018, 07:00:38 pm »
The simplest way to clear the screen is
Code: Pascal  [Select][+][-]
  1. uses
  2.   ...
  3.   CastleColors, CastleGLUtils;
  4.  
  5. ...
  6.  
  7. procedure TForm1.Castle2DControl1Render(Sender: TObject);
  8. begin
  9.   RenderContext.Clear([cbColor], Black); //<---------- this will clear the 2DControl to "Black" color
  10.   //(draw something)
  11. end;

You may also specify the custom color to clear the screen, just use
Code: Pascal  [Select][+][-]
  1. RenderContext.Clear([cbColor], Vector4(1,0.5,0,1));
for orange color (also replace CastleColors with CastleVectors in your "uses" section)
My FOSS games in FreePascal&CastleGameEngine: https://decoherence.itch.io/ (Sources: https://gitlab.com/EugeneLoza)

 

TinyPortal © 2005-2018