Skip to main content
gamedev.net
🔒 Locked

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

Started by brekehan 0 replies 450+ views
Original Post
brekehan
brekehan
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!
remigius
remigius
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 :)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.