当前位置: 首页>>代码示例>>C#>>正文


C# LTexture.SetTexCords方法代码示例

本文整理汇总了C#中Loon.Core.Graphics.Opengl.LTexture.SetTexCords方法的典型用法代码示例。如果您正苦于以下问题:C# LTexture.SetTexCords方法的具体用法?C# LTexture.SetTexCords怎么用?C# LTexture.SetTexCords使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Loon.Core.Graphics.Opengl.LTexture的用法示例。


在下文中一共展示了LTexture.SetTexCords方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Copy

        private LTexture Copy(int width, int height,
                bool flipHorizontal, bool flipVertial)
        {

            int hashCode = 1;

            hashCode = LSystem.Unite(hashCode, width);
            hashCode = LSystem.Unite(hashCode, height);
            hashCode = LSystem.Unite(hashCode, flipHorizontal);
            hashCode = LSystem.Unite(hashCode, flipVertial);

            if (childs == null)
            {
                childs = new System.Collections.Generic.Dictionary<Int32, LTexture>(10);
            }

            lock (childs)
            {

                LTexture cache = (LTexture)CollectionUtils.Get(childs, hashCode);

                if (cache != null)
                {
                    return cache;
                }

                if (dataCords == null)
                {
                    SetVertCords(this.GetWidth(), this.GetHeight());
                }

                LTexture copy = new LTexture();

                if (isLoaded)
                {


                    copy.parent = this;
                    copy.imageData = imageData;
                    copy.textureID = textureID;
                    copy.isLoaded = isLoaded;
                    copy.replace = replace;
                    copy.isStatic = isStatic;
                    copy.reload = reload;
                    copy.format = format;
                    copy.hasAlpha = hasAlpha;
                    copy.SetVertCords(width, height);
                    copy.texWidth = texWidth;
                    copy.texHeight = texHeight;
                    copy.SetTexCords(xOff, yOff, widthRatio, heightRatio);
                    if (flipHorizontal)
                    {
                        Swap(8, 10, copy.dataCords);
                        Swap(12, 14, copy.dataCords);
                    }
                    if (flipVertial)
                    {
                        Swap(9, 13, copy.dataCords);
                        Swap(11, 15, copy.dataCords);
                    }
                    copy.xOff = dataCords[8];
                    copy.yOff = dataCords[9];
                    copy.widthRatio = dataCords[14];
                    copy.heightRatio = dataCords[15];

                    System.Array.Copy(crops, 0, copy.crops, 0, crops.Length);

                }
                else
                {

                    copy.width = width;
                    copy.height = height;
                    copy.texWidth = texWidth;
                    copy.texHeight = texHeight;
                    copy.imageData = imageData;
                    copy.subX = 0;
                    copy.subY = 0;
                    copy.subWidth = width;
                    copy.subHeight = height;
                    copy.isVisible = false;

                    LSystem.Load(new CopyUpdate(this, copy, 0, 0, width, height, flipHorizontal, flipVertial));

                }
                isChild = true;
                CollectionUtils.Put(childs, hashCode, copy);
                return copy;
            }
        }
开发者ID:darragh-murphy,项目名称:LGame,代码行数:90,代码来源:LTexture.cs

示例2: GetSubTexture

        public LTexture GetSubTexture(int x, int y, int width,
                 int height)
        {

            int hashCode = 1;

            hashCode = LSystem.Unite(hashCode, x);
            hashCode = LSystem.Unite(hashCode, y);
            hashCode = LSystem.Unite(hashCode, width);
            hashCode = LSystem.Unite(hashCode, height);

            if (childs == null)
            {
                childs = new System.Collections.Generic.Dictionary<Int32, LTexture>(10);
            }

            lock (childs)
            {
                LTexture cache = (LTexture)CollectionUtils.Get(childs, hashCode);

                if (cache != null)
                {
                    return cache;
                }

                LTexture sub = new LTexture();

                if (isLoaded)
                {
                    sub.parent = this;
                    sub.textureID = textureID;
                    sub.isLoaded = isLoaded;
                    sub.imageData = imageData;
                    sub.hasAlpha = hasAlpha;
                    sub.replace = replace;
                    sub.isStatic = isStatic;
                    sub.reload = reload;
                    sub.format = format;
                    sub.width = width;
                    sub.height = height;
                    sub.texWidth = texWidth;
                    sub.texHeight = texHeight;
                    sub.SetVertCords(width, height);
                    sub.xOff = (((float)x / this.width) * widthRatio) + xOff;
                    sub.yOff = (((float)y / this.height) * heightRatio) + yOff;
                    sub.widthRatio = (((float)width / this.width) * widthRatio)
                            + sub.xOff;
                    sub.heightRatio = (((float)height / this.height) * heightRatio)
                            + sub.yOff;
                    sub.SetTexCords(sub.xOff, sub.yOff, sub.widthRatio,
                            sub.heightRatio);
                    Crop(sub, x, y, width, height);
                }
                else
                {

                    sub.width = width;
                    sub.height = height;
                    sub.texWidth = texWidth;
                    sub.texHeight = texHeight;
                    sub.imageData = imageData;
                    sub.subX = x;
                    sub.subY = y;
                    sub.subWidth = width;
                    sub.subHeight = height;
                    sub.isVisible = false;

                    LSystem.Load(new SubUpdate(this, sub, x, y, width, height));
                }
                isChild = true;
                CollectionUtils.Put(childs, hashCode, sub);
                return sub;
            }
        }
开发者ID:darragh-murphy,项目名称:LGame,代码行数:74,代码来源:LTexture.cs


注:本文中的Loon.Core.Graphics.Opengl.LTexture.SetTexCords方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。