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


C# CCSprite.Visit方法代码示例

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


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

示例1: OnEnter

        public override void OnEnter()
        {
            base.OnEnter(); CCSize windowSize = Layer.VisibleBoundsWorldspace.Size;

            CCSprite sprite = new CCSprite("Images/fire");
            sprite.Position = new CCPoint(windowSize.Width * 0.25f, 0);
            sprite.Scale = 10;

            CCRenderTexture rend = new CCRenderTexture(windowSize, windowSize,
                CCSurfaceFormat.Color, 
                CCDepthFormat.Depth24Stencil8, CCRenderTargetUsage.DiscardContents);

            rend.BeginWithClear(0, 0, 0, 0, 0);

//            var save = CCDrawManager.SharedDrawManager.DepthStencilState;
//
//            CCDrawManager.SharedDrawManager.DepthStencilState = new DepthStencilState()
//                {
//                    ReferenceStencil = 1,
//
//                    DepthBufferEnable = false,
//                    StencilEnable = true,
//                    StencilFunction = CompareFunction.Always,
//                    StencilPass = StencilOperation.Replace,
//                    
//                    TwoSidedStencilMode = true,
//                    CounterClockwiseStencilFunction = CompareFunction.Always,
//                    CounterClockwiseStencilPass = StencilOperation.Replace,
//                };

            sprite.Visit();

//            CCDrawManager.SharedDrawManager.DepthStencilState = new DepthStencilState()
//            {
//                DepthBufferEnable = false,
//                StencilEnable = true,
//                StencilFunction = CompareFunction.NotEqual,
//                StencilPass = StencilOperation.Keep,
//                ReferenceStencil = 1
//            };

//            CCDrawManager.SharedDrawManager.BlendFunc(new CCBlendFunc(CCOGLES.GL_ONE, CCOGLES.GL_ONE_MINUS_SRC_ALPHA));

            sprite.Position = sprite.Position 
                + new CCPoint(sprite.ContentSize.Width * sprite.ScaleX, sprite.ContentSize.Height * sprite.ScaleY) * 0.5f;

            sprite.Visit();

//            CCDrawManager.SharedDrawManager.DepthStencilState = save;

            rend.End();

            rend.Sprite.Position = new CCPoint(windowSize.Width * 0.5f, windowSize.Height * 0.5f);

            AddChild(rend.Sprite);
        }
开发者ID:KevinHeyer,项目名称:CocosSharp,代码行数:56,代码来源:RenderTextureTestDepthStencil.cs

示例2: SpriteWithColor

        public SpriteWithColor(CCColor4B bgColor, CCSize textureSizeInPixels) : base ()
        {
            // 1: Create new CCRenderTexture
            CCRenderTexture rt = new CCRenderTexture(textureSizeInPixels, textureSizeInPixels);

            // 2: Call CCRenderTexture:begin
            rt.BeginWithClear(bgColor);

            // 3: Draw into the texture
            // You'll add this later
            GenerateGradient(textureSizeInPixels);


            var noise = new CCSprite("images/Noise.png");
            noise.AnchorPoint = CCPoint.AnchorLowerLeft;
            noise.Position = CCPoint.Zero;
            noise.BlendFunc = new CCBlendFunc(CCOGLES.GL_DST_COLOR, CCOGLES.GL_ZERO);
            noise.Texture.SamplerState = Microsoft.Xna.Framework.Graphics.SamplerState.LinearWrap;

            // To get the linear wrap to work correctly we have to set the TextureRectInPixels as well as ContentSize
            noise.TextureRectInPixels = new CCRect(0, 0, textureSizeInPixels.Width, textureSizeInPixels.Height);
            noise.ContentSize = noise.TextureRectInPixels.Size;
            noise.Visit();

            // 4: Call CCRenderTexture:end
            rt.End();

            this.Texture = rt.Texture;

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

示例3: StripeWithColor

        public StripeWithColor(CCColor4B c1, CCColor4B c2, CCSize textureSizeInPixels, int nStripes) : base ()
        {
            // 1: Create new CCRenderTexture
            CCRenderTexture rt = new CCRenderTexture(textureSizeInPixels, textureSizeInPixels);

            // 2: Call CCRenderTexture:begin
            rt.BeginWithClear(c1);

            // 3: Draw into the texture
            // You'll add this later
            GenerateStripes(textureSizeInPixels, c2, nStripes);

            var noise = new CCSprite("images/Noise.png");
            noise.AnchorPoint = CCPoint.AnchorLowerLeft;
            noise.BlendFunc = new CCBlendFunc(CCOGLES.GL_DST_COLOR, CCOGLES.GL_ZERO);
            noise.Visit();

            // 4: Call CCRenderTexture:end
            rt.End();

            this.Texture = rt.Texture;
        }
开发者ID:460189852,项目名称:cocos-sharp-samples,代码行数:22,代码来源:StripeWithColor.cs


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