Question about best way to draw background
by Shawn C. · in Torque Game Builder · 01/17/2006 (2:04 pm) · 4 replies
I'm just getting started with T2D, and my first goal seems a simple one. I would like to create a game that uses a large (1024x768) bitmap that will sit statically on screen for the duration of the game and act as my background. I have searched for a tutorial or posting that covers this and have not found one yet.
Should I be using a GuiBitmapCtrl? I have created one and have it showing up in the GUI editor but what is the appropriate way to have it show up in game? In other words what function calls should I be looking at?
Are there docs on the GUI controls that I am missing?
Thanks in advance for any help.
Should I be using a GuiBitmapCtrl? I have created one and have it showing up in the GUI editor but what is the appropriate way to have it show up in game? In other words what function calls should I be looking at?
Are there docs on the GUI controls that I am missing?
Thanks in advance for any help.
#2
I was also wondering about the difference between a GuiChunkedBitmapCtrl and a GuiBitmapCtrl. What is a chunked bitmap? I found many references to them on Google, but no definitions.
Thanks again.
01/17/2006 (4:38 pm)
Thanks, Luke. It occured to me as I was reading your response that I could take a look at the fish demo. I forgot about that one. I created the background as a sprite and set it to layer 31, as you suggested. Once I got the code right, that worked.I was also wondering about the difference between a GuiChunkedBitmapCtrl and a GuiBitmapCtrl. What is a chunked bitmap? I found many references to them on Google, but no definitions.
Thanks again.
#3
01/17/2006 (5:51 pm)
Chunked bitmaps have the added capability of taking large bitmaps that may be too big as one whole image for a video card to handle and slicing it up into pieces behind the scenes so as to support even lowly video cards with anemic capabilities. To my knowledge that's the only difference between that and a normal GuiBitmapCtrl. There is no actual difference in usage or result. I'm guessing there's a miniscule performance hit (like, virtually non-existant) for using a Chunked vs non-chunked.
#4
To achieve this effect and still retain the power to use a large image background we created a new tile map having 128 x 128 tiles and used our 1024 x 768 image in the tile editor as the tile source while building it. Then we just added the tile map to the game and - voila! - a nice big image background that scales with the rest of the playfield.
To change the game board image all we have to do is change the textureName field in the tilemap texture's datablock. However, due to limitations of T2D we have to create a separate tilemap file and datablock for each image we want to use in the game, because once you've defined a datablock you can't redefine it to make it refer to a different image. And tilemap files are dependent on the name of the datablock containing the tile image data. In other words, you can have multiple tilemap files referring to a single datablock, but not a single tilemap that can refer to any datablock.
01/22/2006 (3:14 am)
Our game needs to use the GuiChunkedBitmapCtrl as a static unchanging - and non-scaling background, while the actual game background needs to scale down at certain times. In particular, we're incorporating a custom level editor, and it seemed simplest to just scale down the game board to 75% of its original size and use the remainder of the screen for the editor controls. Having the GuiChunkedBitmapCtrl behind is nice, as it reveals an interface "behind" the game board.To achieve this effect and still retain the power to use a large image background we created a new tile map having 128 x 128 tiles and used our 1024 x 768 image in the tile editor as the tile source while building it. Then we just added the tile map to the game and - voila! - a nice big image background that scales with the rest of the playfield.
To change the game board image all we have to do is change the textureName field in the tilemap texture's datablock. However, due to limitations of T2D we have to create a separate tilemap file and datablock for each image we want to use in the game, because once you've defined a datablock you can't redefine it to make it refer to a different image. And tilemap files are dependent on the name of the datablock containing the tile image data. In other words, you can have multiple tilemap files referring to a single datablock, but not a single tilemap that can refer to any datablock.
Torque 3D Owner Luke D
Default Studio Name
You could also create it as a static or animated T2D sprite and put it on the furthest layer (31) and position/scale it to fit.
I'd quote the actual code here, but I don't have immediate access to my files right now. Let me know if you need further details and I'll post an example later.