Ejemplo n.º 1
0
        public override void TouchesBegan(NSSet touches, UIEvent evt)
        {
            // Called when a touch begins
            foreach (var touch in touches)
            {
                UITouch touchc = touches.AnyObject as UITouch;

                // Check click
                var locationc = touchc.LocationInNode(this);
                var checkX    = touchc.LocationInView(View).X;
                var checkY    = touchc.LocationInView(View).Y;

                // other coordinate system
                //var checkX = ((UITouch)touchc).LocationInNode(this).X;
                //var checkY = ((UITouch)touchc).LocationInNode(this).Y;

                // Get Sprite Node at current location
                var nodeAtLocation = GetNodeAtPoint(locationc);
                if (nodeAtLocation.Name == "cancelSpark")
                {
                    ReleaseInfoText();
                }
                else
                {
                    if (nodeAtLocation.Name != "infoNode" && nodeAtLocation.Name != "infoLabel")
                    {
                        // If the info button is clicked change background
                        if (nodeAtLocation.Name == "info" || nodeAtLocation.Name == "navSprite")
                        {
                            infoTouch = true;

                            // Activate information background
                            if (switchInfo == false)
                            {
                                //setInfoText();
                                container.Alpha = 1f;
                                switchInfo      = true;

                                SKAction seqTextureInfo = SKAction.SetTexture(SKTexture.FromImageNamed(("inforeverse")));
                                infoSprite.RunAction((seqTextureInfo));
                            }

                            // Deactivate information background
                            else
                            {
                                container.Alpha = 0f;
                                switchInfo      = false;

                                SKAction seqTextureInfoNormal = SKAction.SetTexture(SKTexture.FromImageNamed(("info")));
                                infoSprite.RunAction((seqTextureInfoNormal));
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Подсвечивание выбранного камешка заменой текстуры в спрайте
        /// </summary>
        /// <param name="gem">Камешек на подстветку.</param>
        private void ShowSelectionIndicator(Gem gem)
        {
            // Открепляем спрайт от родителя, если он есть
            if (selectedSprite.Parent != null)
            {
                selectedSprite.RemoveFromParent();
            }

            SKSpriteNode sprite  = gem.Sprite;
            SKTexture    texture = SKTexture.FromImageNamed(gem.GetSelectedSpriteName());

            selectedSprite.Size = new CGSize(gemCellWidth, gemCellHeight);
            selectedSprite.RunAction(SKAction.SetTexture(texture));

            // "Подсветка" добавляется в качестве потомка к основному спрайту камешка
            sprite.AddChild(selectedSprite);
            selectedSprite.Alpha = 1.0f;
        }
Ejemplo n.º 3
0
        public override void TouchesBegan(NSSet touches, UIEvent evt)
        {
            // Called when a touch begins
            foreach (var touch in touches)
            {
                var touchc         = touches.AnyObject as UITouch;
                var locationc      = touchc.LocationInNode(this);
                var nodeAtLocation = GetNodeAtPoint(locationc);
                infoTouch = false;

                // Release the info text if cancel icon is clicked
                if (nodeAtLocation.Name == "cancelSpark")
                {
                    ReleaseInfoText();
                }
                else
                {
                    // If the touched node is not on the Info Text
                    if (nodeAtLocation.Name != "infoNode" && nodeAtLocation.Name != "infoLabel")
                    {
                        // If Info Icon is clicked set the info background and invert the info icon
                        if (nodeAtLocation.Name == "info")
                        {
                            infoTouch = true;
                            if (switchInfo == false)
                            {
                                switchInfo = true;
                                SKAction seqTexture = SKAction.SetTexture(SKTexture.FromImageNamed(("background_n")));
                                container.RunAction((seqTexture));
                                SKAction seqTextureInfo = SKAction.SetTexture(SKTexture.FromImageNamed(("inforeverse")));
                                infoSprite.RunAction((seqTextureInfo));
                            }
                            else
                            {
                                switchInfo = false;
                                SKAction seqTextureNormal = SKAction.SetTexture(SKTexture.FromImageNamed(("background")));
                                container.RunAction((seqTextureNormal));
                                SKAction seqTextureInfoNormal = SKAction.SetTexture(SKTexture.FromImageNamed(("info")));
                                infoSprite.RunAction((seqTextureInfoNormal));
                            }
                        }

                        // Otherwise update the particles
                        else
                        {
                            // Check click
                            nfloat checkX = touchc.LocationInNode(this).X;
                            nfloat checkY = touchc.LocationInNode(this).Y;

                            particleEmitterNode.Position = locationc;
                            UpdateEmitter(checkX);

                            // If it is the first touch add the particles to the scene
                            if (firstTouch == false)
                            {
                                AddChild(particleEmitterNode);
                                firstTouch = true;
                            }
                        }
                    }
                }
            }
        }