• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# CCTexture2D类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中CCTexture2D的典型用法代码示例。如果您正苦于以下问题:C# CCTexture2D类的具体用法?C# CCTexture2D怎么用?C# CCTexture2D使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



CCTexture2D类属于命名空间,在下文中一共展示了CCTexture2D类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: CCMotionStreak

        public CCMotionStreak(float fade, float minSegIn, float strokeIn, CCColor3B color, CCTexture2D texture)
        {
            streakRenderCommand = new CCCustomCommand(RenderMotionStreak);

            AnchorPoint = CCPoint.Zero;
            IgnoreAnchorPointForPosition = true;
            StartingPositionInitialized = false;
            FastMode = true;
            Texture = texture;
            Color = color;
            stroke = strokeIn;
            BlendFunc = CCBlendFunc.NonPremultiplied;

            minSeg = (minSegIn == -1.0f) ? stroke / 5.0f : minSegIn;
            minSeg *= minSeg;

            fadeDelta = 1.0f / fade;

            maxPoints = (int) (fade * 60.0f) + 2;

            pointState = new float[maxPoints];
            pointVertexes = new CCPoint[maxPoints];
            vertices = new CCV3F_C4B_T2F[(maxPoints + 1) * 2];

            Schedule();
        }
开发者ID:KevinHeyer,项目名称:CocosSharp,代码行数:26,代码来源:CCMotionStreak.cs


示例2: CCRenderTexture

        public CCRenderTexture(CCSize contentSize, CCSize textureSizeInPixels, 
            CCSurfaceFormat colorFormat=CCSurfaceFormat.Color, 
            CCDepthFormat depthFormat=CCDepthFormat.None, 
            CCRenderTargetUsage usage=CCRenderTargetUsage.DiscardContents) : this()
        {
            int textureWidth = (int)textureSizeInPixels.Width;
            int textureHeight = (int)textureSizeInPixels.Height;

            renderTarget2D = drawManager.CreateRenderTarget(
                textureWidth, textureHeight, colorFormat, depthFormat, usage);

            Texture = new CCTexture2D(renderTarget2D, colorFormat, true, false);
            Texture.IsAntialiased = false;

            Sprite = new CCSprite(Texture);
            Sprite.ContentSize = contentSize;
            Sprite.BlendFunc = CCBlendFunc.AlphaBlend;

            CCPoint center = contentSize.Center;

            renderViewMatrix = 
                Matrix.CreateLookAt(new CCPoint3(center, 300.0f).XnaVector, new CCPoint3(center, 0.0f).XnaVector, Vector3.Up);
            renderProjMatrix = 
                Matrix.CreateOrthographic(contentSize.Width, contentSize.Height, 1024f, -1024);
            renderViewport = new Viewport(0, 0, textureWidth, textureHeight);


            clearColor = CCColor4B.Transparent;
            drawManager.SetRenderTarget(Texture);
            drawManager.Clear(clearColor);
            drawManager.RestoreRenderTarget();
        }
开发者ID:KevinHeyer,项目名称:CocosSharp,代码行数:32,代码来源:CCRenderTexture.cs


示例3: CreateNativeLabel

        internal static CCTexture2D CreateNativeLabel(string text, CCSize dimensions, CCTextAlignment hAlignment,
		                                   CCVerticalTextAlignment vAlignment, string fontName,
		                                   float fontSize, CCColor4B textColor)
		{

		    if (string.IsNullOrEmpty(text))
		    {
		        return new CCTexture2D();
		    }

		    var font = CreateFont (fontName, fontSize);

            if (dimensions.Equals(CCSize.Zero))
            {
                CreateBitmap(1, 1);

                var ms = _graphics.MeasureString(text, font);
                
                dimensions.Width = ms.Width;
                dimensions.Height = ms.Height;
            }

            CreateBitmap((int)dimensions.Width, (int)dimensions.Height);

            var stringFormat = new StringFormat();

		    switch (hAlignment)
		    {
		        case CCTextAlignment.Left:
                    stringFormat.Alignment = StringAlignment.Near;
		            break;
		        case CCTextAlignment.Center:
                    stringFormat.Alignment = StringAlignment.Center;
		            break;
		        case CCTextAlignment.Right:
                    stringFormat.Alignment = StringAlignment.Far;
		            break;
		    }

		    switch (vAlignment)
		    {
		        case CCVerticalTextAlignment.Top:
        		    stringFormat.LineAlignment = StringAlignment.Near;
		            break;
		        case CCVerticalTextAlignment.Center:
        		    stringFormat.LineAlignment = StringAlignment.Center;
		            break;
		        case CCVerticalTextAlignment.Bottom:
        		    stringFormat.LineAlignment = StringAlignment.Far;
		            break;
		    }

            _graphics.DrawString(text, font, _brush, new RectangleF(0, 0, dimensions.Width, dimensions.Height), stringFormat);
            _graphics.Flush();

            var texture = new CCTexture2D(SaveToStream(), CCSurfaceFormat.Bgra4444);

			return texture;
		}
开发者ID:KerwinMa,项目名称:CocosSharp,代码行数:59,代码来源:CCLabelUtilities-Gdi.cs


示例4: CCGridBase

 protected CCGridBase(CCGridSize gridSize, CCTexture2D texture, bool flipped=false)
 {
     GridSize = gridSize;
     Texture = texture;
     textureFlipped = flipped;
     CCSize texSize = texture.ContentSizeInPixels;
     Step = new CCPoint ((float)Math.Ceiling(texSize.Width / GridSize.X), (float)Math.Ceiling(texSize.Height / GridSize.Y));
 }
开发者ID:KevinHeyer,项目名称:CocosSharp,代码行数:8,代码来源:CCGridBase.cs


示例5: Render

 public void Render (DrawBatch drawBatch, CCTexture2D defaultTexture)
 {
     //device.Textures[0] = _texture ?? defaultTexture;
     //device.DrawUserIndexedPrimitives(PrimitiveType.TriangleList, _vertexBuffer, 0, _vertexBuffer.Length, _indexBuffer, 0, _indexBuffer.Length / 3);
     drawBatch.RenderBatch(PrimitiveType.TriangleList,
         0, _indexBuffer.Length, _indexBuffer,
         0, _vertexBuffer.Length, _vertexBuffer,
         _texture ?? defaultTexture);
 }
开发者ID:460189852,项目名称:cocos-sharp-samples,代码行数:9,代码来源:DrawCache.cs


示例6: CCQuadCommand

 public CCQuadCommand(float globalDepth, CCAffineTransform worldTransform, 
     CCTexture2D texture, CCBlendFunc blendType, int quadCount,
     params CCV3F_C4B_T2F_Quad[] quads) 
     : base(globalDepth, worldTransform)
 {
     Quads = quads;
     QuadCount = quadCount;
     Texture = texture;
     BlendType = blendType;
 }
开发者ID:KevinHeyer,项目名称:CocosSharp,代码行数:10,代码来源:CCQuadCommand.cs


示例7: CCSpriteFrame

 public CCSpriteFrame(CCSize contentSize, CCTexture2D texture, CCRect textureRectInPxls, 
     CCSize originalSizeInPxls, bool rotated=false, CCPoint? offsetInPxls=null)
 {
     TextureRectInPixels = textureRectInPxls;
     ContentSize = contentSize;
     OffsetInPixels = offsetInPxls ?? CCPoint.Zero;
     OriginalSizeInPixels = originalSizeInPxls;
     IsRotated = rotated;
     Texture = texture;
 }
开发者ID:h7ing,项目名称:CocosSharp,代码行数:10,代码来源:CCSpriteFrame.cs


示例8: AddSpriteSheet

 public CCSpriteSheet AddSpriteSheet(string fileName, CCTexture2D texture)
 {
     CCSpriteSheet result;
     if (!_spriteSheets.TryGetValue(fileName, out result))
     {
         result = new CCSpriteSheet(fileName, texture);
         _spriteSheets.Add(fileName, result);
     }
     return result;
 }
开发者ID:Karunp,项目名称:cocos2d-xna,代码行数:10,代码来源:CCSpriteSheetCache.cs


示例9: BackgroungLayer

 /// <summary>
 /// 
 /// </summary>
 /// <param name="bgFile"></param>
 public BackgroungLayer(string bgFile, byte opacity = 255)
     : base()
 {
     BackgroundSprite =
         new CCSprite(BackgroundTexture =
             new CCTexture2D(BACKGROUND_FOLDER + bgFile));
     BackgroundSprite.AnchorPoint = CCPoint.AnchorLowerLeft;
     BackgroundSprite.Opacity = opacity;
     Opacity = opacity;
     AddChild(BackgroundSprite);
 }
开发者ID:hussein-aitlahcen,项目名称:heroesrpg,代码行数:15,代码来源:BackgroungLayer.cs


示例10: InitializeTTFAtlas

        public static void InitializeTTFAtlas(int width, int height)
        {
            m_nWidth = width;
            m_nHeight = height;
            m_nDepth = 4;

            m_pTexture = new CCTexture2D();
            m_pData = new int[width * height];

            m_pNodes.Clear();
            m_pNodes.Add(new ivec3() { x = 1, y = 1, z = m_nWidth - 2 });
        }
开发者ID:KerwinMa,项目名称:CocosSharp,代码行数:12,代码来源:CCLabel.cs


示例11: DrawCacheUnit

        public DrawCacheUnit (VertexPositionColorTexture[] vertexBuffer, int vertexOffset, int vertexCount, short[] indexBuffer, int indexOffset, int indexCount, CCTexture2D texture)
        {
            if (vertexCount > vertexBuffer.Length - vertexOffset)
                throw new ArgumentException("vertexBuffer is too small for the given vertexOffset and vertexCount.");
            if (indexCount > indexBuffer.Length - indexOffset)
                throw new ArgumentException("indexBuffer is too small for the given indexOffset and indexCount.");

            _texture = texture;

            _vertexBuffer = new VertexPositionColorTexture[vertexCount];
            _indexBuffer = new short[indexCount];

            Array.Copy(vertexBuffer, vertexOffset, _vertexBuffer, 0, vertexCount);
            Array.Copy(indexBuffer, indexOffset, _indexBuffer, 0, indexCount);
        }
开发者ID:460189852,项目名称:cocos-sharp-samples,代码行数:15,代码来源:DrawCache.cs


示例12: CCSpriteBatchNode

        public CCSpriteBatchNode(CCTexture2D tex, int capacity=defaultSpriteBatchCapacity)
        {
            BlendFunc = CCBlendFunc.AlphaBlend;

            if (capacity == 0)
            {
                capacity = defaultSpriteBatchCapacity;
            }

            TextureAtlas = new CCTextureAtlas(tex, capacity);

            // no lazy alloc in this node
            Children = new CCRawList<CCNode>(capacity);
            Descendants = new CCRawList<CCSprite>(capacity);
        }
开发者ID:KevinHeyer,项目名称:CocosSharp,代码行数:15,代码来源:CCSpriteBatchNode.cs


示例13: CCTextureAtlas

        public CCTextureAtlas(CCTexture2D texture, int capacity)
        {
            Texture = texture;

            // Re-initialization is not allowed
            Debug.Assert(Quads == null);

            if (capacity < 4)
            {
                capacity = 4;
            }

            vertexBuffer = new CCQuadVertexBuffer(capacity, CCBufferUsage.WriteOnly);
            Quads = vertexBuffer.Data;

            Dirty = true;
        }
开发者ID:Kingwl,项目名称:CocosSharp,代码行数:17,代码来源:CCTextureAtlas.cs


示例14: TextureFill

        public TextureFill()
        {
            
            var _xor6 = BuildXorTexture(6);
            _xor6.SamplerState = SamplerState.LinearWrap;
            _brush1 = new TextureBrush(_xor6);
            _brush2 = new TextureBrush(_xor6)
            {
                Transform = Matrix.CreateTranslation(-50f / _xor6.XNATexture.Width, -175f / _xor6.XNATexture.Height, 0)
            };
            _brush3 = new TextureBrush(_xor6)
            {
                Transform = Matrix.CreateScale(.25f, .5f, 1f)
            };
            _brush4 = new TextureBrush(_xor6)
            {
                Transform = Matrix.CreateRotationZ((float)Math.PI / 4)
            };
            _brush5 = new TextureBrush(_xor6, .5f);

            _brush6 = new TextureBrush(_xor6)
            {
                Color = Microsoft.Xna.Framework.Color.Purple
            };

            var pattern = new CCTexture2D("images/pattern1");

            var state = new SamplerState();
            state.AddressU = TextureAddressMode.Mirror;
            state.AddressV = TextureAddressMode.Wrap;
            pattern.SamplerState = state;

            mirrorBrush = new TextureBrush(pattern)
            {
                Color = Microsoft.Xna.Framework.Color.White
            };

            var pattern2 = new CCTexture2D("images/pattern2");
            pattern2.SamplerState = SamplerState.LinearWrap;
            repeatBrush = new TextureBrush(pattern2);


        }
开发者ID:460189852,项目名称:cocos-sharp-samples,代码行数:43,代码来源:TextureFill.cs


示例15: CCRenderTexture

        public CCRenderTexture(CCSize contentSize, CCSize textureSizeInPixels, 
            CCSurfaceFormat colorFormat=CCSurfaceFormat.Color, 
            CCDepthFormat depthFormat=CCDepthFormat.None, 
            CCRenderTargetUsage usage=CCRenderTargetUsage.DiscardContents)
        {
            int textureWidth = (int)textureSizeInPixels.Width;
            int textureHeight = (int)textureSizeInPixels.Height;

            firstUsage = true;
            renderTarget2D = CCDrawManager.SharedDrawManager.CreateRenderTarget(textureWidth, textureHeight, colorFormat, depthFormat, usage);

            Texture = new CCTexture2D(renderTarget2D, colorFormat, true, false);
            Texture.IsAntialiased = false;

            Sprite = new CCSprite(Texture);
            Sprite.ContentSize = contentSize;
            Sprite.BlendFunc = CCBlendFunc.AlphaBlend;

            AddChild(Sprite);
        }
开发者ID:kkarol93,项目名称:CocosSharp,代码行数:20,代码来源:CCRenderTexture.cs


示例16: CCFontFNT

        /// <summary>
        /// Constructor to create a Bitmap Font configuration object from a .FNT configuration file
        /// string to be parsed and a Stream object of the Atlas Texture to be used.
        /// </summary>
        /// <param name="configInfo">String representation read from a .FNT configuration</param>
        /// <param name="atlasTexture">CCTexture2D Atlas to be used.</param>
        /// <param name="imageOffset">Image Offset</param>
        public CCFontFNT(string configInfo, CCTexture2D atlasTexture, CCVector2? imageOffset = null)
        {

            try
            {
                Configuration = new CCBMFontConfiguration(configInfo, string.Empty);
            }
            catch (Exception exc)
            {
                throw new ContentLoadException("Bitmap Font Configuration is invalid: " + exc.Message);
            }

            this.imageOffset = CCVector2.Zero;

            if (imageOffset.HasValue)
                this.imageOffset = imageOffset.Value;

            AtlasTexture = atlasTexture;

            if (Configuration != null)
                IsFontConfigValid = true;
        }
开发者ID:haithemaraissia,项目名称:CocosSharp,代码行数:29,代码来源:CCFontFNT.cs


示例17: BuildXorTexture

        protected static CCTexture2D BuildXorTexture(int bits)
        {
            if (bits < 1 || bits > 8)
                throw new ArgumentException("Xor texture must have between 1 and 8 bits", "bits");

            CCTexture2D tex2 = new CCTexture2D(1 << bits, 1 << bits);
            var tex = tex2.XNATexture;

            Microsoft.Xna.Framework.Color[] data = new Microsoft.Xna.Framework.Color[tex.Width * tex.Height];

            for (int y = 0; y < tex.Height; y++)
            {
                for (int x = 0; x < tex.Width; x++)
                {
                    float lum = ((x << (8 - bits)) ^ (y << (8 - bits))) / 255f;
                    data[y * tex.Width + x] = new Microsoft.Xna.Framework.Color(lum, lum, lum);
                }
            }

            tex.SetData(data);

            return tex2;
        }
开发者ID:460189852,项目名称:cocos-sharp-samples,代码行数:23,代码来源:TestLayer.cs


示例18: CCQuadCommand

        public CCQuadCommand(float globalZOrder, CCTexture2D texture, CCBlendFunc blendType, 
            CCV3F_C4B_T2F_Quad[] quads, int quadCount, CCAffineTransform modelViewTransform, int flags = 0) 
            : base(globalZOrder, modelViewTransform, flags)
        {
            CommandType = CommandType.QUAD_COMMAND;
            Quads = quads;
            QuadCount = quadCount;
            Texture = texture;
            BlendType = blendType;

            var textureId = texture == null ? 0 : texture.TextureId;

            // +=========================================================+
            // | Material Id 24 bits                                     |
            // +============================+============================+
            // | Texture ID                 | BlendFunc (Src ^ Dest)     |
            // | 12 bits                    | 12 bits                    |
            // +============================+============================+
            MaterialId = textureId << 12 | BlendType.GetHashCode();

            System.Diagnostics.Debug.Assert(MaterialId != 0, "Material Id not set");
                
        }
开发者ID:AnimaRobotics,项目名称:CocosSharp,代码行数:23,代码来源:CCQuadCommand.cs


示例19: CCGrid3D

 public CCGrid3D(CCGridSize gridSize, CCTexture2D texture, bool flipped=false) : base(gridSize, texture, flipped)
 {
 }
开发者ID:KerwinMa,项目名称:CocosSharp,代码行数:3,代码来源:CCGrid3D.cs


示例20: Ball

 public Ball(CCTexture2D tex): base(tex)
 {
 }
开发者ID:KerwinMa,项目名称:CocosSharp,代码行数:3,代码来源:Ball.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# CCVector2类代码示例发布时间:2022-05-24
下一篇:
C# CCTextAlignment类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap