Game Development Community

Accessing Cells in an image

by Charles "monkeyboy" Gibson · in Torque Game Builder · 03/24/2005 (7:17 am) · 4 replies

Hi, I have a question regarding how to access a cell from an image map in code.

Let me explain what I am doing. I am creating a demo game (breakout clone) to learn the basics of T2D. I included 5 blocks into one image file stacked vertically of different color. I did this so I didn't have to create 5 separate image files for each block.

What I want to do is access one block from the image file. For example access the first block to use it to draw the first row of blocks, then the second block to do the next row, and so on.

First I setup the image map datablock. Here is how I did it:

datablock fxImageMapDatablock2D( block )
{
mode = cell;
textureName = "blocks.png"

cellWidth = "80";
cellHeight = "30";

cellCountX = "1";
cellCountY = "5";
};

From this point, I don't how to access the blocks individually. If anyone could help or even point me in the right direction to figure it out myself it would be appreciated. Thanks in advance for any assistance provided.

#1
03/24/2005 (7:29 am)
When you call

.setImageMap(block);

add the frame number

.setImageMap(block, 0);
#2
03/24/2005 (8:00 am)
Alternatively:

.setImageMap(myimagemap);
.setFrame(0);
#3
03/24/2005 (9:28 am)
Thank you so much for both of your quick responses. I really appreciate it. You guys are great!!!
#4
03/24/2005 (10:08 am)
Very true... the command LotekK mentioned is very useful...

.setFrame()

since it can be done after creation :)