having a bit of trouble splitting a tileset up

Started by
0 comments, last by Dustin Booher 12 years, 2 months ago
so im trying to split up a tileset into seperate tiles, ive done this before but idk what im doing wrong atm.



image_width = Switches.tileset.Width / target_cols;
image_height = Switches.tileset.Height / target_rows;
Color[] data=new Color[image_height*image_width];
Texture2D temp = new Texture2D(Switches.device, image_width, image_height);
Switches.images = new List<Texture2D>();
Switches.positions = new List<Vector2>();
for (int y = 0; y*image_height < Switches.tileset.Height; y++)
{
for(int x=0;x*image_width<Switches.tileset.Width;x++)
{
data = new Color[image_height * image_width];
Switches.tileset.GetData<Color>(0,
new Rectangle(x * image_width, y * image_height, image_width, image_height),
data, x*image_width + (y * image_width), image_height * image_width);
temp.SetData<Color>(data);
Switches.images.Add(temp);
Switches.positions.Add(new Vector2(x*image_width,y*image_height));
}
}


thats my code, in the example im use tile width/height is 32x32 and the image is 64x32 (only 2 tiles)
Advertisement
Okay I fixed it by changing

[color=#660066]Switches[color=#666600].[color=#000000]tileset[color=#666600].[color=#660066]GetData[color=#666600]<[color=#660066]Color[color=#666600]>([color=#006666]0[color=#666600],
[color=#000000] [color=#000088]new[color=#000000] [color=#660066]Rectangle[color=#666600]([color=#000000]x [color=#666600]*[color=#000000] image_width[color=#666600],[color=#000000] y [color=#666600]*[color=#000000] image_height[color=#666600],[color=#000000] image_width[color=#666600],[color=#000000] image_height[color=#666600]),
[color=#000000] data[color=#666600],[color=#000000] x[color=#666600]*[color=#000000]image_width [color=#666600]+[color=#000000] [color=#666600]([color=#000000]y [color=#666600]*[color=#000000] image_width[color=#666600]),[color=#000000] image_height [color=#666600]*[color=#000000] image_width[color=#666600]);

[color=#666600]to



Switches.tileset.GetData<Color>(0,
new Rectangle(x * image_width, y * image_height, image_width, image_height),
data, 0, image_height * image_width);


but now its not reading my first tile at all, it just reads the second one twice.

This topic is closed to new replies.

Advertisement