Game Development Community

Question regarding GuiBitmapButtonCtrl

by PGames · in Torque 3D Professional · 06/02/2010 (7:17 pm) · 5 replies

I created some GuiBitmapButtonCtrl in GuiDynamicCtrlArrayControl,GuiDynamicCtrlArrayControl in GuiPause,GuiPause is of the GuiControl type. When I try to execute Canvas.popDialog(GuiPause), it pauses for a while before executing,what exactly is the problem and how do I fix it?


If I put in some other type of control, such as GuiBitmapCtrl,then there's not problem. I did a test,when GuiBitmapButtonCtrl numbers above 30,no matter where I place it,if I execute Canvas.popDialog, it'll pause for 3-4 seconds. And this only goes up as I place more. Since I'm trying to create a items menu, this is a cause for concern.

Are there other ways of doing this?


Here's my code:
for(%i=0;%i<100;%i++)
     {
        %preview=new GuiControl()
        {

	     new GuiBitmapButtonCtrl()
             {
                 bitmap = "Image";
	     };
	
        };

	GuiDynamicCtrlArrayControl.add(%preview);
    }

If I add the "image" it'll cause the pause, if not, it won't. Is this due to the image type or how the engine loads the "image"?

#1
06/03/2010 (5:26 am)
By items menu do you mean an inventory?
#2
06/03/2010 (7:05 am)
Bitmap buttons use 4 images, one for each button state (normal, hover, depressed and inactive). It's probably trying to look for the different versions of "Image" for each button, slowing things down.
#3
06/03/2010 (7:12 am)
So how can this be fixed? Have all the states on one image?
#4
06/03/2010 (6:47 pm)
Actually, I cut it down to using just 1 image, and it's still having that pause. Anyone know what's causing this?
#5
06/04/2010 (9:44 am)
The GuiBitmapButtonCtrl does look for images with a special naming convention. Lets say you set bitmap to an image called imgButton, the control would then look for the following:
imgButton_n //Normal
imgButton_d //Depressed
imgButton_h //Highlighted
imgButton_i //Inactive

It will search for those first and then if it cannot find them then it will use just imgButton. Also consider the file size of your image(s) and make sure it is as small as possible and try to avoid having the control resize the image. If you set the extent of the control to 0,0 it will use the size of the image as its extent instead. Also look in your console log to see if there is a lot of console spam associated with trying to find the image. There might be a problem with T3D finding the path to the image.