creating accordion like menu in wade game
Shri

Gio,

 

I thought you had some gui questions before, so I'm sorry if this is a repeat.

 

I am trying to create an accordion-like menu in a wade game.

My questions are what is the best way to go about this.

1) set the game to container and create the menu outisde the wade app via html/css/ jquery

2) create the menu in the game using scene objects

2a) if I create it using scene objects what is the best way to create sub menus ? In my previous attempts, I have been using sprites and checking the position of the click to determine which sub menu item was selected. Would it be better to 'nest' scene objects ?

3) Is there a different method you would recommend ?

 

Any  guidance you can provide would be appreciated.

 

cheers

All 7 Comments
Gio

I would strongly recommend the second approach.

 

The problem with the first is that, while it's the easiest in terms of making the accordion work, it will be very difficult to scale and reposition properly when the game is resized. If it's drawn into the game's canvas (with method 2), then it's resized in the same way as everything else, and it can be done automatically by WADE.

 

It is a good idea to nest scene objects, and the key to doing that in a reusable way is using behaviors. I have made a couple of UI behaviors that I don't mind sharing, if you want to do something similar. The basic idea is that you make a behavior that, in its onAddToScene function, creates some UI scene objects, and removes them in its onRemoveFromScene function. 

 

Then when you want to use the UI control, you create a scene object with no sprites, and just that behavior:

var obj = new SceneObject(null, Accordion);

We have been wanting to add a section to the market (a new category) where we can put these behaviors, and we'll do that soon. If you make this accordion behavior in a way that's flexible and reusable, I would be happy to put it there too.

programmer

 

I have made a couple of UI behaviors that I don't mind sharing, if you want to do something similar.

 

Hi Gio.  Can I get in on that sharing?  I'd really like to see an example of one of these behaviors.  I'm trying to figure out a good way to make a text-entry control.

Gio

Hi

 

I have attached my version of a text-entry control (it's what we used for Zirma). On some platforms it falls back to a javascript "prompt", but in most cases it should work as you would expect.

 

Unfortunately I haven't had time to clean up the code or document any of it. The basic idea is that you use it as a behavior, and create a SceneObject with no sprites that uses that behavior. Then you call its init function, so:

var inputBox = new SceneObject(null, TextInputBehavior);inputBox.getBehavior().init(options);

Where options is an object that contains a set of options (all of them are optional). Like I said, it's undocumented, but if you look at the beginning of the init function in the attached source code, it should be pretty easy to understand.

 

Eventually I'll clean it up and make it available in the Market area of this site, but in the meantime I hope this helps. 

programmer

Thanks! 

Shri

Gio,

 

I posted a tab menu demo in the games forum, let me know what you think

 

cheers,

Shri

echar

Link to  TextInputBehavior ?

Gio

I have placed it here. I think it needs to be on a canvas layer to work, seeing as it uses solidFill_ and similar canvas draw functions.

Post a reply
Add Attachment
Submit Reply
Login to Reply