HOWTO: Slidey Menu for ZuneHD UNFINISHED

THIS IS UNFINISHED, DONT DO IT JUST YET

A user on ZB's asked me how to create a slidey menu for the Zune HD. So here is a quick tutorial. Ive made it very simple instead of being perfect coding so if you want something like this, rather use it for the idea instead of the actual implementation(unless ofcourse it works fine for what you need).

1) Ok lets create a button

 

2) Now create a XNA 3.1 project in VS or VC#. Right click on Content in your solution explorer and Add -> Existing Item. Navigate to where you have saved your button image and select it.

 

3) Right click on your project(not the solution) in the solution explorer and click Add -> Class. Name it Menu.cs and hit OK.

 

4) In the new class add the following using directives at the top:


using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System.Collections;

5) Now add this code inside class Menu { ... }

        Vector2 pos; //to store our x and y
        Texture2D tex; //to store menuitem texture
        ArrayList menuItems = new ArrayList(); //stores our items
        int currMaxY = 0;
        public Vector2 acceleration; //keeps the items acceleration
        public Menu(Vector2 pos, Texture2D menuItemTex)
        {
            this.pos = pos;
            this.tex = menuItemTex;
            acceleration = new Vector2(0,0);
        }

Basically that is just the initialization of the menu object and creating the variables we will use.

 

 

6) Next, create another class(right click project -> Add -> class) and call it MenuItem.cs

7) Add the same using directives to this new class as you did the last:


using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System.Collections;

8) Put the following initialization code into the menu item class inside class MenuItem{ ...}


public Vector2 pos; //to store our x and y
        //this x and y is in relation to the menu pos
        public Texture2D tex; //to store menuitem texture

        public MenuItem(Vector2 pos, Texture2D menuItemTex)
        {
            this.pos = pos;
            this.tex = menuItemTex;
        }

 

9) Going back to the Menu class we need to make a method to add menu items. So add this below public Menu(Vect....


public void AddMenuItem(string text)
        {
            MenuItem item = new MenuItem(new Vector2(0, currMaxY + 10), tex);
            //creates a new item. It will get its Y value from the increasing
            //currMaxY value which stores where the last item is.
            currMaxY += tex.Height;//add the item height to it.
            menuItems.Add(item);//add the menuitem to the arraylist.
        }

10) Ok now lets add some drawing code to out Menu class. We will call the Menu DrawMe() method from our game1 class sending in the current SpriteBatch so that the Menu class can draw its items. There are better ways of doing this(like inheriting from DrawableGameComponent but for simplicity sake lets do it this way).


public void DrawMe(SpriteBatch sb)
        {
            foreach (MenuItem item in menuItems)
            {
                //this will loop through the menu items.
               //the reason for adding the menu pos to the item pos is that item positions are
                //done in relation to the menu. So if the items Y is 60 and the menus Y is 100 then the item will be at 160px
                sb.Draw(item.tex, (item.pos += pos), Color.White);
            }
        }

 

11) Next we need one final method added to our Menu class called update. What this will do is two things, a)it will move the menu with the finger, and b) when a finger is not on it will keep them moving so that if you have 500 menu items you can flick it to scroll down fast. So add the following updateme() method to Men

 

TO BE CONTINUED

Tags:

Comments

Clouds
Clouds United States
11/7/2009 8:49:37 AM Permalink

Ok so I made the button with Gimp and now I'm stuck on "
4) In the new class add the following using directives at the top:
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System.Collections;
"

Where do I add this code?

"
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ButtonMenu
{
    class Menu
    {
    }
}
"
Please help, sorry for stupid dumb question.

Admin
Admin South Africa
11/9/2009 8:35:36 AM Permalink

@Clouds, add those 3 lines just below using System.Text

Clouds
Clouds United States
11/10/2009 2:21:41 AM Permalink

Thank you very much!!! Will try later.

lionel train set
lionel train set United States
1/6/2010 9:27:34 PM Permalink

I was very pleased to find this site.I wanted to thank you for this great read!! I definitely enjoying every little bit of it and I have you bookmarked to check out new stuff you post.

muscle building supplements
muscle building supplements United States
1/10/2010 3:02:41 AM Permalink

Do you accept guest posts? I would love to write couple articles here.
I was wondering what is up with that weird gravatar??? I know 5am is early and I'm not looking my best at that hour, but I hope I don't look like this! I might however make that face if I'm asked to do 100 pushups. lol

offshore havens
offshore havens United States
1/13/2010 10:37:13 AM Permalink

Great post! I am just starting out in community management/marketing media and trying to learn how to do it well - resources like this article are incredibly helpful. As our company is based in the US, it?s all a bit new to us. The example above is something that I worry about as well, how to show your own genuine enthusiasm and share the fact that your product is useful in that case.

electronic cigarette
electronic cigarette United States
1/15/2010 5:49:07 PM Permalink

I admit, I have not been on this webpage in a long time... however it was another joy to see It is such an important topic and ignored by so many, even professionals. I thank you to help making people more aware of possible issues.
Great stuff as usual...

payday loans
payday loans United States
1/18/2010 11:53:45 PM Permalink

Quality is never an accident; it is always the result of high intention, sincere effort, intelligent direction and skillful execution; it represents the wise choice of many alternatives

lesbian dating sites
lesbian dating sites United States
1/24/2010 8:35:50 PM Permalink

Hello,I love reading through your blog, I wanted to leave a little comment to support you and wish you a good continuation. Wishing you the best of luck for all your blogging efforts.

mlm leads
mlm leads United States
1/26/2010 2:47:38 PM Permalink

Thanks for taking the time to discuss this, I feel strongly about it and love learning more on this topic. If possible, as you gain expertise, would you mind updating your blog with more information? It is extremely helpful for me.

funny maid of honor speeches
funny maid of honor speeches United States
1/26/2010 10:35:41 PM Permalink

Nice information, many thanks to the author. It is incomprehensible to me now, but in general, the usefulness and significance is overwhelming. Thanks again and good luck!

seo tips
seo tips United States
2/1/2010 8:36:51 AM Permalink

When I originally commented I clicked the "Notify me when new comments are added" checkbox and now each time a comment is added I get four emails with the same comment.
Is there any way you can remove me from that service?
Thanks!

Loans in VT
Loans in VT United States
2/2/2010 4:16:09 PM Permalink

He who fears being conquered is sure of defeat.

diaper coupon
diaper coupon United States
2/7/2010 4:52:57 PM Permalink

I thought it was going to be some boring old post, but it really compensated for my time. I will post a link to this page on my blog. I am sure my visitors will find that very useful.

trust realty
trust realty United States
2/7/2010 5:33:06 PM Permalink

You may have not intended to do so, but I think you have managed to express the state of mind that a lot of people are in. The sense of wanting to help, but not knowing how or where, is something a lot of us are going through.

merchant funding
merchant funding United States
2/9/2010 8:54:20 AM Permalink

You got a really useful blog I have been here reading for about an hour. I am a newbie and your success is very much an inspiration for me.

I admit, I have not been on this webpage in a long time... however it was another joy to see It is such an important topic and ignored by so many, even professionals. I thank you to help making people more aware of possible issues.
Great stuff as usual...

Pretty good post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I'll be subscribing to your feed and I hope you post again soon.

Hepa Vacuum Cleaners
Hepa Vacuum Cleaners United States
2/16/2010 11:07:33 AM Permalink

Hey - nice blog, just looking around some blogs, seems a pretty nice platform you are using. I'm currently using Wordpress for a few of my sites but looking to change one of them over to a platform similar to yours as a trial run. Anything in particular you would recommend about it?

Fumi Purse Hanger
Fumi Purse Hanger United States
2/27/2010 12:36:43 AM Permalink

Very interesting material you have on the site. It is not very often I can find content like yours you have on the site. I like it!

e liquid reviews
e liquid reviews United States
2/27/2010 8:47:44 AM Permalink

It's hard to come across posts such as yours that is actually fun and
informative to read. Keep it going.

Will save your site in my bookmarks. Great stuff.

Home Theater Installation
Home Theater Installation United States
3/4/2010 6:57:39 AM Permalink

Thanks for the info you provided.

drug testing
drug testing United States
3/4/2010 7:03:27 AM Permalink

Your site is really cool, thanks.

You have very good info on the site. Thanks so much!

Sean Favieri
Sean Favieri United States
3/6/2010 8:33:04 AM Permalink

Fantastic post! This could aid lots of people find out about this matter. Do you want to incorporate video clips together with these? It could undoubtedly help out. Your reason was spot on and owing to you; I probably won't have to describe everything to my pals. I can simply direct them here

boards
boards United States
3/6/2010 6:17:28 PM Permalink

Do you accept guest posts? I would love to write couple articles here.
I was wondering what is up with that weird gravatar??? I know 5am is early and I'm not looking my best at that hour, but I hope I don't look like this! I might however make that face if I'm asked to do 100 pushups. lol

Dude.. I am not much into reading, but somehow I got to read lots of articles on your blog. Its amazing how interesting it is for me to visit you very often.

Add comment




  Country flag

biuquote
  • Comment
  • Preview
Loading