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


C# LTexture.LoadTexture方法代码示例

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


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

示例1: EmulatorButton

        public EmulatorButton(LTexture img, int w, int h, int x, int y,
                bool flag, int sizew, int sizeh)
        {
            this.color = new LColor(LColor.gray.R, LColor.gray.G,
                            LColor.gray.B, 125);
            img.LoadTexture();
            if (flag)
               {
                this.bitmap = img.GetSubTexture(x, y, w, h);
            }
            else
            {
                this.bitmap = img;
            }
            if (bitmap.GetWidth() != sizew || bitmap.GetHeight() != sizeh)
            {

                LTexture tmp = bitmap;
                this.bitmap = bitmap.Scale(sizew, sizeh);

                if (tmp != null)
                {
                    tmp.Dispose();
                    tmp = null;
                }
            }
            this.bounds = new RectBox(0, 0, bitmap.GetWidth(), bitmap.GetHeight());
        }
开发者ID:hellogithubtesting,项目名称:LGame,代码行数:28,代码来源:EmulatorButton.cs

示例2: Draw

        public void Draw(LTexture texture, float x, float y, float originX,
            float originY, float width, float height, float scaleX,
            float scaleY, float rotation, float srcX, float srcY,
            float srcWidth, float srcHeight, bool flipX, bool flipY,
            bool off)
        {
            if (isClose)
            {
                return;
            }
            if (texture == null)
            {
                return;
            }
            if (!texture.isLoaded)
            {
                texture.LoadTexture();
            }
            if (texture.IsChild)
            {
                float xOff = ((srcX / texture.width) * texture.widthRatio) + texture.xOff;
                float yOff = ((srcY / texture.height) * texture.heightRatio) + texture.yOff;
                float widthRatio = ((srcWidth / texture.width) * texture.widthRatio);
                float heightRatio = ((srcHeight / texture.height) * texture.heightRatio);

                int newX = (int)(xOff * texture.texWidth);
                int newY = (int)(yOff * texture.texHeight);
                int newWidth = (int)((texture.texWidth * widthRatio)) - newX;
                int newHeight = (int)((texture.texHeight * heightRatio)) - newY;

                texDst.X = (int)x;
                texDst.Y = (int)y;
                texDst.Width = (int)(width * scaleX);
                texDst.Height = (int)(height * scaleY);
                texSrc.X = newX;
                texSrc.Y = newY;
                texSrc.Width = newWidth;
                texSrc.Height = newHeight;
            }
            else
            {
                texDst.X = (int)x;
                texDst.Y = (int)y;
                texDst.Width = (int)(width * scaleX);
                texDst.Height = (int)(height * scaleY);
                texSrc.X = (int)srcX;
                texSrc.Y = (int)srcY;
                texSrc.Width = (int)(srcWidth - srcX);
                texSrc.Height = (int)(srcHeight - srcY);
            }

            Load(texture);

            SpriteEffects e = SpriteEffects.None;

            if (flipX && !flipY)
            {
                e = SpriteEffects.FlipHorizontally;
            }
            else
                if (flipY && !flipX)
                {
                    e = SpriteEffects.FlipVertically;
                }
                else
                    if (flipX && flipY)
                    {
                        e = SpriteEffects.FlipHorizontally | SpriteEffects.FlipVertically;
                    }

            if (rotation != 0)
            {
                float centerX = texSrc.Width / 2;
                float centerY = texSrc.Height / 2;
                texDst.X += (int)texDst.Width / 2;
                texDst.Y += (int)texDst.Height / 2;
                origin.X = centerX;
                origin.Y = centerY;
                batch.Draw(texture.Texture, texDst, texSrc, color, MathUtils.ToRadians(rotation), origin, e, 0);
            }
            else if (originX != 0 || originX != 0)
            {
                texDst.X += (int)originX;
                texDst.Y += (int)originY;
                origin.X = originX;
                origin.Y = originY;
                batch.Draw(texture.Texture, texDst, texSrc, color, 0, origin, e, 0);
            }
            else
            {
                batch.Draw(texture.Texture, texDst, texSrc, color, 0, Vector2.Zero, e, 0);
            }
            idx++;
        }
开发者ID:hellogithubtesting,项目名称:LGame,代码行数:94,代码来源:SpriteBatch.cs

示例3: GetSplitTextures

 public static LTexture[] GetSplitTextures(LTexture image, int width, int height)
 {
     if (image == null)
     {
         return null;
     }
     image.LoadTexture();
     int frame = 0;
     int wlength = image.Width / width;
     int hlength = image.Height / height;
     int total = wlength * hlength;
     LTexture[] images = new LTexture[total];
     for (int y = 0; y < hlength; y++)
     {
         for (int x = 0; x < wlength; x++)
         {
             images[frame] = image.GetSubTexture((x * width), (y * height), width,
                     height);
             frame++;
         }
     }
     return images;
 }
开发者ID:hellogithubtesting,项目名称:LGame,代码行数:23,代码来源:TextureUtils.cs

示例4: GetSplit2Textures

        public static LTexture[][] GetSplit2Textures(LTexture image, int row,
                int col)
        {
            if (image == null) {
                return null;
            }
            image.LoadTexture();

            int wlength = image.Width / row;
            int hlength = image.Height / col;
            LTexture[][] textures = (LTexture[][])CollectionUtils.XNA_CreateJaggedArray(typeof(LTexture), wlength, hlength);
            for (int y = 0; y < hlength; y++) {
                for (int x = 0; x < wlength; x++) {
                    textures[x][y] = image.GetSubTexture((x * row), (y * col), row,
                            col);
                }
            }
            return textures;
        }
开发者ID:hellogithubtesting,项目名称:LGame,代码行数:19,代码来源:TextureUtils.cs

示例5: DrawBatch

 public void DrawBatch(LTexture texture, float x, float y, float width,
         float height, float srcX, float srcY, float srcWidth,
         float srcHeight, float rotation, Color c)
 {
     if (isClose)
     {
         return;
     }
     if (texture == null)
     {
         return;
     }
     if (!texture.isLoaded)
     {
         texture.LoadTexture();
     }
     initAlphaBlend = !texture.isExt;
     if (texture.IsChild)
     {
         float xOff = ((srcX / texture.width) * texture.widthRatio) + texture.xOff;
         float yOff = ((srcY / texture.height) * texture.heightRatio) + texture.yOff;
         float widthRatio = ((srcWidth / texture.width) * texture.widthRatio);
         float heightRatio = ((srcHeight / texture.height) * texture.heightRatio);
         int newX = (int)(xOff * texture.texWidth);
         int newY = (int)(yOff * texture.texHeight);
         int newWidth = (int)((texture.texWidth * widthRatio)) - newX;
         int newHeight = (int)((texture.texHeight * heightRatio)) - newY;
         texDst.X = (int)x;
         texDst.Y = (int)y;
         texDst.Width = (int)width;
         texDst.Height = (int)height;
         texSrc.X = newX;
         texSrc.Y = newY;
         texSrc.Width = newWidth;
         texSrc.Height = newHeight;
     }
     else
     {
         texDst.X = (int)x;
         texDst.Y = (int)y;
         texDst.Width = (int)width;
         texDst.Height = (int)height;
         texSrc.X = (int)srcX;
         texSrc.Y = (int)srcY;
         texSrc.Width = (int)(srcWidth - srcX);
         texSrc.Height = (int)(srcHeight - srcY);
     }
     if (c == null)
     {
         c = Color.White;
     }
     if (rotation != 0)
     {
         float centerX = texSrc.Width / 2;
         float centerY = texSrc.Height / 2;
         texDst.X += (int)width / 2;
         texDst.Y += (int)height / 2;
         UPos(centerX, centerY);
         batchSprite.Draw(texture.Texture, texDst, texSrc, c, MathUtils.ToRadians(rotation), postion, SpriteEffects.None, 0);
     }
     else
     {
         batchSprite.Draw(texture.Texture, texDst, texSrc, c);
     }
 }
开发者ID:hellogithubtesting,项目名称:LGame,代码行数:65,代码来源:GLEx.cs


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