Sign in to follow this  
brekehan

managed - mutliple textures (frames) in one file, loading

Recommended Posts

I can load a single texure from a file easily, just by following the tutorials in the SDK. However, I have the need to load multiple "frames" from a single file. Example: Making a button. bitmap is 25 X 50, the top half is frame one- "normal state" and the bottom half is frame two- "pressed state". So I need to load two textures from one button.bmp file Anyone have a code example or link on how to do this in C#? If not maybe a C++ example and I will try to convert it? Thanks!

Share this post


Link to post
Share on other sites
You'll typically will have a texture with all the UI elements (button, button pressed etc) on it in known areas. If you draw the UI with the Sprite helper class, you can specify the source rectangles (the 'known areas') which will be rendered. Using sprites is probably the easiest way to implement this and you can find a complete UI tutorial over here. IIRC this tutorial also uses the Sprite helper class.

If you want to use you own vertices to draw the button, you should just set the appropriate texture on the device depending on the state of your button. It is possible to still use a single texture with all the UI elements on it with this approach, but it's a bit messy to get it to work.

Hope this helps :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this