Jump to content

View more

Image of the Day

Inventory ! Va falloir trouver une autre couleur pour le cadre D: #AzTroScreenshot #screenshotsaturday https://t.co/PvxhGL7cOH
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

having a bit of trouble splitting a tileset up

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
1 reply to this topic

#1 Dustin Booher   Members   

100
Like
0Likes
Like

Posted 14 February 2012 - 11:59 AM

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)

#2 Dustin Booher   Members   

100
Like
0Likes
Like

Posted 14 February 2012 - 12:20 PM

Okay I fixed it by changing

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);

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.




Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.