ngui 脚本绘制sprite

public GameObject _background;
public UIAtlas atlas;
private Dictionary<int, UISprite> _allCardSprite;

void Start () {
        _allCardSprite = new Dictionary<int, UISprite> ();

}
for (int i=0; i<10; ++i) { GameObject _parent = NGUITools.AddChild (_background); _parent.name = "cards"; _parent.transform.localPosition = new Vector3 (i*10, 200.0f, 0.0f); UISprite _sprite = NGUITools.AddWidget<UISprite>(_parent); _sprite.atlas = atlas; _sprite.depth = i; _sprite.name = i.ToString(); _sprite.spriteName = i.ToString(); _allCardSprite.Add(i, _sprite); _sprite.MakePixelPerfect(); } foreach (KeyValuePair<int, UISprite> pair in _allCardSprite){ TweenPosition _position = pair.Value.gameObject.GetComponent<TweenPosition>(); if (_position == null){ _position = pair.Value.gameObject.AddComponent<TweenPosition> (); } _position.duration = 0.2f; _position.delay = pair.Key*0.2f; _position.from = new Vector3(0.0f, 0.0f, 0.0f); _position.to = new Vector3(0.0f, -200.0f, 0.0f); _position.PlayForward(); }

//动态加载头像:
GameObject _look = Resources.Load ("HeroPanel", typeof(GameObject)) as GameObject;
GameObject go = NGUITools.AddChild (_background, _look);
go.transform.position = new Vector3 (0.0f, 0.0f, 0.0f);   //相对中心坐标原点

倒计时:
StartCoroutine(waitForOneSecond(111));
public IEnumerator waitForOneSecond(int number)
 {
        while (coolTime >= 0)
        {
            //Debug.Log ("here:\t" + coolTime+":\t"+number);
            coolTime--;
            yield return new WaitForSeconds(1);   
        }
    }

 shuffle洗牌,cut切牌,deal发牌,sort理牌,draw摸牌,play打出,discard弃牌
 
posted @ 2014-07-25 14:07  Zhaoyier  阅读(392)  评论(0编辑  收藏  举报