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

            spritePremulti.Position    = new CCPoint(16, 48);
            spriteNonpremulti.Position = new CCPoint(16, 16);

            CCSize rendSize = new CCSize(32, 64);

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

            //  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.BeginWithClear(CCColor4B.Transparent);
            // A2
            spritePremulti.Visit();
            // B2
            spriteNonpremulti.Visit();
            rend.End();

            /* A1: setup */
            spritePremulti.Position = new CCPoint(windowSize.Width / 2 - 16, windowSize.Height / 2 + 16);
            /* B1: setup */
            spriteNonpremulti.Position = new CCPoint(windowSize.Width / 2 - 16, windowSize.Height / 2 - 16);

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

            AddChild(spriteNonpremulti);
            AddChild(spritePremulti);
            AddChild(rend.Sprite);
        }
        void OnCapture(object sender)
        {
            RemoveChildByTag(childTag);

            var windowSize = VisibleBoundsWorldspace.Size;

            // create a render texture, this is what we are going to draw into
            target = new CCRenderTexture(windowSize, windowSize,
                                         CCSurfaceFormat.Color,
                                         CCDepthFormat.None, CCRenderTargetUsage.PreserveContents);

            target.Sprite.Position = windowSize.Center;

            target.Sprite.AnchorPoint = CCPoint.AnchorMiddle;

            // begin drawing to the render texture
            target.BeginWithClear(CCColor4B.Blue);

            Layer.Visit();

            // finish drawing and return context back to the screen
            target.End();

            AddChild(target.Sprite, 0, childTag);

            target.Sprite.Scale = 0.25f;
        }
            public Button(CCSprite sprite, CCLabel label)
                : this()
            {
                this.ContentSize   = sprite.ScaledContentSize;
                sprite.AnchorPoint = CCPoint.AnchorLowerLeft;
                label.Position     = sprite.ContentSize.Center;

                // Create the render texture to draw to.  It will be the size of the button background sprite
                var render = new CCRenderTexture(sprite.ContentSize, sprite.ContentSize);

                // Clear it to any background color you want
                render.BeginWithClear(CCColor4B.Transparent);

                // Render the background sprite to the render texture
                sprite.Visit();

                // Render the label to the render texture
                label.Visit();

                // End the rendering
                render.End();

                // Add the button sprite to this node so it can be rendered
                buttonSprite             = render.Sprite;
                buttonSprite.AnchorPoint = CCPoint.AnchorMiddle;
                AddChild(this.buttonSprite);
            }
示例#4
0
        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;
        }
示例#5
0
        public void renderScreenShot()
        {
            var size    = Layer.VisibleBoundsWorldspace.Size;
            var texture = new CCRenderTexture(size, size);

            CCAffineTransform worldTransform = AffineWorldTransform;

            texture.Sprite.AnchorPoint = new CCPoint(0, 0);
            texture.BeginWithClear(CCColor4B.Transparent);

            Visit(ref worldTransform);

            texture.End();

            CCSprite sprite = new CCSprite(texture.Sprite.Texture);

            //sprite.Position = new CCPoint(256, 256);
            sprite.Position = new CCPoint(size.Width / 2, size.Height / 2);
            sprite.Opacity  = 182;
            //sprite.IsFlipY = true;
            AddChild(sprite, 999999);
            sprite.Color = CCColor3B.Green;

            sprite.RunAction(
                new CCSequence(
                    new CCFadeTo(2, 0),
                    new CCHide()
                    )
                );
        }
        protected override void InitialiseScenes()
        {
            base.InitialiseScenes();

            var    bounds       = Layer.VisibleBoundsWorldspace;
            CCRect viewportRect = Viewport.ViewportInPixels;

            CCRenderTexture outTexture   = new CCRenderTexture(bounds.Size, viewportRect.Size);
            CCSprite        outTexSprite = outTexture.Sprite;

            var worldTransform = Layer.AffineWorldTransform;

            outTexture.BeginWithClear(0, 0, 0, 0);
            OutSceneNodeContainer.Visit(ref worldTransform);
            outTexture.End();

            outTexSprite.AnchorPoint = CCPoint.AnchorMiddle;
            outTexSprite.Position    = new CCPoint(bounds.Origin.X + bounds.Size.Width / 2, bounds.Size.Height / 2);
            outTexSprite.BlendFunc   = CCBlendFunc.NonPremultiplied;
            outTexSprite.Opacity     = 255;

            CCAction layerAction = new CCSequence(new CCFadeTo(Duration, 0), new CCCallFunc((Finish)));

            outTexSprite.RunAction(layerAction);

            Layer.AddChild(outTexture.Sprite, 3);

            InSceneNodeContainer.Visible  = true;
            OutSceneNodeContainer.Visible = false;
        }
        public CCTexture2D CreateCharacterTexture()
        {
            const int width  = 490;
            const int height = 278;

            var centerPoint      = new CCPoint(width / 2, height / 2);
            var characterTexture = new CCRenderTexture(width, height);

            characterTexture.BeginWithClear(100, 0, 0, 0);

            var bodySprite = CreateCustomisationSprite();

            bodySprite.Position = centerPoint;
            bodySprite.Visit();

            var armorSprite = CreateCustomisationSprite();

            armorSprite.Position = centerPoint;
            armorSprite.Visit();

            var eyesSprite = CreateCustomisationSprite();

            eyesSprite.Position = centerPoint;
            eyesSprite.Visit();

            var noseSprite = CreateCustomisationSprite();

            noseSprite.Position = centerPoint;
            noseSprite.Visit();

            var hairSprite = CreateCustomisationSprite();

            hairSprite.Position = centerPoint;
            hairSprite.Visit();

            var moustacheSprite = CreateCustomisationSprite();

            moustacheSprite.Position = centerPoint;
            moustacheSprite.Visit();

            var beardSprite = CreateCustomisationSprite();

            beardSprite.Position = centerPoint;
            beardSprite.Visit();

            var helmutSprite = CreateCustomisationSprite();

            helmutSprite.Position = centerPoint;
            helmutSprite.Visit();

            var weaponSprite = CreateCustomisationSprite();

            weaponSprite.Position = centerPoint;
            weaponSprite.Visit();

            characterTexture.End();

            return(characterTexture.Sprite.Texture);
        }
示例#8
0
        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.Position = new CCPoint(windowSize.Width * 0.5f, windowSize.Height * 0.5f);

            AddChild(rend);
        }
        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(OGLES.GL_ONE, OGLES.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);
        }
示例#10
0
        private void SwitchToRenderTexture()
        {
            bool areVisualComponentsAlreadyAdded = this.Children != null && this.Children.Contains(visualComponents[0]);

            var oldPosition = this.Position;

            if (!areVisualComponentsAlreadyAdded)
            {
                // Temporarily add them so we can render the object:
                foreach (var component in visualComponents)
                {
                    this.AddChild(component);
                }
            }


            // Create the render texture if it hasn't yet been made:
            if (renderTexture == null)
            {
                // Even though the game is zoomed in to create a pixellated look, we are using
                // high-resolution textures. Therefore, we want to have our canvas be 2x as big as
                // the background so fonts don't appear pixellated
                var pixelResolution = background.ContentSize * 2;
                var unitResolution  = background.ContentSize;
                renderTexture = new CCRenderTexture(unitResolution, pixelResolution);
                //renderTexture.Sprite.Scale = .5f;
            }

            // We don't want the render target to be a child of this when we update it:
            if (this.Children != null && this.Children.Contains(renderTexture.Sprite))
            {
                this.Children.Remove(renderTexture.Sprite);
            }

            // Move this instance back to the origin so it is rendered inside the render target:
            this.Position = CCPoint.Zero;
            renderTexture.BeginWithClear(CCColor4B.Transparent);

            this.Visit();

            renderTexture.End();

            // We no longer want the individual components to be drawn, so remove them:
            foreach (var component in visualComponents)
            {
                this.RemoveChild(component);
            }

            // Move this back to its original position:
            this.Position = oldPosition;

            // add the render target sprite to this:
            renderTexture.Sprite.AnchorPoint = CCPoint.Zero;
            this.AddChild(renderTexture.Sprite);
        }
示例#11
0
        protected override void InitialiseScenes()
        {
            if (Layer == null || Viewport == null)
                return;

            base.InitialiseScenes();

            SetupTransition();

            // create a transparent color layer
            // in which we are going to add our rendertextures
            var bounds = Layer.VisibleBoundsWorldspace;
            CCRect viewportRect = Viewport.ViewportInPixels;

            // create the second render texture for outScene
            CCRenderTexture texture = new CCRenderTexture(bounds.Size, viewportRect.Size);
            texture.Position = bounds.Center;
            texture.AnchorPoint = CCPoint.AnchorMiddle;

            // Temporarily add render texture to get layer/scene properties
            AddChild(texture);

            // Render outScene to its texturebuffer
            texture.BeginWithClear(0, 0, 0, 1);
            SceneNodeContainerToBeModified.Visit();
            texture.End();

            // No longer want to render texture
            RemoveChild(texture);

            // Since we've passed the outScene to the texture we don't need it.
            if (SceneNodeContainerToBeModified == OutSceneNodeContainer)
            {
                HideOutShowIn();
            }

            CCProgressTimer node = ProgressTimerNodeWithRenderTexture(texture);

            // create the blend action
            var layerAction = new CCProgressFromTo(Duration, From, To);

            // add the layer (which contains our two rendertextures) to the scene
            AddChild(node, 2, SceneRadial);

            // run the blend action
            node.RunAction(layerAction);

        }
        void SaveImage(object sender)
        {
            RemoveChildByTag(spriteTag);
            var renderSize = canvasNode.BoundingRect.Size;
            var rtm        = new CCRenderTexture(renderSize, renderSize);

            rtm.BeginWithClear(CCColor4B.Green);
            canvasNode.Position -= canvasNode.BoundingRect.Origin;
            canvasNode.Visit();
            rtm.End();
            canvasNode.Position = CCPoint.Zero;

            rtm.Texture.IsAntialiased = true;
            rtm.Sprite.AnchorPoint    = CCPoint.AnchorLowerLeft;
            rtm.Sprite.Opacity        = 127;
            AddChild(rtm.Sprite, 50, spriteTag);;
        }
示例#13
0
        public GameplayLayer() : base(CCColor4B.Black)
        {
            Animations.Init();


            renderTexture = new CCRenderTexture(VisibleBoundsWorldspace.Size, VisibleBoundsWorldspace.Size * 2);

            background          = new SpaceBackground();
            background.Position = new CCPoint(0, 0);

            player                 = new Player();
            player.Position        = GameParameters.PLAYER_INITIAL_POSITION;
            player.RocketLaunched += NewRocketHandler;

            playerCannotMove    = false;
            playerTakesNoDamage = false;

            playersRocketList       = new List <Rocket>();
            alienInvadersRocketList = new List <Rocket>();

            alienAttackMillis = 0;

            alienHive = new AlienHive(this.ContentSize, NewRocketHandler);

            playerLifeHpDisplay          = new PlayerLifeHpDisplayNode(ref player);
            playerLifeHpDisplay.Position = new CCPoint(VisibleBoundsWorldspace.Size.Width, VisibleBoundsWorldspace.Size.Height);

            renderTexture.BeginWithClear(CCColor4B.Transparent);
            this.Visit();
            renderTexture.End();

            this.AddChild(renderTexture.Sprite);

            renderTexture.Sprite.AddChild(background);

            renderTexture.Sprite.AddChild(player);

            foreach (AlienInvader enemy in alienHive.AlienInvadersList)
            {
                renderTexture.Sprite.AddChild(enemy);
            }

            renderTexture.Sprite.AddChild(playerLifeHpDisplay);

            Schedule(GameLoop, GameParameters.ANIMATION_FRAME_CHANGE_INTERVAL_SECONDS);
        }
示例#14
0
        public override void OnEnter()
        {
            base.OnEnter();

            CCDrawNode circle = new CCDrawNode();

            circle.DrawSolidCircle(new CCPoint(150.0f, 150.0f), 75.0f, new CCColor4B(255, 255, 255, 255));

            CCRenderTexture rtm = new CCRenderTexture(new CCSize(200.0f, 200.0f), new CCSize(200.0f, 200.0f), CCSurfaceFormat.Color, CCDepthFormat.Depth24Stencil8);

            rtm.BeginWithClear(CCColor4B.Orange);
            circle.Visit(); // Draw to rendertarget
            rtm.End();

            rtm.Position    = VisibleBoundsWorldspace.Center;
            rtm.AnchorPoint = CCPoint.AnchorMiddle;

            AddChild(rtm);
        }
        void SaveImage(object sender)
        {
            RemoveChildByTag(spriteTag);
            var renderSize   = canvasNode.BoundingRect.Size;
            var renderOrigin = canvasNode.BoundingRect.Origin;

            // here we calculate the translation of the rendering.  It should be the offset of BoundingRect Origin
            // this will then be passed to the Visit(ref CCAffineTransform) method.
            var translate = CCAffineTransform.Translate(canvasNode.AffineWorldTransform, -renderOrigin.X, -renderOrigin.Y);

            var rtm = new CCRenderTexture(renderSize, renderSize);

            rtm.BeginWithClear(CCColor4B.Green);
            canvasNode.Visit(ref translate);
            rtm.End();

            rtm.Texture.IsAntialiased = true;
            rtm.Sprite.AnchorPoint    = CCPoint.AnchorLowerLeft;
            rtm.Sprite.Opacity        = 127;
            AddChild(rtm.Sprite, 50, spriteTag);;
        }
示例#16
0
        public override void OnEnter()
        {
            base.OnEnter();

            CCDrawNode circle = new CCDrawNode();

            circle.DrawSolidCircle(new CCPoint(150.0f, 150.0f), 75.0f, new CCColor4B(255, 255, 255, 255));

            CCRenderTexture rtm = new CCRenderTexture(new CCSize(200.0f, 200.0f), new CCSize(200.0f, 200.0f), CCSurfaceFormat.Color, CCDepthFormat.Depth24Stencil8);

            rtm.BeginWithClear(CCColor4B.Orange);
            circle.Visit(); // Draw to rendertarget
            rtm.End();

            // Create a new sprite from the render target texture
            var sprite = new CCSprite(rtm.Texture);

            sprite.Position = VisibleBoundsWorldspace.Center;


            AddChild(sprite);
        }
示例#17
0
        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;
        }
示例#18
0
        public LabelSystemFontRenderTexture()
        {

            Color = new CCColor3B(200, 191, 231);
            Opacity = 255;

            label1 = new CCLabel("Visit Rendering", "fonts/MorrisRoman-Black.ttf", 30, CCLabelFormat.SystemFont)
                {
                    Color = CCColor3B.Orange,
                    AnchorPoint = CCPoint.AnchorMiddleLeft,
                    Dimensions = size,
                };
            label1.LabelFormat.Alignment = CCTextAlignment.Center;

            txtLabel = new CCRenderTexture (size, size);


            txtLabel.BeginWithClear (CCColor4B.AliceBlue);
            label1.Visit ();
            txtLabel.End ();

            AddChild(txtLabel.Sprite);

        }
示例#19
0
 void ClearImage(object sender)
 {
     target.BeginWithClear((byte)(CCMacros.CCRandomBetween0And1() * 255), (byte)(CCMacros.CCRandomBetween0And1() * 255),
                           (byte)(CCMacros.CCRandomBetween0And1() * 255), (byte)(CCMacros.CCRandomBetween0And1() * 255));
     target.End();
 }
示例#20
0
        private void SwitchToRenderTexture()
        {
            // The card needs to be moved to the origin (0,0) so it's rendered on the render target.
            // After it's rendered to the CCRenderTexture, it will be moved back to its old position
            var oldPosition = this.Position;

            // Make sure visuals are part of the card so they get rendered
            bool areVisualComponentsAlreadyAdded = this.Children != null && this.Children.Contains(visualComponents[0]);

            if (!areVisualComponentsAlreadyAdded)
            {
                // Temporarily add them so we can render the object:
                foreach (var component in visualComponents)
                {
                    this.AddChild(component);
                }
            }

            // Create the render texture if it hasn't yet been made:
            if (renderTexture == null)
            {
                // Even though the game is zoomed in to create a pixellated look, we are using
                // high-resolution textures. Therefore, we want to have our canvas be 2x as big as
                // the background so fonts don't appear pixellated
                var unitResolution  = background.ContentSize;
                var pixelResolution = background.ContentSize * 2;
                renderTexture = new CCRenderTexture(unitResolution, pixelResolution);
            }

            // We don't want the render target to be a child of the card
            // when we call Visit
            if (this.Children != null && this.Children.Contains(renderTexture.Sprite))
            {
                this.RemoveChild(renderTexture.Sprite);
            }

            // Move this instance back to the origin so it is rendered inside the render target:
            this.Position = CCPoint.Zero;

            // Clears the CCRenderTexture
            renderTexture.BeginWithClear(CCColor4B.Transparent);

            // Visit renders this object and all of its children
            this.Visit();

            // Ends the rendering, which means the CCRenderTexture's Sprite can be used
            renderTexture.End();

            // We no longer want the individual components to be drawn, so remove them:
            foreach (var component in visualComponents)
            {
                this.RemoveChild(component);
            }

            // add the render target sprite to this:
            this.AddChild(renderTexture.Sprite);

            renderTexture.Sprite.AnchorPoint = CCPoint.Zero;

            // Move this back to its original position:
            this.Position = oldPosition;
        }
示例#21
0
        void Init()
        {
            var gesture = CCEventListenerGesture.Create();

            gesture.SetSwipeThreshouldDistance(80);
            gesture.OnSwipeEnded = (swipe) =>
            {
                isSwiped = false;
                switch (swipe)
                {
                case CCEventListenerGesture.SwipeDirection.NONE:
                    break;

                case CCEventListenerGesture.SwipeDirection.UP:
                case CCEventListenerGesture.SwipeDirection.DOWN:
                case CCEventListenerGesture.SwipeDirection.LEFT:       //ふぉーるするー
                case CCEventListenerGesture.SwipeDirection.RIGHT:
                    CCLog.Log($"[OreOreLog]:{nameof(TestLayer)}{this.ZOrder}");

                    var goGame = new CCMenuItemLabel(new CCLabel("ゲームであそぶ", "Arial", 40),
                                                     _ =>
                    {
                        ChangeScene(new Loading(new GameAssetsLoader(new GameAssets())));
                        var dig = GetChildByTag(ModalMenuDialog.TAG) as ModalMenuDialog;
                        dig.Close();
                    });


                    var goTitle = new CCMenuItemLabel(new CCLabel("タイトルにもどる", "Arial", 40),
                                                      _ =>
                    {
                        ChangeScene(new Loading(new TitleAssetsLoader()));
                        var dig = GetChildByTag(ModalMenuDialog.TAG) as ModalMenuDialog;
                        dig.Close();
                    });

                    var cancel = new CCMenuItemLabel(new CCLabel("キャンセル", "Arial", 40),
                                                     _ =>
                    {
                        var dig = GetChildByTag(ModalMenuDialog.TAG) as ModalMenuDialog;
                        dig.Close();
                        RemoveChild(dig);
                        isSwiped = false;
                    });
                    var sns_share = new CCMenuItemLabel(new CCLabel("ランキングのシェア", "Arial", 40),
                                                        _ =>
                    {
                        var dig = GetChildByTag(ModalMenuDialog.TAG) as ModalMenuDialog;
                        dig.Close();
                        RemoveChild(dig);

                        void Share(CCLayer layer)
                        {
                            CCRenderTexture rt = new CCRenderTexture(VisibleBoundsWorldspace.Size, VisibleBoundsWorldspace.Size, CCSurfaceFormat.Color, CCDepthFormat.Depth24Stencil8);
                            rt.BeginWithClear(CCColor4B.Black);
                            layer.Visit();
                            rt.End();
                            rt.Sprite.Position           = VisibleBoundsWorldspace.Center;
                            CCRenderCommand shareCommand = new CCCustomCommand(
                                () => {
                                using (MemoryStream ms = new MemoryStream())
                                {
                                    //rt.Texture.SaveAsPng(ms, (int)layer.VisibleBoundsWorldspace.Size.Width, (int)layer.VisibleBoundsWorldspace.Size.Height);
                                    //ShareControl.ShareImage(ms);
                                    rt.SaveToStream(ms, CCImageFormat.Png);
                                    var _share = Xamarin.Forms.DependencyService.Get <IShareSNS>();

                                    string text = "";
                                    if (_rankingData.IsRankinCurrentPlayData)
                                    {
                                        int score = _rankingData.Ranks[_rankingData.RankinIndex].Score;
                                        if (_rankingData.RankinIndex == 0)
                                        {
                                            text = $"わたしのスコア:{score}点" +
                                                   $"\n" +
                                                   $"ハイスコア更新しました!";
                                        }
                                        else
                                        {
                                            text = $"わたしのスコア:{score}点" +
                                                   $"\n" +
                                                   $"ランキング更新しました!";
                                        }
                                    }
                                    else
                                    {
                                        text = "今のランキングです!";
                                    }

                                    string hashTag = "#撃ち続けろ";

                                    text = text + "\n" + hashTag;
                                    _share.Post(text, ms);
                                }
                            });
                            Renderer.AddCommand(shareCommand);
                        }
                        Share(this);
                        isSwiped = false;
                        return;
                    });

                    var menuItems = new[] { goGame, goTitle, sns_share, cancel };

                    var menu = new ModalMenu(menuItems)
                    {
                        Position = new CCPoint(GlobalGameData.Window_Center_X, GlobalGameData.Window_Center_Y - 30),
                    };

                    menu.AlignItemsVertically(30);

                    var dialog = new ModalMenuDialog(menu);

                    AddChild(dialog, 1, ModalMenuDialog.TAG);


                    isSwiped = true;
                    break;

                default:
                    break;
                }
            };
            AddEventListener(gesture, this.Point.First());

            var touch = new CCEventListenerTouchOneByOne();

            touch.OnTouchBegan = (_, __) =>
            {
                foreach (var label in _rankPointsLabel)
                {
                    if (label.Label.BoundingBoxTransformedToWorld.ContainsPoint(_.Location))
                    {
                        selectedMenuItem = label;
                        label.Selected   = true;
                        return(true);
                    }
                }
                return(false);
            };
            touch.OnTouchMoved = (_, __) =>
            {
                CCMenuItem current = null;
                foreach (var label in _rankPointsLabel)
                {
                    if (label.Label.BoundingBoxTransformedToWorld.ContainsPoint(_.Location))
                    {
                        current = label; break;
                    }
                }
                if (current != selectedMenuItem)
                {
                    if (selectedMenuItem != null)
                    {
                        selectedMenuItem.Selected = false;
                    }

                    if (current != null)
                    {
                        current.Selected = true;
                    }
                    selectedMenuItem = current;
                }
            };
            touch.OnTouchEnded = /*EventListener_TouchEnded*/
                                 (_, __) =>
            {
                if (selectedMenuItem != null)
                {
                    selectedMenuItem.Selected = false;
                    selectedMenuItem.Activate();
                }
            };
            AddEventListener(touch, this);

            if (_rankingData.CurrentPlayData != null)
            {
                var currentScoreLabel = new CCLabel($"あなたのスコア:{_rankingData.CurrentPlayData.Score}点", "arial", 20)
                {
                    Position    = new CCPoint(20, GlobalGameData.Window_Height - 20),
                    AnchorPoint = CCPoint.AnchorMiddleLeft
                };
                AddChild(currentScoreLabel);
                if (_rankingData.IsRankinCurrentPlayData)
                {
                    var omedetoLabel = new CCLabel("ランクインおめでとう!", "arial", 20)
                    {
                        Position = new CCPoint(380, GlobalGameData.Window_Height - 20)
                    };
                    AddChild(omedetoLabel);
                }
            }
            systemLabel = new CCLabel("スワイプ:メニューを開く  スコアを選ぶ:リプレイ", "arial", 20)
            {
                Position    = new CCPoint(20, 20),
                AnchorPoint = CCPoint.AnchorMiddleLeft,
                Visible     = false
            };
            AddChild(systemLabel);
        }