Question about Canvas.setContent()
by Terry Greenlaw · in Torque Game Builder · 04/27/2005 (8:23 am) · 1 replies
In the code below, how does the fxSceneWindow2D object relate to the GuiChunkedBitMapCtrl? The syntax seems very strange to have an unnamed object declaration in the parameter block of a previous object. Does this just declare sceneWindow2D as a child of mainScreenGui?
The reason I'm asking is that for most of my stuff, I don't use any of the GUI controls. I tried to get rid of the GuiChunkedBitmapCtrl and just do a Canvas.setContent(sceneWindow2D). The initial display is correct, but the dirty rects aren't refreshed as on-screen objects move. Are fxSceneWindow2D objects valid parameters to Canvas.setContent() ? If so, is there a parameter exposed to script that tells the engine to clean up the dirty rects? Preferably, is there any way to just have fxSceneWindow2D objects passed to setContent() automagically do the right thing?
TIA,
-tieros
The reason I'm asking is that for most of my stuff, I don't use any of the GUI controls. I tried to get rid of the GuiChunkedBitmapCtrl and just do a Canvas.setContent(sceneWindow2D). The initial display is correct, but the dirty rects aren't refreshed as on-screen objects move. Are fxSceneWindow2D objects valid parameters to Canvas.setContent() ? If so, is there a parameter exposed to script that tells the engine to clean up the dirty rects? Preferably, is there any way to just have fxSceneWindow2D objects passed to setContent() automagically do the right thing?
function setupT2DScene()
{
new GuiChunkedBitmapCtrl(mainScreenGui) {
profile = "GuiContentProfile";
horizSizing = "width";
vertSizing = "height";
position = "0 0";
extent = "800 600";
minExtent = "8 8";
visible = "1";
bitmap = "./images/grass01";
useVariable = "0";
tile = "0";
new fxSceneWindow2D(sceneWindow2D) {
profile = "GuiContentProfile";
horizSizing = "width";
vertSizing = "height";
position = "0 0";
extent = "800 600";
minExtent = "8 8";
visible = "1";
lockMouse = "0";
};
};
Canvas.setContent(mainScreenGui);
Canvas.setCursor(DefaultCursor);
new fxSceneGraph2D(t2dSceneGraph);
sceneWindow2D.setSceneGraph( t2dSceneGraph );
sceneWindow2D.setCurrentCameraPosition( "0 0" SPC $x SPC $y );
}TIA,
-tieros
Associate Justin DuJardin
Default Studio Name
Firstly, it has been established as common practice to specify a chunked bitmap or something of the like as a base 'container' for controls on GUI's for the purpose of having a background for you GUI's, when you call setContent for the canvas the object you specify becomes the base for what the canvas renders, so having one that doesn't fit to the extents of your current view results in only part of the screen being rendered and you get artifacts of mouse movements and the like when you move outside of the rect of the content control. That is to say, when you specify a content control the canvas renders nothing above it or outside of it's bounds, hence the need for a canvas content to extend to the extents of the canvas.
Secondly, and hopefully this will answer your question about setting content to a sceneWindow, it is possible to specify a fxSceneWindow2D as the content of the canvas because it's class derives from GuiControl, which chunkedBitmap does as well, which is also what you pass to the setContent function of the canvas. I'm afraid I'm still a bit lost on what you mean by not refreshing dirty rects, perhaps if you were able to post a screen shot of what you're experiencing I'd be able to be of more assistance.
If you do happen to mean that it is not refreshing parts of the screen, that could be because your extents may not extend to the extremes of the visible screen, in which case the canvas would not render anything but that which is in the extents of your content control. I've looked into the code for both of the two controls and the only reason one would not render is that in the onRender of the sceneWindow2D it checks for a sceneGraph which from your script it looks like you're assigning one, so I don't really know what else to look at from your description.
Hope this helps,
-justin'