Pulling specific cells into new imageMaps
by Jay Laird · in Torque Game Builder · 09/14/2006 (4:02 pm) · 5 replies
So, everything says that we should import images as large single files and let the engine split them up. I can do this, but how do I choose a particular cell's image to a static sprite dynamically (in the script)? I am working on dynamic tile creation, and depending on the surrounding tiles, I would like the tile (a static sprite) to pull a certain frame from the celled image. I don't know what I'm missing here, but would I be better just pulling in individual PNGs for each tile? Is my question clear at all?
If none of that was clear, here's in short terms what I want to do:
if(%towerToTheTop)
%towerImage = "techTowerCell0";
if(%towerToTheBottom)
%towerImage = "techTowerCell1";
if(%towerToTheLeft)
%towerImage = "techTowerCell2";
if(%towerToTheRight)
%towerImage = "techTowerCell3";
%tower.setImageMap(%towerImage);
So how do I split a giant cell image into those smaller maps, or at least how do I call them? Since I don't know. Thanks in advance for any help you can provide.
If none of that was clear, here's in short terms what I want to do:
if(%towerToTheTop)
%towerImage = "techTowerCell0";
if(%towerToTheBottom)
%towerImage = "techTowerCell1";
if(%towerToTheLeft)
%towerImage = "techTowerCell2";
if(%towerToTheRight)
%towerImage = "techTowerCell3";
%tower.setImageMap(%towerImage);
So how do I split a giant cell image into those smaller maps, or at least how do I call them? Since I don't know. Thanks in advance for any help you can provide.
#2
09/15/2006 (8:57 am)
Alright, I appreciate that, and actually that was interesting, however, these tiles are actually going to have health values and such, so I don't think a tileMap would work (would it?). Anyway, I must admit I feel like a fool. I had searched for how to choose a specific frame in the ImageMaps reference guide, however, there is nothing there about the methods. Well, I discovered the methods were in the TGB reference pdf. Learned my lesson. Thanks anyway.
#3
If you want to interrogate the tiles surrounding a paricular tile, then tileLayers make that quite easy just by moving the x and y values of the tile you're looking at. Tiles can contain custom data, so you could also setup tile.health=100, tile.damageValue=20 and so-on.
If you're doing it with staticImageMaps, it could get a bit tricky as you will need to manually setup some kind of mounting system so you know which images are are surrounding which other images.
09/15/2006 (9:15 am)
I don't see why a tileLayer wouldn't work, but without knowing exactly what you're going to be doing with it, it's difficult to say.If you want to interrogate the tiles surrounding a paricular tile, then tileLayers make that quite easy just by moving the x and y values of the tile you're looking at. Tiles can contain custom data, so you could also setup tile.health=100, tile.damageValue=20 and so-on.
If you're doing it with staticImageMaps, it could get a bit tricky as you will need to manually setup some kind of mounting system so you know which images are are surrounding which other images.
#4
09/15/2006 (3:17 pm)
Yeah, I've been setting up that system now, but basically it's a platform construction system within the game which checks an array that I set up and whether that array has a tile built or not, who owns it and so on. Honestly, I probably could have used tileLayers and tileMaps, but, well, I guess since I've been learning this basically on my own (basically my introduction to programming), I've been learning a lot as I build this up. I have a tendency to make things more difficult for myself. Honestly, I'm probably just making my own version of a tileMap. Heheh, oh well. It's almost done now.
#5
09/15/2006 (3:35 pm)
Heh, I know the feeling :) At least you're making progress.
Torque Owner Philip Mansfield
Default Studio Name
It takes a celled imagemap and turns it into a tile layer.