Jump to content
  • Advertisement
Sign in to follow this  
Dustin Booher

having a bit of trouble splitting a tileset up

This topic is 2494 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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)

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!