当前位置:编程学习 > C#/ASP.NET >>

请教!怎样做可循环选择的菜单和子菜单!

大家好,我想做一个可以循环的菜单

内有0,1,2三个选项;

有左、右两个方向来控制菜单,当选到2(也就是最后一项的时候,自动跳回0),选到0的时候,下一个自动跳到2

0选项的功能是返回,1是进入场景,2是打开子菜单

我设置了一个currentItem,代表当前选定的选项;

问题在于,这个主菜单(三个选项)和子菜单(五个选项)都要用到currentItem。

而且子菜单是通过主菜单打开的

逻辑有点搞不清了,请高手指点迷津,感激不尽!

int currentItem = 0;

void PushDetector_Click() {
if (!manager.display.Contains(this)) {
manager.Show(this);

        else {
if (mainMenu) {

if (currentItem == 3 || currentItem == 0) {
manager.Hide(this);
} else if (currentItem == 1) {
Application.LoadLevel("ParticleMan");
}
}
}

if (currentItem == 2) {
this.OnSelect("SubMenu");
}

Debug.LogError("Clicked On: " + currentItem);
}

void SwipeDetector_Left() {
if (manager.display.Contains(this)) {
currentItem++;
Debug.LogWarning("RIGHT   Current Item is: " + currentItem);

for (var i = 0; i < this.menuItems.Length; i++) {
var otheritem = this.menuItems[i];
otheritem.iconSize = 128;
}

if (currentItem == this.menuItems.Length) {
currentItem = 0;
}
this.menuItems[currentItem].iconSize = 150;
}

}

void SwipeDetector_Right() {

if (manager.display.Contains(this)) {

currentItem--;
Debug.LogWarning("LEFT   Current Item is: " + currentItem);

for (var i = 0; i < this.menuItems.Length; i++) {

var otheritem = this.menuItems[i];
otheritem.iconSize = 128;

}

if (currentItem == -1) {
currentItem = this.menuItems.Length - 1;
}

this.menuItems[currentItem].iconSize = 150;
//currentItem = (currentItem-1)%this.menuItems.Length;
}
}
--------------------编程问答-------------------- --------------------编程问答-------------------- 除
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,