Problem with setBitmap
by SysRat · in Torque Game Builder · 04/26/2011 (5:38 am) · 2 replies
Hello.
I created a .gui file with GUI Builder tool.
Then I created "GuiControl" and "GuiBitmapButtonCtrl"(myGUI). After that I successfully attached my oldimage.png file to bitmap field(bitmap = "~/gui/img/oldimage").
When I run a game, my oldimage.png file is on the screen. But when I try to change my image with myGUI.setBitmap("~/gui/img/newimg") I got only a blank square. In console I got some errors like:
Could not locate texture: ~/gui/img/newimg
Could not locate texture: ~/gui/img/newimg_n
Could not locate texture: ~/gui/img/newimg_h
Could not locate texture: ~/gui/img/newimg_d
Could not locate texture: ~/gui/img/newimg_t
Files newimg.png, newimg_n.png etc are exists in the directory ~/gui/img/.
I created a .gui file with GUI Builder tool.
Then I created "GuiControl" and "GuiBitmapButtonCtrl"(myGUI). After that I successfully attached my oldimage.png file to bitmap field(bitmap = "~/gui/img/oldimage").
When I run a game, my oldimage.png file is on the screen. But when I try to change my image with myGUI.setBitmap("~/gui/img/newimg") I got only a blank square. In console I got some errors like:
Could not locate texture: ~/gui/img/newimg
Could not locate texture: ~/gui/img/newimg_n
Could not locate texture: ~/gui/img/newimg_h
Could not locate texture: ~/gui/img/newimg_d
Could not locate texture: ~/gui/img/newimg_t
Files newimg.png, newimg_n.png etc are exists in the directory ~/gui/img/.
About the author
http://shaggydwarf.com
#2
Erm, might not be the answer, gimme a couple ticks to see what I can find.[/s]
Alright, here goes. TGB's hating me right now, so I wasn't able to resolve the _h _d _i issues, but I honestly I didn't play with it too much.
In the GUI editor, escape your quotations in setBitmap as so: setBitmap(\"game/data/images/button.png\");
Second, I had issues using the tilde/home character caused no shortage of issues with my tests, but I was able to get it to work by using the game/data/images directory to get to the image. You do need to include the file extension when calling setBitmap, and your _i (and the others) will need to be at the end of the file extension, rather than at the end of the file name.
05/05/2011 (7:55 pm)
[s]Add .png to your setBitmap call.Erm, might not be the answer, gimme a couple ticks to see what I can find.[/s]
Alright, here goes. TGB's hating me right now, so I wasn't able to resolve the _h _d _i issues, but I honestly I didn't play with it too much.
In the GUI editor, escape your quotations in setBitmap as so: setBitmap(\"game/data/images/button.png\");
Second, I had issues using the tilde/home character caused no shortage of issues with my tests, but I was able to get it to work by using the game/data/images directory to get to the image. You do need to include the file extension when calling setBitmap, and your _i (and the others) will need to be at the end of the file extension, rather than at the end of the file name.
SysRat
Shaggy Dwarf