Forum > Games

Castle GE Castle2DControl

(1/1)

JasonLugg:
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  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} --- Castle2DControl1.EraseBackground(Form1.Canvas.Handle);

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} --- 
But no joy? What do I have to do?

Eugene Loza:
The simplest way to clear the screen is

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---uses  ...  CastleColors, CastleGLUtils; ... procedure TForm1.Castle2DControl1Render(Sender: TObject);begin  RenderContext.Clear([cbColor], Black); //<---------- this will clear the 2DControl to "Black" color  //(draw something)end;
You may also specify the custom color to clear the screen, just use

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---RenderContext.Clear([cbColor], Vector4(1,0.5,0,1));for orange color (also replace CastleColors with CastleVectors in your "uses" section)

Navigation

[0] Message Index

Go to full version