码迷,mamicode.com
首页 > 其他好文 > 详细

ngui 脚本绘制sprite

时间:2014-07-25 16:44:51      阅读:293      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   os   io   for   re   c   

public GameObject _background;
public UIAtlas atlas;
private Dictionary<int, UISprite> _allCardSprite;
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);   //相对中心坐标原点

ngui 脚本绘制sprite,布布扣,bubuko.com

ngui 脚本绘制sprite

标签:style   blog   color   os   io   for   re   c   

原文地址:http://www.cnblogs.com/zhaoyier/p/3867901.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!