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


C# CCSprite.Visit方法代码示例

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


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

示例1: RenderTextureTestDepthStencil

        public RenderTextureTestDepthStencil()
        {
            CCSize s = CCDirector.SharedDirector.WinSize;

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

            CCRenderTexture rend = new CCRenderTexture((int)s.Width, (int)s.Height, SurfaceFormat.Color, DepthFormat.Depth24Stencil8, RenderTargetUsage.DiscardContents);

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

            var save = CCDrawManager.DepthStencilState;

            CCDrawManager.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.DepthStencilState = new DepthStencilState()
            {
                DepthBufferEnable = false,
                StencilEnable = true,
                StencilFunction = CompareFunction.NotEqual,
                StencilPass = StencilOperation.Keep,
                ReferenceStencil = 1
            };
            // GL_SRC_ALPHA

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

            //! move sprite half width and height, and draw only where not marked
            sprite.Position = sprite.Position + new CCPoint(sprite.ContentSize.Width * sprite.Scale, sprite.ContentSize.Height * sprite.Scale) * 0.5f;

            sprite.Visit();

            CCDrawManager.DepthStencilState = save;

            rend.End();


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

            AddChild(rend);
        }
开发者ID:Ratel13,项目名称:cocos2d-xna,代码行数:56,代码来源:RenderTextureTestDepthStencil.cs

示例2: RenderTextureIssue937

        public RenderTextureIssue937()
        {
            /*
            *     1    2
            * A: A1   A2
            *
            * B: B1   B2
            *
            *  A1: premulti sprite
            *  A2: premulti render
            *
            *  B1: non-premulti sprite
            *  B2: non-premulti render
            */
            CCLayerColor background = new CCLayerColor(new CCColor4B(200, 200, 200, 255));
            AddChild(background);

            CCSprite spr_premulti = new CCSprite("Images/fire");
            spr_premulti.Position = new CCPoint(16, 48);

            CCSprite spr_nonpremulti = new CCSprite("Images/fire");
            spr_nonpremulti.Position = new CCPoint(16, 16);


            /* A2 & B2 setup */
            CCRenderTexture rend = new CCRenderTexture(32, 64);

            // It's possible to modify the RenderTexture blending function by
            //CCBlendFunc bf = new CCBlendFunc (OGLES.GL_ONE, OGLES.GL_ONE_MINUS_SRC_ALPHA);
            //rend.Sprite.BlendFunc = bf;

            rend.Begin();
            // A2
            spr_premulti.Visit();
            // B2
            spr_nonpremulti.Visit();
            rend.End();

            CCSize s = CCDirector.SharedDirector.WinSize;

            /* A1: setup */
            spr_premulti.Position = new CCPoint(s.Width / 2 - 16, s.Height / 2 + 16);
            /* B1: setup */
            spr_nonpremulti.Position = new CCPoint(s.Width / 2 - 16, s.Height / 2 - 16);

            rend.Position = new CCPoint(s.Width / 2 + 16, s.Height / 2);

            AddChild(spr_nonpremulti);
            AddChild(spr_premulti);
            AddChild(rend);
        }
开发者ID:Karunp,项目名称:cocos2d-xna,代码行数:51,代码来源:RenderTextureIssue937.cs


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